Phoenix

10-19-2003, 08:36 AM

I use gluLookAt()...How can I extract the x,y,z coordinates (the first 3 parameters of gluLookAt) from the MODELVIEW matrix??

View Full Version : eye coordinates from modelview matrix

Phoenix

10-19-2003, 08:36 AM

I use gluLookAt()...How can I extract the x,y,z coordinates (the first 3 parameters of gluLookAt) from the MODELVIEW matrix??

CatAtWork

10-19-2003, 10:06 AM

http://www.lighthouse3d.com/opengl/billboarding/index.php3?billCheat1

Phoenix

10-20-2003, 04:50 AM

Ok! I found it by myself looking at the gluLookAt() code!

that article was a bit different from what I needed http://www.opengl.org/discussion_boards/ubb/wink.gif ... anyway the 4th column of the modelview matrix does not contain the coordinate of the observer, infact if you use gluLookAt() the matrix you'll have is the result of:

(x0 x1 x2 0) (1 0 0 ex)

(y0 y1 y2 0) (0 1 0 ey)

(z0 z1 z2 0) X (0 0 1 ez)

(0 0 0 1) (0 0 0 1 )

where ex,ey,ez are coordinates of the eye.

so the element of the 4th column will be:

A = x0*ex+x1*ey+x2*ez

B = y0*yx+y1*ey+y2*ez

C = z0*ex+z1*ey+z2*ez

D = 1

to re-obtain ex,ey,ez you have just to solve this equation-system: you can use the Kramer's rule remembering that the following matrix should be orthonormal (=> DET=1)

(x0 x1 x2)

det (y0 y1 y2) = 1

(z0 z1 z2)

that article was a bit different from what I needed http://www.opengl.org/discussion_boards/ubb/wink.gif ... anyway the 4th column of the modelview matrix does not contain the coordinate of the observer, infact if you use gluLookAt() the matrix you'll have is the result of:

(x0 x1 x2 0) (1 0 0 ex)

(y0 y1 y2 0) (0 1 0 ey)

(z0 z1 z2 0) X (0 0 1 ez)

(0 0 0 1) (0 0 0 1 )

where ex,ey,ez are coordinates of the eye.

so the element of the 4th column will be:

A = x0*ex+x1*ey+x2*ez

B = y0*yx+y1*ey+y2*ez

C = z0*ex+z1*ey+z2*ez

D = 1

to re-obtain ex,ey,ez you have just to solve this equation-system: you can use the Kramer's rule remembering that the following matrix should be orthonormal (=> DET=1)

(x0 x1 x2)

det (y0 y1 y2) = 1

(z0 z1 z2)

Phoenix

10-20-2003, 04:52 AM

sorry for writing bad all the matrices http://www.opengl.org/discussion_boards/ubb/frown.gif

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.