Difference between revisions of "LlSetRot"

From Second Life Wiki
Jump to navigation Jump to search
Line 10: Line 10:
**It is better to use [[llSetLocalRot]] to set the rotation of child prims, even if you are setting it to a global rotation (just multiply by the root rotation in that case).
**It is better to use [[llSetLocalRot]] to set the rotation of child prims, even if you are setting it to a global rotation (just multiply by the root rotation in that case).
**There is no easy way to get the roots [[Viewer coordinate frames#Local|local]] rotation of an attached object (other then being told by the root).
**There is no easy way to get the roots [[Viewer coordinate frames#Local|local]] rotation of an attached object (other then being told by the root).
*For small rotation changes, there is an update threshold of ~6 degrees, under which the sim will not send an update for the object to the viewer, though the object will be correctly rotated in the sim. You can change some other aspect of the object (like color, for instance), and it will force an update, however.
*For small rotation changes, there is an update threshold depending on the time duration, between changes. It does not appear to be limited to the 6deg rule any longer.
|spec
|spec
|constants
|constants
|examples
|examples=Drop this script in a prim to have to rotate in 1 degree increments
<pre>
rotation rot_xyzq;
 
default
{
    state_entry()
    {
        vector xyz_angles = <0,1.0,0>; // This is to define a 1 degee change
        vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
        rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
    }
 
    touch_start(integer s)
    {
        llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...
 
    }
}
</pre>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 12:27, 28 December 2007

Summary

Function: llSetRot( rotation rot );

Sets the rotation of the prim to rot.

• rotation rot

Caveats

  • This function causes the script to sleep for 0.2 seconds.
  • If the prim is attached, then this function offsets the rotation by the avatars rotation.
  • If the prim is not the root prim it is offset by the roots local rotation. The work-around is to divide the rotation by the root rotation.
    • If you are trying to set the rotation of a child prim relative to the root prim then divide the local rotation by the root rotation.
    • If you are trying to set the rotation of a child prim to a global rotation then you need to divide the global rotation by the root rotation twice.
    • It is better to use llSetLocalRot to set the rotation of child prims, even if you are setting it to a global rotation (just multiply by the root rotation in that case).
    • There is no easy way to get the roots local rotation of an attached object (other then being told by the root).
  • For small rotation changes, there is an update threshold depending on the time duration, between changes. It does not appear to be limited to the 6deg rule any longer.
All Issues ~ Search JIRA for related Bugs

Examples

Drop this script in a prim to have to rotate in 1 degree increments

rotation rot_xyzq;

default
{
    state_entry()
    {
        vector xyz_angles = <0,1.0,0>; // This is to define a 1 degee change
        vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
        rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
    }

    touch_start(integer s)
    {
        llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...

    }
}

See Also

Functions

•  llGetRot
•  llSetLocalRot

Deep Notes

Search JIRA for related Issues

Signature

function void llSetRot( rotation rot );