rotation question
|
|
Asjbak Vandeverre
Registered User
Join date: 25 Dec 2006
Posts: 14
|
11-14-2007 13:38
Hi all, I use this script: integer seconds=1; default { on_rez(integer params){llResetScript();} state_entry() { llSetTimerEvent(seconds); } timer(){ llSleep(0); llSetRot(llEuler2Rot(<0, -1, 0 * 0>  * llGetRot()); llSleep(0); llSetRot(llEuler2Rot(<0, 1, 0 * 0>  * llGetRot()); llSleep(0); llSetRot(llEuler2Rot(<0, 1, 0 * 0>  * llGetRot()); llSleep(0); llSetRot(llEuler2Rot(<0, -1, 0 * 0>  * llGetRot()); llSleep(0); } } to rotate a prim back and forth. As I can see (i'm not that good in scripting) it rotates not in degrees but it rotates 1 side, pause, other side, pauze. What's the easiest way to rotatate a prim (for example) from the 0-point 10 degrees left and 10 degrees right and so on? thanx, asj
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-14-2007 16:28
The quick and dirty method I would use: First, make a simple script with llOwnerSay((string)llGetRot()). Set the object to the three rotations (10° left, 0°, 10° right)... and have it chat the rotation for each. In a timer event, I'd have the script llSetRot() to whichever is next in a sequence list. From: someone list ROTS = [<left_rot>, <center_rot>, <right_rot>, <center_rot>]; float INTERVAL = 1.0;
integer counter;
default { state_entry() { llSetTimerEvent(INTERVAL); } timer() { llSetRot(llList2Rot(ROTS, counter++)); if (counter > 3) counter = 0; } }
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
11-14-2007 18:59
Dote's advice is good.
Some other comments...
llSleep(0) sleeps for 0 seconds. not sure why you would do that.
0*0 is always 0. Not sure why you would do that.
You can convert degrees to radians using DEG_TO_RAD. So, 10 degrees around vertical looks like
<0, 0, 10*DEG_TO_RAD>
In your example, you are rotating 1 radian, which is about 35 degrees.
Convert that to a rotation using llEuler2Rot( <0, 0, 10>*DEG_TO_RAD )
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-14-2007 22:46
instead of doing all that math every time you switch directions why not try this... float vgFltSeconds = 1.0; vector vgVecAngle = <.0, 1.0, .0>; rotation vgRotAngle; default{ state_entry(){ vgRotAngle = llEuler2Rot( vgVecAngle * DEG_TO_RAD ); //-- save our angle as a rotation llSetTimerEvent( vgFltSeconds ); } timer(){ vgRotAngle.s *= -1; //-- this reverses the angle direction each time llSetRot( vgRotAngle * llGetRot() ); } }
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Asjbak Vandeverre
Registered User
Join date: 25 Dec 2006
Posts: 14
|
11-15-2007 06:22
hi all, Thanx for your answers. DoteDote, When I full in the rotations at ROTS it says there's an error in the following rule: llSetRot(llList2Rot(ROTS, counter++); Void singer, Your script is working fine. I'm going to try now to make it for example > -10 degrees, 0 , +10 degrees and when it stops i try to get it back to 0 degrees (even if i rotate the texture) thanx for your replies!! 
|
|
Asjbak Vandeverre
Registered User
Join date: 25 Dec 2006
Posts: 14
|
11-15-2007 06:30
O no  I was to early, This script is rotating the prim just to 1 side! What I want is to center the prim and it has to go 10 degrees to the left, back to center, 10 degrees to the right. So i can use the center for middlealligment
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-15-2007 09:22
not a problem, you can handle it by dividing your initial vector in half. so if the angle between left and right is 10deg, you calculate your rotation as something like vector vVecAngle = <.0, 20.0, .0>; //-- angle between left and right rotation left2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / 2 ); rotation right2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / -2 ); if you need to go from left to right w/o the middle, use the original, if you need to go from one side to center, use the above
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Asjbak Vandeverre
Registered User
Join date: 25 Dec 2006
Posts: 14
|
11-15-2007 13:25
Hi Void, I tried this now: float vgFltSeconds = 3; vector vVecAngle = <.0, 90.0, .0>; //-- angle between left and right rotation left2center; rotation right2center; default{ state_entry(){ left2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / 2 ); right2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / -2 ); llSetTimerEvent( vgFltSeconds ); } timer(){ llSetRot( left2center * llGetRot() ); llSay(0, "left"  ; llSetRot( right2center * llGetRot() ); llSay(0, "right"  ; } } But it's still rotating 1 way. When I place a prim it should do this: \ | / (where | is my startposition) now it's doing |\\| \\ (hope you understand lol)
|
|
Asjbak Vandeverre
Registered User
Join date: 25 Dec 2006
Posts: 14
|
11-15-2007 13:31
got it  don't know if it's the best way to do but this is how i've got it working: float vgFltSeconds = 3; vector vVecAngle = <.0, 90.0, .0>; //-- angle between left and right rotation left2center; rotation right2center; default{ state_entry(){ left2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / 2 ); right2center = llEuler2Rot( vVecAngle * DEG_TO_RAD / -2 ); llSetTimerEvent( vgFltSeconds ); } timer(){ //vgRotAngle.s *= -1; //-- this reverses the angle direction each time //llSetRot( vgRotAngle * llGetRot() ); llSetRot( left2center * llGetRot() ); llSetRot( right2center * llGetRot() ); llSetRot( right2center * llGetRot() ); llSetRot( left2center * llGetRot() ); } }
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
11-15-2007 15:50
From: Asjbak Vandeverre DoteDote, When I full in the rotations at ROTS it says there's an error in the following rule: llSetRot(llList2Rot(ROTS, counter++); It was missing a ')'. I've corrected it to: llSetRot(llList2Rot(ROTS, counter++));
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-15-2007 20:41
From: Asjbak Vandeverre got it don't know if it's the best way to do but this is how i've got it working: assuming you wanted it to start center look right first, the center then left, then center... yes if you wanted right, then left, then back to center, replace the middle 2 with your original 20deg rotation rotation FullRot = llEuler2Rot ( <.0, -90.0, .0> * DEG_TO_RAD ) llSetRot( left2center * llGetRot() ); llSetRot( FullRot * llGetRot() ); llSetRot( left2center * llGetRot() ); then discard the extra right2center variable
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|