ModelView matrix manipulation

Hei! :cool:

Can any one trhow any example, how OpenGL manipulates with Rotation, translation, scale and ModelView matrix? I mean, describe algorithm how OpenGL Rotation, translation and scale functions act on ModelView matrix.

Thanks in advnace!
Regards !

For a bit of an explanation, have a look at appendix G of the redbook:

A simplified way of thinking is that translations, scales and rotations are performed on the vertex data in the opposite order of the order in which you specify them.
And all of these transformations are meant to transform the source vertex into observer-space.

Suppose your program does the following:

Rotate 90 degrees around the X-axis
Move by 10,20

send vertex

Basically, this means that the vertex is first moved by 10,20, then the resulting vector is rotated around the global X-axis.
Then the projection matrix is applied. (But you didn’t ask about that).

Why do they do it this way?
it allows you to set the camera position, object positions etc, and push the effective transformation onto the matrix stack.
You can then use additional translates etc to fill in the details (e.g. the fingers on an arm) and when you’re done, you can pop the matrix from the stack.
In other words, you don’t need to repeat a lot of matrix operations that have to be repeated if things are performed in the same order in which they were specified.

But it does feel somewhat unnatural.

Hei T101!

Thanks For response!
As i understand, OpenGL vertex go thru modelview, projection matrix, perspective division and viewport transformations to get the window coordinates.

I have to describe the ModelView matrix, its behaivour. Those scaling, rotation and transformation functions affect the modelview matrix. How do they affect. By multiplying, for example, rotation matrix with modelview matrix and result is new modelview matrix?

What do you think T101?
Do u have any examples of matrix manipulation?


Any one else can help…?

Originally posted by Delorean:
Any one else can help…?
Its just a try though t101 is spot on.
Actually the vertex data is multiplied with the modelview matrix.You provide the transformation in the reverse order. Whnever you give a transformation call a matrix is created (depending on what transform you have done) and post multiplied with the current mdelview matrix.
so say if i have done a translation using glTranslatef(10,20,30) then this matrix will be generated.

1 0 0 10
0 1 0 20
0 0 1 30
0 0 0  1

Now you would have seen that when you choose the current matrix using glMatrixMde you immeduately call loadidentity this creates an identity matrix and places it in the stack.
In above case (translation) before evaluating the vertices, the concatenation would take place and cause the modelview matrix to become

1 0 0 10
0 1 0 20
0 0 1 30
0 0 0  1

Suppose you give another tranformation i.e T’ aftr it then T’ members will be concatenated too. Finallt the vertex data will b multiplied with the most recent modelviewmatrix that obtained after postmultipliction of ll transformations. If this thing is causing trouble i would reccomend the red book and super bible do check them out. Thanx

Roger MMM! it’s just like i thought