ModelView Matrix

ear All:

I have a question related to ModelView Matirx Operation,
and would like to know how does OpenGL perform the operation.

Let say my current modelView Matrix is

T0 =1.000000 T1 =0.000000 T2 =0.000000 T3 =0.000000
T4 =0.000000 T5 =1.000000 T6 =0.000000 T7 =0.000000
T8 =0.000000 T9 =0.000000 T10=1.000000 T11=0.000000
T12=3.320000 T13=0.080000 T14=-60.935867 T15=1.000000

and then I specify the glScale command by glScaled(0.313486, 0.313486, 0.313486);
what will the modelview matrix look like? I use glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix);
and print out the modelView Matrix, it is shown as follows:

T0 =0.313486 T1 =0.000000 T2 =0.000000 T3 =0.000000
T4 =0.000000 T5 =0.313486 T6 =0.000000 T7 =0.000000
T8 =0.000000 T9 =0.000000 T10=0.313486 T11=0.000000
T12=3.320000 T13=0.080000 T14=-60.935867 T15=1.000000

Then if I specify glTranslated(-31.789, -22.129, 60.935867);

the modelView Matrix becomes the following:

T0 =0.313486 T1 =0.000000 T2 =0.000000 T3 =0.000000
T4 =0.000000 T5 =0.313486 T6 =0.000000 T7 =0.000000
T8 =0.000000 T9 =0.000000 T10=0.313486 T11=0.000000
T12=-6.645412 T13=-6.857136 T14=-41.833313 T15=1.000000

Why glTranslated(-31.789, -22.129, 60.935867) command
results in T12=-6.645412 T13=-6.857136 T14=-41.833313 ??

Thanks for any help.

Robert tyyu@ksts.seed.net.tw

Think about it. Your translation is being scaled by the scale you just sent. Do the math:

(-31.789 * 0.313486) + 3.32 == -6.645412.

Thanks for your hint, it helps.
Allow me to ask one more to clear my question:

When I check the MSDN regarding glScaled(x,y,z) command,
it has the following explain:
----------- Message included -----
The glScale function produces a general scaling along
the x, y, and z axes. The three arguments indicate the
desired scale factors along each of the three axes.
The resulting matrix is

|x 0 0 0|

s = |0 y 0 0|
|0 0 z 0|
|0 0 0 1|

The current matrix (see glMatrixMode) is multiplied by this scale matrix,
with the product replacing the current matrix. That is,
if M is the current matrix and S is the scale matrix, then M is replaced with M¡PS.
---------- End of included message

So my understanding is if my current M is

1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
M =0.0 0.0 1.0 0.0
3.32 0.08 -60.9 1.0

Then when I have glScaled(0.313486, 0.313486, 0.313486)
Should the final matrix be

1.0 0.0 0.0 0.0 0.313486 0 0 0
0.0 1.0 0.0 0.0 0 0.313486 0 0
M =0.0 0.0 1.0 0.0 * 0 0 0.313486 0
3.32 0.08 -60.9 1.0 0 0 0 1

How come the matrix become the following:

T0 =0.313486 T1 =0.000000 T2 =0.000000 T3 =0.000000
T4 =0.000000 T5 =0.313486 T6 =0.000000 T7 =0.000000
T8 =0.000000 T9 =0.000000 T10=0.313486 T11=0.000000
T12=3.320000 T13=0.080000 T14=-60.935867 T15=1.000000

What I mean is that when I have the opengl command listed
with the order as:

glScaled(0.313486,0.313486,0.313486);
glTranslated(-31.789, -22.129, 60.935867);

why the T12 of the final matrix is (-31.789 * 0.313486 + T12)??
What is the rule? Do I misunderstand the MSDN explaination?

Also, if I have the following opengl commands:

glRotated(30, 1.0, 0.0, 0.0);
glRotated(60, 0.0, 1.0, 0.0);
glRotated(30, 0.0, 0.0, 1.0);
glScaled(0.5,0.5,0.5);
glTranslated(10.0,10.0,10.0);

What will be the last ModelMatrix??
ie, what kind of math will be applied
to the operation??

Thanks for your patience and help.

Robert tyyu@ksts.seed.net.tw

You might want to invest in a book on linear algebra or matrix math.

What the MSDN was saying is that the two matricies are multiplied together to create a composite transformation matrix. It didn’t say anything about concatonating the matrices together (which you seemed to have expected). It’s a matrix multiply.