Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rotation via llSetLinkPrimitiveParams, part 1

Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
08-13-2008 19:48
Edit: Nevermind my previous question. Let's back up even further...

I admit defeat. I have no clue how rotation via llSetLinkPrimitiveParams works. It is not doing anything rational.

I would expect this...

llSetLinkPrimitiveParams( linknum, [ PRIM_ROTATION, llEuler2Rot( < 0,0,0 >;) ]);

To align the prim to *some* axis. I don't know and don't care if it is a local or global axis. I expect it to align to *some* axis.

It doesn't. Not to either the root or child local axis, and not to the world axis. It's some odd angle relative to any of the these.

If I apply this rotation to several child prims they all align the same way, so it's doing something consistent. But it is not doing anything I expect.

Any clue what it's doing?
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
08-13-2008 21:24
Rez a default cube. Duplicate it, then change the X & Y dimensions of the new prim to 0.1 and its Z dimension to 1, and then move it to the same location as the default cube. Now link them so that the default cube is root.

You now have a default cube with a tall, thin box sticking through it. We'll now try rotating that tall, thin box.

Drop the following script in the object.

default
{
state_entry()
{
}

touch_start( integer total_number)
{
llOwnerSay( "rotating";);
llSetLinkPrimitiveParams( 2, [ PRIM_ROTATION, llEuler2Rot( < PI/2,0,0 > ) ]);
}
}

When you touch the object it should rotate the thin box to another axis. Modify the script so that it'll rotate to another axis. Try PI, or 0, for example. Seems to work, right?

Now rotate the object to an odd angle on all three axis. Now touch it.

Maybe it still works, maybe it doesn't, but if you keep trying different axis it will fail, and if you switch back to an axis that used to work it will still fail. The thin box will not align to the object axis or the world axis.

Why? What is it aligning to?
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-13-2008 22:44
Check out https://jira.secondlife.com/browse/SVC-93 for a discussion of the very special borkitude built into child prim rotations.
_____________________
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
08-13-2008 23:21
Thanks, Viktoria. That may be what I'm encountering. It sounds like llSetLocalRot works in child prims, and that's ultimately what I want to do (set rotation relative to the root prim), but I wanted to do it via llSetLinkPrimitiveParams so I wouldn't have to have a script in every child prim.

You can't...always git...what you wa-ant...
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-13-2008 23:32
In that bug report there are workarounds shown:

From: someone

If you must set a child prim to a world-relative rotation "rot" using PRIM_ROTATION (or llSetRot()), use this:

llSetPrimtiiveParams([PRIM_ROTATION, (rot / llGetRootRotation) / llGetRootRotation);

If you must set a child prim to a local rotation "rot" using PRIM_ROTATION, use this:

llSetPrimitiveParams([PRIM_ROTATION, rot/llGetRootRotation]);

Furthermore, llGetRootRotation does not return a meaningful result for child prims in attachments.


That ought to let you keep it in one script, unless you're playing with an attachment :p
_____________________
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
08-14-2008 01:43
From: Viktoria Dovgal
In that bug report there are workarounds shown:

That ought to let you keep it in one script, unless you're playing with an attachment :p


It is an attachment. The workaround for local rotation doesn't work.

Edit: Here's something that shows promise:

for attachments, use llGetLocalRot instead of llGetRootRotation