stop running away, i need some SERIOUS help here.
WHAT IT SHOULD DO:
1: i give it a euler vector of what rotation i want it to go into. ie: 30, 0,0 = 30 degrees tilted on the x axis. this should be local to it/its linkset.
2: have it calculate an 'arbitrary pivot point' which is one edge defined by the contsants. ie: Z_NEG, the butt-end of the z arrow.
3: stick itself in THAT rotation, with it's z-butt apparently not moving from where i put it.
i revisited the script, and the wiki scrap of information on it... and totally failed to figure things out.
first, i tried to clean up all that stuff deanna was telling me to do above into something simple and organized. here are my notes:
//--now according to deanna voodoo, there should be more rotation multiplications in here
//--okay wait, as far as i can tell, all this pivot/offset done in the other script is just undoing what it did all along.
//1: pivot = zero rotation
//2: pivot = zero rotation with one side edge calculated
//3: pivot = that * the current rotationt
//4: pivot = local pos - - pivot (ie: +pivot) which is what im currently using as offset....
//5: offset = -pivot
//6: offset = * target rotation
//7: pivot = pivot + offset
//--OR-- = pivot + (-pivot * target rotation)
//8: and PIVOT is what the targetpos is.
//-- so what it is REALLY doing is....
//1: pivot starts at zero, and has a half size ln added to it.
//2: that is * the current rotation
//3: now the offset is... localpos + pivot
//3: target pos is... -pivot * target rot... +offset
//-- which except for the negative, is the formula the geeks suggest...??? i think?? or it is, but i added the pivot to the center instead of subtracting.
//--of course... all this could only be functional at zero rotation at all.
//--but it does work in a child prim. at zero rotation. so far.
//-- yep. its totally fubar in standalone or child if you rotate the object. OMFG I HATE ROTATIONS!!!
this is the wiki note written by geeks (interjection mine)
//Note: An object can be rotated around an arbitrary point by multiplying a vector by a rotation in the manner described above. The vector should be the difference between the object's current position and the desired "center-point" of rotation. Take the result of the multiplication and add it to the point of rotation WHICH POINT OF ROTATION YOU IDIOTIC GEEKS!?!?!?. This vector will be the "new location" the object should be moved to.
so i've come up with offset = center + pivot (not minus)
and targetPos = (-pivot * targetRot) + offset are the formulae that (seem to) work.
so now i have the following script.
and it DOES work. under severely controlled circumstances.
what DOESNT work?
1: its totally fubar if the object is rotated away from 0 0 0
2: if i apply the same rotation that it already has, it moves away from its pivot point. its SUPPOSED to keep its z-butt in one spot at any/all rotations! (it doesnt rotate any more, it stays in the same orientation, at least.)
3: if i attempt to see if the new rotation i'm trying to plug in is the same it is already in... the check utterly fails to recognize either
llRot2Euler(llGetLocalRot()) == vAngle
or
llGetLocalRot() == llEuler2Rot(vAngle)
so somehow it has to figure out how/when NOT to change its position depending on whether this rotation i'm setting it to is actually the SAME as it already is in or not.
note:
PIVOT is the edge of the prim, where it should 'appear' to be rotating from.
OFFSET is the distance between the pivot and the center.
TARGETPOS is the end result of calculating where to stick the prim so it's edge(pivot) stays in the same spot
//--edge rotate originally by ged, retranslate by deanna trollop
//--expanded by bloodsong
//--side constants. pos is towards arrow point, neg is towards arrow butt
integer X_POS = 1;
integer X_NEG = 2;
integer Y_POS = 3;
integer Y_NEG = 4;
integer Z_POS = 5;
integer Z_NEG = 6;
RotFromEdge3(vector vAngle, integer iSide)
{
//--okay, FIRST.... figure out the rotations, and if we need to be here at all
rotation startRot = llGetLocalRot();
rotation targetRot = llEuler2Rot(vAngle*DEG_TO_RAD);
if(startRot == targetRot) return; //--easy enough
//UTTERLY FAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//--now we do pivot point voodoo.
//Note: An object can be rotated around an arbitrary point by multiplying a vector by a rotation in the manner described above. The vector should be the difference between the object's current position and the desired "center-point" of rotation. Take the result of the multiplication and add it to the point of rotation. This vector will be the "new location" the object should be moved to.
//-- okay so X---x----
//-- X= desired point
//-- x=center
//-- [---] = difference between them.
vector center = llGetLocalPos(); //--i would think
vector pivot = ZERO_VECTOR; //--which will be the edge based on...
vector offset; //-- center - pivot. or vice versa. crap.
//-- convert to what side
vector size = llGetScale(); //--gets length of sides to find edges.
if(iSide == X_POS)
pivot.x = size.x/2.0;
else if (iSide == Y_POS)
pivot.y = size.y/2.0;
else if (iSide == Z_POS)
pivot.z = size.z/2.0;
else if(iSide == X_NEG)
pivot.x = size.x/ -2.0;
else if (iSide == Y_NEG)
pivot.y = size.y/ -2.0;
else if (iSide == Z_NEG)
pivot.z = size.z/ -2.0;
//--according to deanna's voodoo, this has to be * the current rotation to 'convert to world coordinates.'
pivot = pivot * startRot;
offset = center + pivot; //--as far as i can tell.
//-- plus because - is going the wrong way
//--okay, this is the vector * rotation part except we havent found the relationship between the target rot and the current rot. oh well, here goes...
vector targetPos = (-pivot * targetRot) + offset; //--lets try the center as the 'point of rotation.' no... okay, lets try pivot no... all right center again...
//--and this is giving crap results when the plain offset is where the target SHOULD BE
//--so lets try the offset, which has nothing to do with any 'center of rotation.' nope! same crap.
//--so, against all logic, lets make it -pivot * target rot + offset
//ooookay, that works. go figure. something is screwy.
llOwnerSay("Center="+(string)center+"\ntarget="+(string)targetPos);
llSetPrimitiveParams([ PRIM_POSITION, targetPos,
PRIM_ROTATION, targetRot]);
}
default
{
touch_start(integer total_number)
{
vector home = llGetLocalPos();
integer n;
for (n=0; n<4; ++n)
{
RotFromEdge3(< 30.0, 0.0, 00.0>, Z_NEG);
}
llSleep(5.0);
llSetPos(home);
while (llGetLocalPos() != home)
llSetPos(home);
llSetRot(ZERO_ROTATION);
}
}
the rotfromedge (on one axis) works. the rotfromedge (on 3 axes) works if i want to 'add' a rotation to the current. why does it totally not work when i just want to set an 'absolute' rotational aspect?