Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llTargetOmega and local axis

Roslyn Korobase
Registered User
Join date: 3 Mar 2007
Posts: 23
04-26-2007 14:31
Sorry could not find this in the threads or through google.

I want to rotate a object around its local axis so if the object is positioned at a different direction it still rotates correctly. I want to use llTargetOmega to avoid lag and get smooth rotation, the object is non physical.

Simply using :-

llTargetOmega( < rotx, 0, 0 >, speed2 * PI, 1.0 );

this works untill i move the object then it rotates about the wrong axis. I would assume that i need to get the current rotation of the axis and factor this in the the llTargetOmega call so it rotates as I would expect it but I am a bit stuck on which functions and the conversion between rotation and x,y,z etc.

Thanks in advance
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-26-2007 14:57
Multiply the desired local axis vector by llGetRot() to get the global axis.
Roslyn Korobase
Registered User
Join date: 3 Mar 2007
Posts: 23
04-26-2007 23:48
Wow thanks, that really is easy!
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
04-27-2007 08:40
...really easy and won't work if you rotate the object and then take it and rerez it. llTargetOmega() somewhat foolishly does its rotation realtive to an object's "world" axes. I say "world" in quotes, because if the script is in a child prim, the axis is relative to the ROOT prim in the link set.

If you have a spinning object and rotate it using the build tools, the object will still keep spinning around the same axis relative to its own axes, as you'd expect. In other words, if you have a cylinder spinning around its long axis and you rotate it on its side, it'll continue to spin on its long axis... HOWEVER, if you take it and then rerez it, it'll start spinning around the world-Z axis again. I'm not sure on this without testing, but I'd be willing to bet a region-restart would also "reset" the axis of rotation.

To get around this, you'll need to link the object to a (possibly invisible) root prim so that it carries its "world" axes with it. Then multiply the desired local-relative rotation axis by llGetRootRotation() to get the axis to give to llTargetOmega(), I believe. From then on, rotate the entire link set, not just the spinning child prim.
Roslyn Korobase
Registered User
Join date: 3 Mar 2007
Posts: 23
04-27-2007 08:46
I see what you mean, Luckly my objects are quite simple and the rotation scripts etc are all acting on the root prim and when the objects are rezed the scripts will turn off rotation anyway and it has to be enabled via a menu (shich solves that issue).

Thanks anyway
Vlad Bjornson
Virtual Gardener
Join date: 11 Nov 2005
Posts: 650
04-27-2007 14:10
Thanks for the info, Lex. I am constantly confused by rotations in SL and your post actually makes sense to me :) This will be much nicer than having to reset the rotations after moving or updating my objects.