Rotating on a global axis whilst retaining local orientation - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Rotating on a global axis whilst retaining local orientation


Scripting Discuss scripting for SL and other platforms

Reply
 
LinkBack Thread Tools Display Modes
Old 08-23-2009, 07:01 AM   #1 (permalink)
Senior Member
 
Eata's Avatar
 
Join Date: Sep 2007
Posts: 706
My Mood:
SLShopper Ads: 1
Unhappy Rotating on a global axis whilst retaining local orientation

This is driving me crazy.

I want an object that is at arbitary X and Z axis to be able to rotate around either axis but still retain the other axis as normal.

For example, make a standard box and change it's X to 315.00, so it is at a downwards angle. Select the rotation cursor and put it on world, now rotate it with the blue rotation ring. This is exactly the kind of rotation what I want, to yaw around whilst retaining the same pitch. Same with pitching whilst retaining the same yaw. I never want there to be any roll.

The problem is that local rotation which retains the other axis does it too well, if you put it on local rot you can see the blue ring now takes you in a sort of end over end style meaning that globally we are getting roll. If you do it global then it falls over whenever I have changed both the pitch and yaw.
I tried taking the original llGetRot and then retaining the axis I wasn't changing but this breaks badly when you are at an angle that needs all three (EG 339.05, 319.20, 59.65).

Help

Here's an example which ends up with it going on it's side.

Quote:
integer rotateActive;
integer rotateStep;

default
{
state_entry()
{
llSetRot(<-0.00000, -0.92388, -0.38268, 0.00035>);
llSetTimerEvent(2);
}

timer()
{
vector eul;
rotation quat;
if (rotateStep > 6)
{
eul = <-45 * DEG_TO_RAD,0,0>;
rotateStep = 0;
}
else if (rotateStep < 3)
eul = <0,0,45 * DEG_TO_RAD>;
else if (rotateStep == 3)
eul = <45 * DEG_TO_RAD,0,0>;
else
eul = <0,0,-45 * DEG_TO_RAD>;
quat = llEuler2Rot(eul);
llSetRot(llGetRot() * quat);
rotateStep++;
}
}

Last edited by Eata; 08-23-2009 at 07:26 AM.
Eata is offline   Reply With Quote
Old 08-23-2009, 10:45 PM   #2 (permalink)
Senior Member
 
Oneironaut Escher's Avatar
 
Join Date: Jun 2007
Posts: 331
I have no idea what you're asking

But, I know a 'Gotcha' I ran into was, well - here try changing this:

llSetRot(llGetRot() * quat);

to this:

llSetRot(quat * llGetRot());

and see what happens. Those two lines will actually produce different results. Whether the different result is what you're looking for, not sure. I remember nearly losing it once I figured out I was having the issue I was because of something stupid like that.
Oneironaut Escher is offline   Reply With Quote
Old 10-10-2009, 04:24 AM   #3 (permalink)
Junior Member
 
Join Date: Oct 2009
Posts: 1
How can you expect to achieve the maintenance of a local orientation while spinning on a global axis? It's a bit like asking how can I walk a mile west and end up where I started? You can only do this under particular circumstances, and you give an example of one where you tip on the x-axis and spin on the global z axis. This works because the local x-axis remains at right angles to the global z-axis. After an arbitrary reorientation on the x-z plane it won't work.
Jonno is offline   Reply With Quote
Old 10-19-2009, 09:43 AM   #4 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 9
Quote:
Originally Posted by Oneironaut Escher View Post
llSetRot(llGetRot() * quat);
This is a "right multiplication" and will rotate the object in global coordinates. It is like changing the rotation when you have "world coordinates" chosen in the edit window.

Quote:
Originally Posted by Oneironaut Escher View Post
llSetRot(quat * llGetRot());
This is a "left multiplication" and will rotate the object in local coordinates. It is like changing the rotation when you have "local coordinates" chosen in the edit window.
Grandma Bates is offline   Reply With Quote
1 User Said Thanks:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On