Jump to content

Rotations are making me DIZZY!!


You are about to reply to a thread that has been inactive for 2565 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have this box that my avie sits on.  I'm looking for a series of LSL script commands that will, in essence, do this...

 

1) Turn the box, with my avie on it, which is presently  facing north, 90 degrees to the right so I'm facing east

2) Turn the box, with my avie on it, 90 degrees to the right again, so I'm now facing south

3) Turn the box, with my avie on it, 90 degree to the right, once more, so I'm now facing west

4) Turn the box, with my avie on it, 90 degrees to the left, so I'm now facing south

5) Turn the box, with my avie on it, 90 degrees to the left again, so I'm now facing east

6) Turn the box, with my avie on it, 90 degrees to the right, so I'm facing south again

7) Turn the box, with my avie on it, 90 degrees further to the right, so I'm facing west

8) Turn the box, with my avie on it, 90 degrees to the right, once more, so I'm now facing north, the direction that I started

 

I'm getting confused with global vs. local rotations, as well as the order of the operands, and also whether I need to multiply or divide.  Any help you can provide with the set of necessary rotation commands to make this happen would be greatly appreciated!

 

Sincerely,

Rutherford Beresford

Link to post
Share on other sites

All of those are simple local* rotations

llSetRot (llEuler2Rot(<0.0,0.0,-PI/2>)*llGetRot());

rotates your block 90 degrees clockwise around Z

or

llSetRot (llEuler2Rot(<0.0,0.0,PI/2>)*llGetRot());

rotates it 90 degrees aniticlockwise  (just remember your right hand rule to get the direction right).

Rotations can be difficult to learn at first.  Spend time studying

http://wiki.secondlife.com/wiki/Rotation

and http://wiki.secondlife.com/wiki/User:Void_Singer/Rotations

and then doing a lot of practicing.

*EDIT:  Steph's post reminded me that I should have explained something that was in my head and was part of your question.  I wrote my response as a pair of local rotations (clockwise and anticlockwise) because they are the same thing as global rotations when the script is placed in the root prim (your cube).  In my mind, the cube is rotating around its own Z axis, so I think of this as a local rotation.  Steph is equally correct in thinking of these as rotations around the regional Z axis, so she wrote hers a global rotations.  (it's the order of the llEuler2Rot and llGetRot functions that makes the difference).  So long as you keep your frame of reference in mind as you script, you'll be OK.  

  • Like 1
Link to post
Share on other sites

rotation rot_xyzq;default{    state_entry()    {        vector xyz_angles = <0.0,0.0,-90.0>;//didnt put - to go anti        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 total_number)    {        llSetRot(llGetRot()*rot_xyzq);    }}

 EDIT: I deleted as it made it confusing

Link to post
Share on other sites

Essentially, what you're calling global rotations are rotations using the sim's frame of reference, while local rotations use the prim's frame of reference.   So you could look at it as global rotations being "turn n degrees North/South/East/West" and local ones being "turn n degrees Right/Left".

The symbols used are a bit confusing, in that the * symbol, usually used for multiplication, is here used to mean "transform by".    To use the sim's frame of reference, you transform llGetRot() by the number of degrees you want to turn (llSetRot(llGetRot()*rot).   To use the prim's frame of reference (Left/Right) you transform the number of degrees by llGetRot() (llSetRot(rot*llGetRot()).

In your example, I'm a bit confused about whether the box is always facing due North when you start or just happens to be on this occasion.   I decided you meant it always should always start facing North for the purposes of the script.   NB that when you rez a prim, it's rotated at  ZERO_ROTATION, which means facing East on the SL map.  That often causes confusion.

 

integer gIntCounter;integer gIntMax;list gLiRotations;rotation gRotLeft;rotation gRotRight;rotation gRotNorth;default{	state_entry()	{		llSitTarget(<0.0,0.0,0.5>,ZERO_ROTATION);  // facing the way the box faces		gRotRight = llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD);		gRotLeft = llEuler2Rot(<0.0,0.0, 90.0>*DEG_TO_RAD);		gRotNorth = llEuler2Rot(<0.0,0.0,90.0>*DEG_TO_RAD);		gLiRotations = [			gRotRight,			gRotRight,			gRotRight,			gRotLeft,			gRotLeft,			gRotRight,			gRotRight,			gRotRight				];		gIntMax = llGetListLength(gLiRotations);	}	changed(integer change)	{		if(change & CHANGED_LINK){			if (llAvatarOnSitTarget()){				gIntCounter = 0; // zero the counter				llSetRot(gRotNorth); // face due north			}		}	}	touch_start(integer total_number)	{		integer i = gIntCounter%gIntMax;		//  llOwnerSay((string)i);		rotation temp = llList2Rot(gLiRotations,i);//find the appropriate rotation in the list		llSetRot(temp * llGetRot()); //turn left or right, using the object's frame of reference		++gIntCounter;//advance the counter	}}

 

  • Like 1
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 2565 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...