Hi,
I am stuck on a problem about relative positions.
I have a base, base1, and a free prim - p1. p1 is at some offset relative to base1 in terms of position and rotation.
I read through the forums and reviewed some others' scripts and came up with this to capture the offset of p1 relative to base1:
//basePosition is a vector that contains llGetPos of base1...
vector relativePosition = llGetPos() - basePosition * llGetRot();
//baseRotation is a rotation that contains the llGetRot() of base1...
rotation relativeRotation = llGetRot() / baseRotation ;
Here is the problem:
I have a new base, base2 and I want p1 to position itself at the same relative position and rotation that it had for base1. base2 can be anywhere and rotated around only one axis (y axis). I place p1 close to base2 and have base2 tell p1 its position using llSay.
I store the relative position and rotation and want to apply that to base2...here is what I have so far:
//NewBasePosition is a vector that contains llGetPos of the new base2...
//NewBaseRotation is a rotation that contains the llGetRot() of base2...
vector vDestPos = (relativePosition * NewBaseRotation) + NewBasePosition;
rotation rDestRot = controllerRotation * NewBaseRotation;
//Move to new location...(I know about the 10m limit..see comments that follow)
llSetPos(vDestPos);
llSetRot(rDestRot);
The new position (vDestPos) is not right...I do not understand why it is so far off.
The new position also does not take the new base's rotation onto consideration. The rotation as a result of calling llSetRot is correct, but the prim's actual postion does not consider the fact that the base is facing another direction.
I have been looking at this for a while and I think I am missing something really basic - I would appreciate some help:
* Am I calculating the relative postion correctly?
* Am I calculating the relative rotation correctly?
* I think my calculation for the destination postion is wrong - I need some guidance
I use llSetPos on purpose because the movement will always be less than 10m and this limits how far the prim can move during testing. I will be doing this at setup time, so there is no on-going need to recalculate the relative position or rotation of some moving base.
Thanks for your help -2fast
