Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Yet another rotation problem

Kareni Mobley
Registered User
Join date: 20 Mar 2008
Posts: 2
03-27-2008 05:43
I've been trying to get an analog clock with moving hands to work properly when rotated. This is a pure learning project for me, to learn rotations. Earlier and simpler projects have worked perfectly so I thought I'd gotten a hang of it. The call I use to set the hands are basiclly the same. It updates the second hand every second (the other two every minute) and sets rotation of the hand based on the root's rotation and the time offset. If I made a clock I was going to use I'd use llTargetOmega for the second hand.

The clock works perfectly when the root is at zero rotation (apart from some sync issues with the second hand). The "fun" starts when I try to rotate the object. For example, when I rotate 90 degrees along the global X axis so it stands straight up (local Y is 12 o'clock) it flips the rotation of the hands from negative local Z rotation to positive. Same with 90 degrees Y rotation. When I combine those two rotations the hands flips axis of rotation and rotate negative local Y. Globally this last rotation is the same as when the root is at zero rotation.

Obviosly I must be doing something wrong. :(

Here's the code I use to set the rotation of the minute hand from the root prim:

CODE

llSetLinkPrimitiveParams(3, [PRIM_ROTATION, <0.0, 0.0, llSin(-min*TWO_PI/120.0), llCos(-min*TWO_PI/120.0)> * llGetRot()]);


min = the variable that holds the minute value

I've read the wiki and searched for similar threads. Nothing helped me so far. From reading other threads I got several different approaches to making a clock, but I want it this way. Or at least understand why it doesn't work properly.

My understanding from the wiki and other threads is that:
CODE

rotation local_rot = offset * llGetRot();


Which is what I thought I was doing in my code...

Any ideas?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-27-2008 10:19
I believe you'll want to think of the position used in llSetLinkPrimitiveParams() as if you were calling llSetPos() from the child prim. That means it is already relative to the root's position, and you are NOT going to want to multiply by llGetRot() in the root prim's script.

EDIT: Err...and likewise for rotation, which is what you're dealing with here in fact. LOL.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-27-2008 10:20
Divide by llGetRot(), instead of multiplying by it.
Kareni Mobley
Registered User
Join date: 20 Mar 2008
Posts: 2
03-27-2008 10:50
From: Deanna Trollop
Divide by llGetRot(), instead of multiplying by it.


Thank you!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-28-2008 08:59
the wiki was right for general purposes, however there is a bug int the implementation of set prim params (and set rot) for child prims which requires a different workaround (SVC-93 IIRC)

for local relative you divide by root rot (or use the set local rot function), for global relative you divide by root rot a second time.
_____________________
|
| . "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...
| -