GL transformations question

Started by
3 comments, last by Sabonis 13 years, 7 months ago
Hello,

I am implementing my own gluLook at function with the help of:

http://pyopengl.sourceforge.net/documentation/manual/gluLookAt.3G.html

They mention "and gluLookAt is equivalent to glMultMatrixf(M); glTranslatef (-eyex, -eyey, -eyez);"

Why can't the translation values for the eye be put into the matrix m?

What is the different between combining the two and separating them into the commands glMultMatrixf and gltranslatef?

The translation for xyz in the matrix m are 0, why not just populate them?

Either way, ive tried both ways and both give me different results.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...
Advertisement
No technical reason at all; you can incorporate the translation directly into the rotation matrix if you want. However, it's easier to construct the pure rotation matrix M and perform the translation as separate steps.

Adding the translation to the rotation matrix, however, is not just about setting the some values in the matrix, because the axes of translation are affected by the rotation matrix M. That's why it's easier to perform them as separate steps, so OpenGL can just multiply the matrices instead of doing it yourself to get the correct translation.
I think where my logic is failing is here:

M=
a b c 0
d e f 0
g h i 0
0 0 0 1

T =
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1

Here is what their multiplication would mean (in my head)
MxT =
a b c x
d e f y
g h i z
0 0 0 1

BUT:
The two commands separately executed would give a result of something like:
a b c u
d e f v
g h i w
0 0 0 1

where u,v,w are completely different than xyz. I'm just confused as why.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...
It's just normal matrix multiplication. Your two matrices are correct, and the value of u, v and w are:
u = a*x + b*y + c*zv = d*x + e*y + f*zw = g*x + h*y + i*z
Thanks for your help!
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein (1879-1955) That is so very true...

This topic is closed to new replies.

Advertisement