08-22-2007 19:56
Use llRezObject to rez a single prim with a random rotation.

How do you, from within the single prim, align it pointing it's x-axis along the global x-axis and then read the angle of rotation around that axis?

I've tried the following, which seemed intuitive, but gives nonsense...

rotation rMyRot = llGetRot();
vector vFwd = llRot2Fwd(rMyRot);

rotation rBetween = llRotBetween(vFwd,<1.0,0.0,0.0>;);

rotation rNewRot = rBetween * rMyRot;

llSetRot(rNewRot);

Shouldn't at this point the prim be lined up with the global x-axis?
And shouldn't I now be able to get the x-axis angle of rotation by...

vector eulerRot = llRot2Euler(rNewRot);
float angleX = eulerRot.x * RAD_TO_DEG;