SHARE
TWEET

Untitled

a guest Aug 18th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float phase = 3.0;
  2.  
  3. float sine_easeInOut(float time, float begin, float cend, float duration)
  4. {
  5.     return -cend/2 * (llCos(PI * time / duration) - 1) + begin;
  6. }
  7.  
  8. vector position;
  9. vector axis;
  10. rotation startRot;
  11.  
  12. // Returns a list with new rotation and new position.
  13. rotate_around_axis(rotation rotate, vector axis, rotation startRot, vector startPos, integer link)
  14. {
  15.     //rotate = llRotBetween(llRot2Axis(startRot), llRot2Axis(rotate));
  16.     vector current_offset = startPos - axis;
  17.     vector new_offset = current_offset * rotate;
  18.     vector new_position = axis + new_offset;
  19.     rotation new_rot = startRot * rotate;
  20.     llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, new_position, PRIM_ROT_LOCAL, new_rot]);
  21. }
  22.  
  23.  
  24.  
  25. default
  26. {
  27.     state_entry()
  28.     {
  29.         position = llGetPos();
  30.         axis = <position.x - 5, position.y, position.z>;
  31.         startRot = llGetRot();
  32.         llSetTimerEvent(0.5);
  33.         llResetTime();
  34.     }
  35.  
  36.     timer()
  37.     {
  38.         float elapsed_time = llGetTime();
  39.         float rotation_degrees = elapsed_time * 4;
  40.         integer step = llFloor(elapsed_time / phase);
  41.         float begin = 0;
  42.         float end = 1;
  43.         elapsed_time = elapsed_time - (step * phase);
  44.         float height = sine_easeInOut(elapsed_time, begin, end, phase);
  45.         if (step % 2 == 0)
  46.         {
  47.             height = 1 - height;
  48.         } else {
  49.             begin = 1;
  50.             end = 0;
  51.         }
  52.         vector new_position = <position.x, position.y, position.z + height>;
  53.         if (rotation_degrees > 360)
  54.         {
  55.             do {
  56.                 rotation_degrees -= 360;
  57.             } while (rotation_degrees > 360);
  58.         }
  59.         vector rotation_euler = <0, 0, rotation_degrees> * DEG_TO_RAD;
  60.         rotation mRotation = llEuler2Rot(rotation_euler);
  61.         rotate_around_axis(mRotation, axis, startRot, new_position, LINK_THIS);
  62.         //llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, new_position]);
  63.  
  64.     }
  65.  
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top