views:

375

answers:

2

Sorry in advance if this is a really basic Matrix/OpenGl question. I have a situation where I have a 4x4 matrix that I would like to translate to, but don't want to use glMultMatrixf. I would rather use a gluLookAt method I've been using for most other translations. Is getting the values needed from the 4x4 matrix as simple as just pulling out the proper column values? If so which columns map to which parameters?

The signature of gluLookAt:

void gluLookAt( GLdouble eyeX,
            GLdouble eyeY,
            GLdouble eyeZ,
            GLdouble centerX,
            GLdouble centerY,
            GLdouble centerZ,
            GLdouble upX,
            GLdouble upY,
            GLdouble upZ )

http://pyopengl.sourceforge.net/documentation/ref/glu/lookat.html http://www.opengl.org/wiki/GluLookAt_code

+1  A: 

The parameters don't exist in the matrix, per se. The matrix is calculated from them. It's produced by multiplying the three vertexes (eye, center, and "up") into the current view matrix.

The OpenGL Red Book (which you really should get, if you don't have it already) explains it in more detail.

greyfade
+1  A: 

check out the DirectX versions:

http://msdn.microsoft.com/en-gb/library/ee417299(VS.85).aspx

http://msdn.microsoft.com/en-gb/library/ee417302(VS.85).aspx

those explain how the look ats are made.

from that you should be able to reverse the process, or at least determine if it's possible.

What are you trying to do exactly? why do you need to be able to do this?

the question gives the impression that you have a lookAt matrix, but rather than just directly applying that matrix, you want to pull out the parameters just so you can pass them to gluLookAt?

I'm just interested to know why exactly you want to pull the parameters out of a lookAt matrix?

matt
In this situation right now I am just applying the matrix, but the way I'm handling collision detection would make it easier if I just had coordinates.
sadboy