Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RotOffset(vector offset, vector ammount)
- {
- rotation vRotArc = llEuler2Rot( ammount * DEG_TO_RAD );
- //-- creates a rotation constant, 30 degrees around the X axis
- vector vPosOffset = offset;
- //-- creates an offset one meter in the positive Y direction
- vector vPosRotOffset = vPosOffset * vRotArc;
- //-- rotates the offset to get the motion caused by the rotation
- vector vPosOffsetDiff = vPosOffset - vPosRotOffset;
- //-- gets the local difference between the current offset and the rotated one
- vector vPosRotDiff = vPosOffsetDiff * llGetLocalRot();
- //-- rotates the difference in the offsets to be relative to the global rotation.
- vector vPosNew = llGetLocalPos() + vPosRotDiff;
- //-- finds the prims new position by adding the rotated offset difference
- rotation vRotNew = vRotArc * llGetLocalRot();
- //-- finds rot to continue facing offset point
- //llSetPos(vPosNew);
- //llSetLocalRot(vRotNew);
- llSetLinkPrimitiveParamsFast( LINK_THIS, [PRIM_POSITION, vPosNew, PRIM_ROTATION, vRotNew] );
- }
- integer IS_ON = FALSE;
- set_Rot()
- {
- if (IS_ON)
- {
- RotOffset(<0,0,-(0.315/2)>,<0,-90,0>);
- }
- else
- {
- RotOffset(<0,0,-(0.315/2)>,<0,90,0>);
- }
- }
- default
- {
- state_entry()
- {
- //llSay(0, "Hello, Avatar!");
- }
- touch_start(integer total_number)
- {
- IS_ON = !IS_ON;
- set_Rot();
- //llSay(0, "Touched.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement