Been working lately on helping Mathue with his steam engine. I was using lots of server-side tricks to animate (actually rotating the object by changing it’s position on the server) but this wasn’t giving the effect I was looking for: a wheel smoothly turning on its axis.
Looking through Wiki’s and other web sites, I found what has to be one of the simplest and smoothest ways to rotate objects: llTargetOmega! Instead of using the server resources, llTargetOmega tells each client viewer to create a rotation. The upside: Rotations are very smooth, easily controllable at high speeds (above 10 rpm) and do not use server resources to create the motion. The one downside is that each client may see the object slightly differently for any given moment in time. For that contigency, llSetRot may be best or at least an llSetRot issued at the end of a movement cycle with llTargetOmega to ensure everyone has the same object rotation.
Here’s how simple llTargetOmega is to use:
default
{
state_entry()
{
llTargetOmega( <0, 1, 0>, PI, 1.0 );
}
}
This script will automatically start rotating an object around it’s local Y-axis upon rezzing at the rate of 180 degrees per second (30 RPM).
llTargetOmega takes three parameters: a rotation vector, a spinrate, and a physics gain. In my example, the vector is <0,1,0> which is around the y-axis (the “1″) and spinrate is PI (e.g 3.141…) radians/second which is 180 degrees. The gain of 1.0 is largely ignored for my application, since the objects I’m working with are not turned on for local physics. If they were, the gain represents the “strength” of the spin in the physics engine.
Good luck with your own spinning objects–llTargetOmega should speed you on your way!
