Difference between revisions of "LlGetLocalRot"

From Second Life Wiki
Jump to navigation Jump to search
m (corrected/added also: Get*Rot(ation) GetPrimitiveParams Set*Rot Set*PrimitiveParams)
m
 
(8 intermediate revisions by 4 users not shown)
Line 3: Line 3:
|func=llGetLocalRot
|func=llGetLocalRot
|return_type=rotation
|return_type=rotation
|func_footnote
|func_footnote=If called from the root prim, it returns the objects rotation.
|func_desc
|func_desc
|return_text=[[Viewer coordinate frames#Local|local]] to the root (if the script isn't physical)
|Return_text=of the prim [[Viewer coordinate frames#Local|relative]] to the root.
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples=
|examples=
<pre> //--// v7-D Feebie Type 1 Door Script //--//
<source lang="lsl2">
//--// Works At ANY Angle             //--//
//--// Door Script - Works At ANY Angle //--//


//-- works in ANY single prim door, linked or un-linked
//-- works in ANY single prim door, linked or un-linked
//-- works in muti prim doors NOT linked to a larger structure
//-- works in muti prim doors NOT linked to a larger structure
//-- REQUIREMENTS: a cut root prim, suggest cube, pathcut start=.125, end=.625
//-- REQUIREMENTS: a cut root prim. Suggest cube, pathcut start=.125, end=.625
//-- CAVEAT: single prim doors are limited to 5m width
//-- CAVEAT: single prim doors are limited to 5m width


Line 23: Line 23:




rotation vgRotDoorSwing;
rotation gRotDoorSwing;


default
default{
{
   state_entry(){
   state_entry()
     gRotDoorSwing = llEuler2Rot( <0.0, 0.0, vgIntDoorSwing> * DEG_TO_RAD );
  {
     vgRotDoorSwing = llEuler2Rot( <.0, .0, (float)vgIntDoorSwing * DEG_TO_RAD> );
   }
   }


   touch_start( integer vIntTouches )
   touch_start( integer vIntTouched ){
  {
     llSetLocalRot( (gRotDoorSwing = ZERO_ROTATION / gRotDoorSwing) * llGetLocalRot() );
    //- small hack to reverse direction of swing on each
    //- touch & avoid lsl funkiness regarding rotation division
    vgRotDoorSwing.s *= -1;
 
     llSetLocalRot( vgRotDoorSwing * llGetLocalRot() );
   }
   }
}
}
 
</source>
//-- IF Redistributing as-is:
|helpers=
//-- Please leave script full permissions & include all comments, so others can learn</pre>[[User:Void Singer|Void Singer]] 18:49, 6 November 2007 (PST)
<source lang="lsl2"> //-- this is an equivalent call from any prim in the same link set
|helpers
llList2Rot( llGetLinkPrimitiveParams( target_prim, [PRIM_ROT_LOCAL] ), 0 )
//-- where "target_prim" is the link number of the prim you want to get the local rotation of</source>
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetRot]]|}}
{{LSL DefineRow||[[llGetRot]]|}}
{{LSL DefineRow||[[llGetRootRotation]]|}}
{{LSL DefineRow||[[llGetRootRotation]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|}}
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetRot]]|}}
{{LSL DefineRow||[[llSetRot]]|}}
{{LSL DefineRow||[[llSetLocalRot]]|}}
{{LSL DefineRow||[[llSetLocalRot]]|}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|}}
{{LSL DefineRow||[[llSetLinkPrimitiveParamsFast]]|}}
|also_events
|also_events
|also_tests
|also_tests
Line 61: Line 57:
|sort=GetLocalRot
|sort=GetLocalRot
|cat1=Movement
|cat1=Movement
|cat2
|cat2=Rotation
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 01:11, 22 January 2015

Summary

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

Returns the rotation of the prim relative to the root.

If called from the root prim, it returns the objects rotation.

Examples

 //--// Door Script - Works At ANY Angle //--//

//-- works in ANY single prim door, linked or un-linked
//-- works in muti prim doors NOT linked to a larger structure
//-- REQUIREMENTS: a cut root prim. Suggest cube, pathcut start=.125, end=.625
//-- CAVEAT: single prim doors are limited to 5m width

 //--// USERS MODIFY HERE v
integer vgIntDoorSwing = 90;
//-- use -# to reverse the direction of swing, eg. -90;


rotation gRotDoorSwing;

default{
  state_entry(){
    gRotDoorSwing = llEuler2Rot( <0.0, 0.0, vgIntDoorSwing> * DEG_TO_RAD );
  }

  touch_start( integer vIntTouched ){
    llSetLocalRot( (gRotDoorSwing = ZERO_ROTATION / gRotDoorSwing) * llGetLocalRot() );
  }
}

Useful Snippets

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

Notes

Returns the region relative rotation of the object if called from the root

Deep Notes

Signature

function rotation llGetLocalRot();