PDA

View Full Version : Modeling transformations



RasterMagic
12-03-2003, 07:49 AM
I was uner the impression that I actaully understood modeling transformations in OpenGL. I was wrong.

Let me quote Richard Wrigth, OpenGL SuperBible, Second Edition, p. 138:

"All of the various transformations change the current coordinate system with respect to eye coordinates."

I find this clear. Very clear. In essence I understand like this: I do not rotate any object but rather the coordinate system the object is defined in.

This, though, makes me unable to comprehend his figure at page 140.

The figure explains that the order of modeling transformation is important. Part 1 of the figure shows a cube first rotated around the z-axis and the translated along the x-axis. According to the figure the cube is now somewhere in the first quadrant, rotated. This I don't understand.

According to his quote all transformations are done "with respect to the eye coordinates", thus I think part 1 of the figure should be as follows:

1. First the rotation rotates, not the cube but the coordinate system, with respect to the eye corrdinate system. Hence the cube is now rotated with respect to the z-axis. This is ok, and as shown.

2. The next transformation is a translation with respect to the x-axis, and this is where I'm having problems. According to the figure this moves the cubes out of the new x-axis (the one created by the rotation descirbed in 1. above), but according to how I understand this (as from the quote in the beginning of my post), this SHOULD translate the COORDINATE SYSTEM with respect to the EYE COORDINATE SYSTEM and NOT the cube with respect to the NEWLY created coordinate system. Ergo I think the cube should be with its center at the x-axis an rotated, but it's not.

dvm
12-04-2003, 10:13 PM
The order of transformations matters because what we are dealing with is in essence matrix multiplications.Remember from algebra that AxB != BxA in matrices. So



glTranslatef();
glRotatef();

is different than:



glRotatef();
glTranslatef();

Also when you render the cube you render it according to the current coordinate system. Usually you draw the cube in the center of that system, right? So if you first rotate the system and then translate it the new center is in the 1st quadrant which is where the cube is going to be drawn. Hope these helped. It can be hard to understand transformations, I'm only just beginning to believe I have finally understood them. Try checking nate robbins' tutorials on www.xmission.com/~nate (http://www.xmission.com/~nate) and try to find a copy of the red book, either on hard print or an online version of it. I haven't read your book, but I believe it's good to have multiple sources. (Then you have to compile them in your head http://www.opengl.org/discussion_boards/ubb/wink.gif )