Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

setting rotation to a linked prim

Ludvaig Lindman
Registered User
Join date: 2 Feb 2007
Posts: 78
09-29-2007 05:43
hi,
I'm trying to set a certain rotation to a linked prim. So far i put a script into the root prim that sends a linked message to the linked prim I want to rotate. I want this prim to rotate, wait, then rotate to the default position.
To find out about the degrees I want to rotate, I manually rotated the prim and wrote down the numbers.

Then I tried something like this (this is the script in the prim that gets rotated):

//begin script

rotation Inverse(rotation r)
{
r.x = -r.x;
r.y = -r.y;
r.z = -r.z;
return r;
}
vector CloseRot = <0.0, 270.0, 2750.0>;
vector OpenRot = <0.0, 270.0, 264.0>;

rotation open_rot;
rotation close_rot;


integer open = FALSE;
default
{
state_entry()
{
open_rot = llEuler2Rot((DEG_TO_RAD * OpenRot));
close_rot = llEuler2Rot((DEG_TO_RAD * CloseRot));
}

link_message(integer sender_num, integer num, string str, key id)
{
if (str == "open";)
{


llSetPrimitiveParams([PRIM_ROTATION, open_rot * Inverse(Inverse(llGetLocalRot())*llGetRot())]);
}
if (str == "close";)
{




llSetPrimitiveParams([PRIM_ROTATION, close_rot * Inverse(Inverse(llGetLocalRot())*llGetRot())]);
}
}
}

// end script

However, I set the correct rotations, I previously found out about by manually rotating the prim into the desired position. But the script does not seem to set the correct rotation, even though I used the same degrees.
Maybe there is a better way to do this? Most important is, that setting the rotation to this prim even works when manually rotating the whole object.

Any help appreciated. THANKS!
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
09-30-2007 09:37
Just a quick reply but perhaps it will be enough to point you in the right direction.

Try rotating the prim to your desired rotation. Drop in a script which will read out the local rotation of the prim and then use this in your script. This should allow you to set the rotation independent of the objects orientation within the region/sim.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum