Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float phase = 3.0;
- float sine_easeInOut(float time, float begin, float cend, float duration)
- {
- return -cend/2 * (llCos(PI * time / duration) - 1) + begin;
- }
- vector position;
- vector axis;
- rotation startRot;
- // Returns a list with new rotation and new position.
- rotate_around_axis(rotation rotate, vector axis, rotation startRot, vector startPos, integer link)
- {
- //rotate = llRotBetween(llRot2Axis(startRot), llRot2Axis(rotate));
- vector current_offset = startPos - axis;
- vector new_offset = current_offset * rotate;
- vector new_position = axis + new_offset;
- rotation new_rot = startRot * rotate;
- llSetLinkPrimitiveParamsFast(link, [PRIM_POS_LOCAL, new_position, PRIM_ROT_LOCAL, new_rot]);
- }
- default
- {
- state_entry()
- {
- position = llGetPos();
- axis = <position.x - 5, position.y, position.z>;
- startRot = llGetRot();
- llSetTimerEvent(0.5);
- llResetTime();
- }
- timer()
- {
- float elapsed_time = llGetTime();
- float rotation_degrees = elapsed_time * 4;
- integer step = llFloor(elapsed_time / phase);
- float begin = 0;
- float end = 1;
- elapsed_time = elapsed_time - (step * phase);
- float height = sine_easeInOut(elapsed_time, begin, end, phase);
- if (step % 2 == 0)
- {
- height = 1 - height;
- } else {
- begin = 1;
- end = 0;
- }
- vector new_position = <position.x, position.y, position.z + height>;
- if (rotation_degrees > 360)
- {
- do {
- rotation_degrees -= 360;
- } while (rotation_degrees > 360);
- }
- vector rotation_euler = <0, 0, rotation_degrees> * DEG_TO_RAD;
- rotation mRotation = llEuler2Rot(rotation_euler);
- rotate_around_axis(mRotation, axis, startRot, new_position, LINK_THIS);
- //llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, new_position]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement