Tuesday, August 7, 2007

Ring scripts, supplemental

For coding in the positions for each hand state, getting the position is easy. Simply use the regular positioning editor to put your ring where it belongs, and copy over the coordinates. However, things become a bit more difficult when it gets to rotation. In the prim editor, rotation is dealt with with degrees. Degrees make sense to you and me, it's what we were taught in school as children. However, degrees are not infallible, in fact they can cancel each other out and cause all sorts of problems really. So LSL keeps degrees in this bizarre format called quaternions. It does all this sine of the cosine of the inverse of the opposite angle cubed minus 11 to tell where things ought to be. That wikipedia page does make it out to be more confusing than it is, and it's a ridiculously confusing thing inherently (but wikipedia tends to not really help when it comes to technical things, as it doesn't explain anything so anyone who doesn't already know exactly what it is could understand).

However, LSL has a handy and easy way to bypass this. Put this little few lines of code into a script in your ring, and then when you wear it move it into position and rotate to your heart's content. Then, when you're copying over the position, touch the ring. It will send you a message telling you what the rotation is in quaternions to copy over! It's just that easy!



default
{

touch_start(integer total_number)
{
llOwnerSay((string)llGetLocalRot());
// This will tell you, and only you, the owner of the object, what the rotation is when you touch it. If the object is attached to you, it will be the rotating in relation to the attachment point, if in a child prim, its rotating in relation to the parent prim. Drop it in a parent prim and drop it on the ground, and it will be its rotation relative to the world. If for some reason you want to announce the rotation to everyone in the sandbox, replace the above line with llSay(0,(string)llGetLocalRot());
}
}

No comments: