08-09-2006, 04:09 AM
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.
08-09-2006, 05:13 AM
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.