Difference between revisions of "LlTargetOmega"

From Second Life Wiki
Jump to navigation Jump to search
m
(Add very useful info about getting Global/Local axis when rotating propellers and such. This should help fix most poorly written rotation scripts using this function.)
Line 39: Line 39:
|constants
|constants
|helpers
|helpers
|also_functions
|also_functions=
{{LSL DefineRow||[[llRot2Fwd]]|Gets the orientation of the {{HoverText|local x-axis|front-direction of prim}} relative to {{HoverLink|Viewer_coordinate_frames#Global|global coordinate system|the earth}}}}
{{LSL DefineRow||[[llRot2Left]]|Gets the orientation of the {{HoverText|local y-axis|left-direction of prim}} relative to {{HoverLink|Viewer coordinate frames#Global|global coordinate system|the earth}}}}
{{LSL DefineRow||[[llRot2Up]]|Gets the orientation of the {{HoverText|local z-axis|up-direction of prim}} relative to {{HoverLink|Viewer_coordinate_frames#Global|global coordinate system|the earth}}}}
|also_tests
|also_tests
|also_events
|also_events

Revision as of 21:10, 28 March 2012

Summary

Function: llTargetOmega( vector axis, float spinrate, float gain );
0.0 Forced Delay
10.0 Energy

Rotates the object/prim around axis at spinrate * llVecMag(axis) in radians per second with strength gain.

• vector axis arbitrary axis to rotate the object around
• float spinrate rate of rotation in radians per second
• float gain also modulates the final spinrate and disables the rotation behavior if zero

Specification

Physics

  • If the object is not physical or the script is attached to a child prim, then the effect is entirely client side. The rotation experienced by the user cannot be detected or queried by script.
  • If the object is physical and the script is attached to the root prim, then the physical representation is updated regularly. The rotation experienced by the user can be detected or queried by script.

Link Sets

  • If the script is attached to the root prim, the entire object rotates around the region axis
    • If the object is attached then it rotates around the attachment axis
  • If the script is attached to a child prim, the prim rotates around the local axis
    • A Child prim can rotate around its own axis while the entire object rotates around another axis.

Caveats

  • If the object is not physical then the rotation is only a client side effect and it will collide as non-moving geometry.
  • If the function does not appear to be working, make sure that that Advanced > Network > Velocity Interpolate Objects (viewer 1.x) or Develop > Network > Velocity Interpolate Objects (viewer 2.x) is enabled.

Examples

<lsl>//rotates the x axis once per second, // rotates the y axis 3 times per second, // rotates the z axis once every two seconds. // combined the rate is about 3.20156 revolutions per second

llTargetOmega(<1.0,3.0,0.5>,TWO_PI,1.0);</lsl>

<lsl> //Rotates very slowly around a sphere's local X axis .... Good for making a globe that rotates around a tilted axis

default {

   state_entry()
   {
      llTargetOmega(<1.0,0.0,0.0>*llGetRot(),0.1,0.01);
   }
}</lsl>

Notes

  • Use llVecNorm on axis so that spinrate actually represents the rate of rotation.
  • Set the gain to zero to disable and remove the rotation behavior, eg llTargetOmega(ZERO_VECTOR, 0, 0);
    • A spinrate of 0 with a nonzero gain causes the object to try to stop all spin, rather than simply clearing a previous llTargetOmega() call.
  • If there are other forces applied to a prim together with llTargetOmega(), (like using llSetForce to make the object float), use llTargetOmega(-llGetOmega(), 0., 1.) to cancel spin. Note that the gain must be non-zero, but not necessarily 1.

See Also

Functions

•  llRot2Fwd Gets the orientation of the local x-axis relative to the earth
•  llRot2Left Gets the orientation of the local y-axis relative to the earth
•  llRot2Up Gets the orientation of the local z-axis relative to the earth

Deep Notes

Tests

•  llTargetOmega test

Signature

function void llTargetOmega( vector axis, float spinrate, float gain );