Difference between revisions of "LlSetLocalRot"

From Second Life Wiki
Jump to navigation Jump to search
m (added some also and tweaked the previous helper)
m (Cleaned up the text ever so slightly and added a bit of clarify text/links.)
 
(2 intermediate revisions by 2 users not shown)
Line 8: Line 8:
|caveats
|caveats
|constants
|constants
|examples=Drop this script in a prim* to rotate it in 1 degree increments. *This prim must be attached as child of a root prim.
|examples=Drop this script into a ''child'' prim to rotate it in 1 degree increments on each [[touch]].
<lsl>rotation rot_xyzq;
<source lang="lsl2">rotation rot_xyzs;
   
   
default
default
Line 15: Line 15:
     state_entry()
     state_entry()
     {
     {
         vector xyz_angles = <0,1.0,0>; // This is to define a 1 degree change
         vector xyz_angles = <0,1.0,0>; // This defines a 1 degree change on the Y axis
         vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
         vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to radians
         rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
         rot_xyzs = llEuler2Rot(angles_in_radians); // Convert to a rotation
     }
     }
   
   
     touch_start(integer s)
     touch_start(integer s)
     {
     {
         llSetLocalRot(llGetLocalRot()*rot_xyzq); //Do the Rotation...
         llSetLocalRot(llGetLocalRot()*rot_xyzs); // Apply the increment rotation to the prim's current rotation ...
   
   
     }
     }
}</lsl>
}</source>
|helpers=
|helpers=
<lsl>//-- this is an equivalent call from any prim in the same link set
<source lang="lsl2">//-- this is an equivalent call from any prim in the same link set
llSetLinkPrimitiveParamsFast( target_prim, [PRIM_ROT_LOCAL, rot] );
llSetLinkPrimitiveParamsFast( target_prim, [PRIM_ROT_LOCAL, rot] );
//-- where "target_prim" is the link number of the prim you want to set the local rotation of</lsl>
//-- where "target_prim" is the link number of the prim you want to set the local rotation of</source>
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetRot]]|}}
{{LSL DefineRow||[[llGetRot]]|}}
Line 46: Line 46:
|cat1=Movement
|cat1=Movement
|cat2=Rotation
|cat2=Rotation
|haiku={{Haiku|Carousel horses|Race, ever facing forward.|Turn without turning.}}
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 13:32, 3 January 2016

Summary

Function: llSetLocalRot( rotation rot );

Sets the rotation of a child prim relative to the root prim

• rotation rot

Caveats

  • This function causes the script to sleep for 0.2 seconds.
All Issues ~ Search JIRA for related Bugs

Examples

Drop this script into a child prim to rotate it in 1 degree increments on each touch.

rotation rot_xyzs;
 
default
{
    state_entry()
    {
        vector xyz_angles = <0,1.0,0>; // This defines a 1 degree change on the Y axis
        vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to radians
        rot_xyzs = llEuler2Rot(angles_in_radians); // Convert to a rotation
    }
 
    touch_start(integer s)
    {
        llSetLocalRot(llGetLocalRot()*rot_xyzs); // Apply the increment rotation to the prim's current rotation ...
 
    }
}

Useful Snippets

//-- this is an equivalent call from any prim in the same link set
llSetLinkPrimitiveParamsFast( target_prim, [PRIM_ROT_LOCAL, rot] );
//-- where "target_prim" is the link number of the prim you want to set the local rotation of

Deep Notes

Search JIRA for related Issues

Signature

function void llSetLocalRot( rotation rot );

Haiku

Carousel horses
Race, ever facing forward.
Turn without turning.