Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation help

Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
05-16-2006 22:36
I am using the code below to
a. get the rotation of the current prim
b. set the prim at the current rotation + a specified rotation

I am able to set the prims rotation with the function below by calling it like this:
setrot(180) (will set it to 180 degrees)

CODE
setrot(integer a) 
{
vector eul = <0, 0, a>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
llSetRot(quat);
llSay(0,(string)quat);
}


However, if the prim is already at 20 degrees and I specify:
setrot(180)
it should then rotate to 200 degrees.

I certainly have a headache from thinking I had it figured out and then figuring out that I indeed did NOT have it figured out.

Any help would be appreciated.
Thanks!
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-16-2006 23:53
CODE
setrot(integer a) 
{
vector eul = <0, 0, a>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
llSetRot(llGetRot() *quat);
llSay(0,(string)quat);
}


That should do what you were after. You might need to change the say line too...

llSetRot() sets the absolute rotation, so when you call setrot(20) it correctly sets it to 20ยบ. Putting in llGetRot() * quat does the equivalent of adding the rotations together.