Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
|
01-24-2010 16:09
My friend recently asked me to make him a script for his projector that he wants to use in his club. This project projects colored lasers, because he wants to make some "raving night club." I want to make it so the project will rotate up and down at like a 45 degree angle. I was wondering how I would go about doing this. I have a swing script that I got out of a freebie swing. however the swing is kind of choppy when it moves back and forth because it is trying to do a series of calculations and such. I tried to do something more simple like "rotation rot_xyzq; default { state_entry() { vector xyz_angles = <0,1.0,0>; // This is to define a 1 degree change vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation } touch_start(integer s) { llSetLocalRot(llGetRot()*rot_xyzq); //Do the Rotation... } }" which I got off the wiki. This rotates nice and cleanly, but at the same time, it rotates so fast, I don't really want to use it. Is there any way I can get a nice clean 45 degree rotate up and down? I'm sorry if it is really obviously. If there is one function in LSL that i dislike more than any other, it is rotation... Thank you.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-24-2010 16:41
you can use target omega to go slower but still smoothly, but you'll need a pause at each end of the rotation to forcibly set the actual rotation (target omega is viewer side only in non physics objects) so that it doens't end up looking noticeably different or off for viewer that show up WHILE it is running. (it may still look initially off, but will self correct with this method)
float vFltDeg = 45; rotation vRotAxs = llEuler2Rot( <0.0, vFltDeg, 0.0> * DEG_TO_RAD ); // float vFltTim = 1.0; //-- seconds to complete 45deg of motion
llSetTimerEvent( vFltTm ); llTargetOmega( <0.0, 1.0, 0.0>, vFltDeg *vFltTim, 1.0 );
timer(){ llTargetOmega( ZERO_VECTOR, 0.0, 0.0 ); llSetRot( (vRot45y = ZERO_ROTATION / vRot45y) * llGetRot() ); llTargetOmega( <0.0, 1.0, 0.0>, (vFltDeg = -vFltDeg) * vFltTim, 1.0 ); }
or something to that effect.
_____________________
| | . "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... | - 
|
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
|
01-24-2010 17:01
I hope I'm not being really dumb here or anything, but can you put it all together for me in a whole basic script, because I'm trying to place what you gave me into my script and I keep getting syntax errors and everything now, because I'm not too bright with this... : / Sorry.
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-24-2010 18:40
A nightclub in SL! There's a novel idea!
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
|
01-24-2010 18:58
I know right.... I just do it to get scripting experience... what ever he does is his business : /
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-25-2010 11:39
float vFltDeg = 45; rotation vRotAxs; // float vFltTim = 1.0; //-- seconds to complete 45deg of motion
default{ state_entry(){ vRotAxs = llEuler2Rot( <0.0, vFltDeg, 0.0> * DEG_TO_RAD ); // llSetTimerEvent( vFltTm ); llTargetOmega( <0.0, 1.0, 0.0>, vFltDeg *vFltTim, 1.0 ); }
timer(){ llTargetOmega( ZERO_VECTOR, 0.0, 0.0 ); llSetRot( (vRot45y = ZERO_ROTATION / vRot45y) * llGetRot() ); llTargetOmega( <0.0, 1.0, 0.0>, (vFltDeg = -vFltDeg) * vFltTim, 1.0 ); } }
...I think, I can't test right now... dealing with local problems.
_____________________
| | . "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... | - 
|