Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetRootRotation on attachments?

Farallon Greyskin
Cranky Seal
Join date: 22 Jan 2006
Posts: 491
02-26-2008 16:59
Has this function ALWAYS returned a "zero" rotation value for attachments? I thought I had this working some time ago but I can;t make it work now.

How do you use llSetPrimitiveParams in a child prim of an attachment to set a known rotation (one read and stored previously with llGetLocalRot())?

Doing an llSetRot(llGetLocalRot()) works (prim should not move) but I need to use llSetPrimitiveParams instead to move and position at the same time. In a NON-attachment the following works:

llSetPrimitiveParams([PRIM_POSITION, llGetLocalPos(), PRIM_ROTATION, llGetLocalRot()/llGetRootRotation()]);

However when attached, llGetRootRotation returns a zero rotation and the prim rotates oddly when it should stay put.

What can you use as a reference instead of llGetRootRotation or is it just /impossible/ to use llSetPrimitiveParams to rotate a child prim in an attachment to a previously read and stored value?

I could have sworn this worked some time ago in attachements an non-attachments though...

Again, in short I want to do the following:

Instead if this:
llSetPos(llGetLocalPos());
llSetLocalRot(llGetLocalRot();

I want to do this:
llSetPrimitiveParams([PRIM_POSITION, llGetLocalPos(), PRIM_ROTATION, llGetLocalRot()/llGetRootRotation()]);

in an attachment and have it work. The first methods works but with delays, the second works only if not attached.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-26-2008 20:01
not sure if it's always been that way, but it would seem that it's getting the av rotation (at least as attachments understand it, so it's always zero_vector)

IIRC you need to use llGetLocalRot from the root and communicate that to the children. either that or assume the root is at zero rotation, and apply local rot from the level of the child (can't remember which one it is, the latter I think)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Farallon Greyskin
Cranky Seal
Join date: 22 Jan 2006
Posts: 491
02-26-2008 20:31
I'll give the first suggestion a try, didn't think of that (annoying though) the second doesn't work :/

Thing is, I had this "mechanism" working on an earlier av and it now no longer works. I'm wondering if they broke something in the not too distant past...

EDIT:

Ok your first suggestion worked. THANK YOU! :D

So yeah, IN the root prim I have a script now that gets the local rot and link messages it to the other prims that need the info, then they can do the following and it works as expected (in this sample, the prim should not move at all):

llSetPrimitiveParams([PRIM_POSITION, lLGetLocalPos(), PRIM_ROTATION, llGetLocalRot()/root_rot]); // root_rot being the llGetLocalRot() being returned by the root prim script.
Farallon Greyskin
Cranky Seal
Join date: 22 Jan 2006
Posts: 491
02-26-2008 22:06
As a thank you for the solution, I'll post a bit of the source if it may be useful to others:

Problem: How to move a linked prim in an attachment between two or more known rotations/positions using llSetPrimitiveParam (reduces delays over llSet* functions)

But llSetPrimitiveParams needs you to supply the rotation relative to the root prim so you need to "divide" it but the rotation of of the root prim

So for NON attached items you simply:
llSetPrimitiveParams([PRIM_POSITION, prim_pos_1, PRIM_ROTATION, prim_rot_1/llGetRootRotation()]);

instead of the slower and uglier:
llSetPos(prim_pos_1);
llSetLocalRot(prim_rot_1);

BUT!

If the linkset its an attachment, that doesn't work becuase the root prim has no global rotation so llGetRootRotation() returns useless data (ZERO_ROTATION I think).

If only there was an llGetRootLocalRotation()...

Solution:

Put a script in the root prim that getsthe root prims local rotation and link messages it to the child prims where they can store the info for use later on. This requires resetting the root prim script for EVERY change you make to any child script that uses this info but.. at least it works at all.

RootScript:

default
{
state_entry()
{
llMessageLinked(LINK_ALL_OTHERS, -1, (string)llGetLocalRot(), NULL_KEY);
}

on_rez(integer start_param)
{
llResetScript();
}
}

Child Prim Script:

vector ear_normal_pos = <-0.26850, 0.00229, -0.16010>;
rotation ear_normal_rot = <-0.38604, 0.59833, 0.65246, 0.25937>;

vector ear_up_pos = <-0.30470, 0.00410, -0.13160>;
rotation ear_up_rot = <-0.08812, 0.64355, 0.71108, 0.26916>;

rotation root_rot = ZERO_ROTATION;

default
{
state_entry()
{
// Have to use sets here because we don;t know the root prims rotation yet
llSetPos(ear_normal_pos);
llSetLocalRot(ear_normal_rot);
}

link_message(integer sender_num, integer num, string str, key id)
{
if (num == -1)
{
root_rot = (rotation)str;
return;
}

if (str == "ears normal";)
{
llSetPrimitiveParams([PRIM_POSITION, ear_normal_pos, PRIM_ROTATION, ear_normal_rot/root_rot]);
}
else if (str == "ears up";)
{
llSetPrimitiveParams([PRIM_POSITION, ear_up_pos, PRIM_ROTATION, ear_up_rot/root_rot]);
}
}
}