Advertisement

rotation problem

Started by February 22, 2003 12:55 PM
9 comments, last by nitzan 22 years ago
I have an airplane that I want to rotate. First I rotate my airplane 45 degrees along the Y-Axis. Now the issue arises when I want my airplane to pitch up. I cant seem to figure out how to make the airplane rotate around its own axis instead of the screen axis. Any ideas ? Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------
You should look up quaternions, they''ll make your life quite a bit easier.
Advertisement
I am already using quaternions.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Heh ok. Are you sure you''re using them correctly?
I remember having some trouble with the order of multiplication since quaternion multiplications are non-commutative. You could try reversing your order.
If you rotate around a pivot point, these are the steps:
1) Translate to Origo
2) Rotate
1) Translate back

But I probably misunderstood your problem.
The Model is already around the origin.

The issue here is that every time I do a rotation, I want the *model''s axis* to rotate too. So the next rotation will be around that axis instead of the screen axis.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Advertisement
It already does rotate based on the *model''s axis* but if the center of the model is not in the correct position, it will look odd when rotating.
Ok, obviously I am not explaining myself well enough,
The model is already at the origin. No translation is being done on it.

To see an example of my problem download Nehe''s lesson 7 and run it.

Push the LEFT arrow key until the object is rotated 45 degrees along the Y Axis. Then hit the right arrow key to stop it so its stationary at around 45 degrees.

http://www.geocities.com/nitzanw/images/box1.jpg

Now push the DOWN arrow key and see what happens:

http://www.geocities.com/nitzanw/images/box2.jpg

The Box is rotating along the SCREEN coordinates rather then the BOX coordinates. I want it to rotate using the BOX coordinates. Like this:

http://www.geocities.com/nitzanw/images/box3.jpg


How do I do that ?

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Can''t you use the normals from the box? If you use the right, top,and forward vectors, you got a coor.system. Then rotate with the normals as direction vectors.
If you first call glRotatef() for the y axis, then for the x-axis, it will rotate first on the y, then from the model''s new axis, it will rotate on the x. If you call x rotation first, then thats what it will do first. If you go into tut 7 and switch the order it rotates in, then it works as you wanted.

This topic is closed to new replies.

Advertisement