I have defined a matrix that contains the position and orientation of the camera similar to the GL_MODELVIEW matrix:
(m3 = 0; m7 = 0; m11 = 0; m15 = 1)
I'm trying to load this data into the ModelViewMatrix. I'm thinking in this two possibilites:
- Using the function glLoadTransposeMatrixf():
If I use this solution I'm obtaining the correct position and orientation. The problem is that I need to use the second solution because I'm modifying the Left/Up/Forward/Translation vectors on my code to modify the view.
Using the function gluLookAt():
gluLookAt(Translation->X,
Translation->Y,
Translation->Z,
Translation->X-Forward->X,
Translation->Y-Forward->Y,
Translation->Z-Forward->Z,
Up->X,
Up->Y,
Up->Z);
My problem is that the GL_MODELVIEW matrix that I'm obtaining with that is different from the other case. Specifically, the Translation vector is wrong, but the Left/Up/Forward vectors are correct.
I'm really confused with that. Can someone explain if there are differences between this two options and what I'm doing wrong, please?
Obtained results:
I'm using a matrix M like this:
M = (Lx Upx Fwx tx)
(Ly Upy Fwy ty)
(LZ Upz Fwz tz)
(0 0 0 1 )
With the first method i'm obtaining the correct GL_MODELVIEW matrix:
N = (Lx Upx Fwx tx)
(Ly Upy Fwy ty)
(Lz Upz Fwz tz)
(0 0 0 1 )
but with the second method i'm obtaining the next GL_MODELVIEW matrix:
N = (Lx Upx Fwx tx')
(Ly Upy Fwy ty')
(Lz Upz Fwz tz')
(0 0 0 1 )
Note that tx'!=tx, ty'!=ty, tz'!=tz. This is very confusing...