PDA

View Full Version : gluLookAt() - Matrix

axis
10-09-2001, 09:40 PM
Hi,

Suppose the current modelview matrix is identity, When gluLookAt(a,b,c,d,e,f,g,h,i) is called, what modelview matrix will be ?
How the elements of this matrix correspond to the given parameters mathematically?

Bob
10-09-2001, 11:59 PM
I dont know the exact order of the operations(you know, U cross V != V cross U). But the basic idea is to use the three vectors to create a rotatio matrix. Upvector is the last vector, and front vector is the difference between the first two vectors.

Create a right-vector with front-vector cross up-vector.
Create a new upvector with front cross right.
Normalize front, right and upvectors.
You now have the three ortonormalized vectors to put in the rotation part of the matrix.

The exact procedure can be found in the MESA source.

Of course, the matrix is also translated according to the first vector.

marcus256
10-11-2001, 03:59 AM
You can also check with the SGI OpenGL sample implementation, which has a source for GLU:
http://oss.sgi.com/projects/ogl-sample/