Difference between revisions of "User:Toady Nakamura/Touch Toggle Rotate"
Jump to navigation
Jump to search
m (added date written & tag) |
Kireji Haiku (talk | contribs) m (some readability improvements) |
||
Line 4: | Line 4: | ||
<lsl> | <lsl> | ||
integer spinning = FALSE; | integer spinning;// = FALSE; | ||
default | default | ||
{ | { | ||
touch_start(integer | touch_start(integer num_detected) | ||
{ | { | ||
if( | // toggle between TRUE (1) and FALSE (0) | ||
spinning = !spinning; | |||
llTargetOmega(<0.0, 0.0, 1.0>, -PI_BY_TWO, -0.01); | |||
if (spinning)// is on turn it off | |||
llTargetOmega(ZERO_VECTOR, (float)FALSE, (float)FALSE); | |||
else// turn it back on | |||
llTargetOmega(<0.0, 0.0, 1.0>, -PI_BY_TWO, -0.01); | |||
} | } | ||
} | } | ||
</lsl> | </lsl> | ||
Revision as of 07:14, 13 October 2012
Make a cylinder that looks like a record or a CD.
Place this script inside...
<lsl> integer spinning;// = FALSE;
default {
touch_start(integer num_detected) { // toggle between TRUE (1) and FALSE (0) spinning = !spinning;
if (spinning)// is on turn it off llTargetOmega(ZERO_VECTOR, (float)FALSE, (float)FALSE);
else// turn it back on llTargetOmega(<0.0, 0.0, 1.0>, -PI_BY_TWO, -0.01); }
} </lsl>
How llTargetOmega works...
- for the function that reads: llTargetOmega(<0.0, 1.0, 0.0>, TWO_PI, 1);
- The first parameter is axis of rotation expressed as a vector (<0,1,0>) which will rotate the prim on the Y axis
- To change the axis to x <1,0,0>... to change it to z <0,0,1> and to reverse direction <-1,0,0>, <0,-1,0>, <0,0,-1>
The second parameter is the rate of rotation in radians per second.
- PI_BY_TWO (slow counterclockwise), -PI_BY_TWO (slow clockwise)
- PI (counterclockwise) or -PI (clockwise)
- TWO_PI (counterclockwise) or -TWO_PI (clockwise)
The third parameter is the gain. (should not equal zero - subtle effect)
script written 02-22-08 inspired by Torley's record player--Toady Nakamura 11:40, 14 May 2012 (PDT)