Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotating child prim in attachment

Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-24-2006 00:02
Is there an invariant rotation operation that can be used with llSetPrimitiveParams and will work on a child prim of an attachment? I know the following will work:

CODE
llSetLocalRot(llGetLocalRot());


Because Get/SetLocalRot both work relative to the attachment's root prim. However, I can't find anything that will work with llSetPrimitiveParams.

CODE
llSetPrimitiveParams([PRIM_ROTATION, llGetLocalRot()]);


That doesn't work, and there's stuff in the Wiki and the scripting library that says that PRIM_ROTATION works like llSetRot in a child prim, not llSetLocalRot, so you need to divide by the root rotation. But this doesn't work either:

CODE
llSetPrimitiveParams([PRIM_ROTATION, llGetLocalRot() / llGetRootRotation()]);


The prim still changes its rotation. Probably because llGetRootRotation returns the root prim's rotation in an unattached object, but returns the avatar's rotation in an attachment. So that call would work in an unattached object, but not an attachment (in a child prim).

Once I figured that out, I finally understood the Child Rotation page in the Wiki. And the only solution described is 'pass the rotations around'. Which means, call llGetLocalRot in the root prim, then send that information out to all the child prims?

If there is an invariant operation, then it should be possible to calculate this. If there isn't one, then it's basically impossible for an attachment's child prim to know its rotation relative to the root prim?

I want to use llSetPrimitiveParams so I can set the position/rotation in a single step. The other idea I had was to use 2 scripts per child prim, have both pick up the link message trigger, and one sets the position, one sets the rotation. Then I can use Get/SetLocalRot, which will work correctly, and also avoid the 0.2s delay. But that's kinda cheap, and cheating, and wasting resources, and probably won't look as smooth as using llSetPrimitiveParams, I'm pretty sure I'll still get some "2-step" movement. But if that's the only way to get the correct rotations...

Or I'm totally missing something, and there is a way to do this. And if there is, I would really appreciate it if someone told me how :)

Ziggy
Jigsaw Partridge
A man of parts
Join date: 3 Apr 2005
Posts: 69
04-24-2006 05:35
I found that only the root prim was able to determine the object's 'attachment' angle (using llGetLocalRot()), so in my scripts I broadcast this to all child prims to allow them to figure out the correct parameters to pass to llSetPrimitiveParams(). I can't use llSetLocalRot(), because I need to simultaneously adjust the child prim position and rotation.

I also found I had to monitor changes to this 'attachment' rotation using a timer, there being no event (that I could determine) raised when it changed.
Introvert Petunia
over 2 billion posts
Join date: 11 Sep 2004
Posts: 2,065
04-24-2006 06:04
Think of the CHILDREN!!!!

(sorry no tech advice here, I just had to say that)
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-24-2006 10:43
OK, I'll try the broadcasting idea. In my case, it's always the root prim that tells the child prims to change their rotation, so I can just add the root rotation information to that message, I don't think I'll need to scan the rotation on a timer. Thanks for the advice.