Hi
How can i get the direction of the camera from the modelview matrix? Note that i’m using from the function gluLookAt()to move and rotate the camera.
-Ehsan-
In eye space it’s always (0, 0, -1, 0).
For a right-handed(!) camera system, back into model space you would need to transform that by the inverse of the modelview:
MV * v = (0, 0, -1, 0)T;
MV^-1 * MV * v = MV^-1 * (0, 0, -1, 0)T;
v = MV^-1 * (0, 0, -1, 0)T;
Only rotations are interesting, that gives MV^-1 == (MV)T and the matrix just needs to be 3x3.
v = (MV)T * (0, 0, -1)T;
The result of that is the negated first three comonents of the third row of the current modelview matrix.