Advertisement
Guest User

Untitled

a guest
Sep 1st, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vector desired_axis = <148.89938, 139.48409, 0.0>;
  2.  
  3. default
  4. {
  5.     state_entry()
  6.     {
  7.         rotation vRotArc       = llEuler2Rot( <0.0, 0.0, 180.0> * DEG_TO_RAD );
  8.          //-- creates a rotation constant, 30 degrees around the X axis
  9.  
  10.          // Saya - Calculating offset based on the difference between the prims position and the desired axis
  11.         vector currentPos = llGetPos();
  12.         // I don't want to rotate around Z at all, so I remove the Z component of the prim position
  13.         currentPos = <currentPos.x, currentPos.y, 0>;
  14.  
  15.         vector   vPosOffset     = currentPos - desired_axis;
  16.  
  17.         // Produces expected results:
  18.         llSay(DEBUG_CHANNEL, (string)vPosOffset);
  19.        
  20.          //-- creates an offset one meter in the positive Y direction
  21.          
  22.         vector   vPosRotOffset  = vPosOffset * vRotArc;
  23.          //-- rotates the offset to get the motion caused by the rotation
  24.          
  25.         vector   vPosOffsetDiff = vPosOffset - vPosRotOffset;
  26.          //-- gets the local difference between the current offset and the rotated one
  27.          
  28.         vector   vPosRotDiff    = vPosOffsetDiff * llGetRot();
  29.          //-- rotates the difference in the offsets to be relative to the global rotation.
  30.          
  31.         vector   vPosNew        = llGetPos() + vPosRotDiff;
  32.          //-- finds the prims new position by adding the rotated offset difference
  33.          
  34.         rotation vRotNew        = vRotArc * llGetRot();
  35.          //-- finds rot to continue facing offset point
  36.  
  37.          llSetPrimitiveParams([PRIM_POSITION, vPosNew,PRIM_ROTATION, vRotNew]);
  38.  
  39.          llRemoveInventory(llGetScriptName());
  40.     }
  41.  
  42.     touch_start(integer total_number)
  43.     {
  44.         llSay(0, "Touched.");
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement