Difference between revisions of "LlGetRot"

From Second Life Wiki
Jump to navigation Jump to search
m (Fix for alphabetical order in Functions list)
m (Added example=, also= (various))
Line 10: Line 10:
|spec
|spec
|caveats
|caveats
|examples
|examples=
<pre> //-- rotates an object to face the nearest cardinal direction (N,E,S,W)
//-- assumes build is aligned to root object facing
 
default{
  state_entry()
  {
    llSay( 0, "Rotate me in edit, then touch to make me face the nearest compass point" );
  }
 
  touch_start( integer vIntTouches )
  {
    //-- convert our rotation to x/y/z degrees
    vector vVecBase = llRot2Euler( llGetRot() ) * RAD_TO_DEG;
    //-- round the z-axis to the nearest 90deg
    float vFltCorrected = (float)(llRound(vVecBase.z / 90) * 90);
    llSetRot( llEuler2Rot( <.0, .0, vFltCorrected * DEG_TO_RAD> ) );
  }
}</pre>[[User:Void Singer|Void Singer]] 20:10, 6 November 2007 (PST)
|helpers
|helpers
|also_header
|also_header
Line 16: Line 34:
{{LSL DefineRow||[[llGetLocalRot]]|}}
{{LSL DefineRow||[[llGetLocalRot]]|}}
{{LSL DefineRow||[[llGetRootRotation]]|}}
{{LSL DefineRow||[[llGetRootRotation]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetRot]]|}}
{{LSL DefineRow||[[llSetRot]]|}}
{{LSL DefineRow||[[llSetLocalRot]]|}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|}}
|also_tests
|also_tests
|also_events
|also_events

Revision as of 20:10, 6 November 2007

Summary

Function: rotation llGetRot( );
0.0 Forced Delay
10.0 Energy

Returns a rotation that is the prim's rotation relative to the region plane.

Examples

 //-- rotates an object to face the nearest cardinal direction (N,E,S,W)
 //-- assumes build is aligned to root object facing

default{
  state_entry()
  {
    llSay( 0, "Rotate me in edit, then touch to make me face the nearest compass point" );
  }

  touch_start( integer vIntTouches )
  {
     //-- convert our rotation to x/y/z degrees
    vector vVecBase = llRot2Euler( llGetRot() ) * RAD_TO_DEG;
     //-- round the z-axis to the nearest 90deg
    float vFltCorrected = (float)(llRound(vVecBase.z / 90) * 90);
    llSetRot( llEuler2Rot( <.0, .0, vFltCorrected * DEG_TO_RAD> ) );
  }
}
Void Singer 20:10, 6 November 2007 (PST)

Deep Notes

Signature

function rotation llGetRot();