Difference between revisions of "LlSetRot"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{Issues/SVC-93}}{{LSL_Function|func_id=61|func_sleep=0.2|func_energy=10.0|func=llSetRot
{{LSL_Function
|inject-2={{Issues/SVC-93}}
|func_id=61|func_sleep=0.2|func_energy=10.0
|func=llSetRot
|p1_type=rotation|p1_name=rot
|p1_type=rotation|p1_name=rot
|func_desc=Sets the rotation of the prim to '''rot'''.
|func_desc=Sets the rotation of the prim to {{LSLP|rot}}.
|return_text
|return_text
|spec=This function is available for nonphysical root prims and all child prims. It has no effect on the root prim if the object is physical.
|spec=This function is available for nonphysical root prims and all child prims. It has no effect on the root prim if the object is physical.

Revision as of 12:20, 10 June 2012

Summary

Function: llSetRot( rotation rot );
0.2 Forced Delay
10.0 Energy

Sets the rotation of the prim to rot.

• rotation rot

Specification

This function is available for nonphysical root prims and all child prims. It has no effect on the root prim if the object is physical.

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 rotation.
    • If you are trying to set the rotation of a child prim relative to the root prim then divide the 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).
    • Alternatively see the Useful Snippets for generalized workarounds that work with llSetPrimitiveParams, llSetLinkPrimitiveParams, and llSetLinkPrimitiveParamsFast
  • 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.

Examples

Drop this script in a prim to have it rotate in 1 degree increments <lsl> rotation rot_xyzq;

default {

   state_entry()
   {
       vector xyz_angles = <0,1.0,0>; // This is to define a 1 degree 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...
   }

}

</lsl>

Useful Snippets

<lsl>//-- These correctly sets a global rotation for the root prim in all scenarios llSetLocalRot( rot ) llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot] )

//-- These correctly sets a global rotation for a child prim in all scenarios llSetLocalRot( rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 ) ) llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 )] )</lsl>

Deep Notes

Signature

function void llSetRot( rotation rot );