PDA

View Full Version : about modeling transformation



xiaomi
05-11-2005, 05:13 PM
i want to use glRotated() to realize observing dynamically.
glRotated(Y_Angle,0.0,1.0,0.0);
glRotated(X_Angle,1.0,0.0,0.0);
Y_Angle and X_Angle Represent separately vertical and horizontal movement of the mouse。
but glRotated(X_Angle,1.0,0.0,0.0) expresses the object rotating wind X axle in the system of coordinates that after running the first code(glRotated(Y_Angle,0.0,1.0,0.0) ;) .

so,how i can make the object rotating wind X axle in the system of coordinates that begin

gamefish
05-11-2005, 06:21 PM
use glPushMatrix() to store the current state, or glLoadIdentity() to go back to initial state.

actually I think the second rotation will excutes first

xiaomi
05-11-2005, 08:10 PM
glRotated(X_Angle,1.0,0.0,0.0);
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

after running, the object can only rotate the x axis.

zero_t9
05-11-2005, 09:02 PM
whatever here
glRotated(X_Angle,1.0,0.0,0.0);
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

Equal to
glLoadIdentity() ;
glRotated(Y_Angle,0.0,1.0,0.0);

is not it?

xiaomi
05-11-2005, 09:23 PM
yes,they are equivalent.but how i can realize the function that is put forward

xiaomi
05-12-2005, 03:53 AM
??

T101
05-12-2005, 05:14 AM
Hint: if people don't seem to be able to answer your question, maybe that's because they don't understand what you're trying to do.

All transformations, including multi-axis rotations are chained. You cannot rotate something about two axes without the result of one interfering with that of the other.

That's not because "Euler angles are evil" (search the net for that phrase), but because it's just not possible.

If you want the X-rotation to modify the result of the Y-rotation, you need to specify the Y-axis rotation _below_ the X-axis rotation.
If you want the Y-rotation to modify the result of the X-rotation, it's the other way around.
If you think about it in world-objects, conceptually you need to specify them in the opposite order of the order in which they are applied to the vertices.

(By the way, if that is NOT what you want, you CAN rotate about a different axis than just the X-axis, Y-axis, or Z-axis.
That's why there are three parameters for the axis in glRotate instead of one.)