camera position from modelview matrix

hello, how can I get the
camera position and viewing direction
from the modelview matrix?


You can’t really do it because Modelview matrix is “model” and “view” matrices. So it is modeling transformations at viewing transformations at the same time.

You are only able to get this information right after camera transformation (so right before modeling transformations). Or if you know what is the modeling transformation, apply the inverse matrix but that’s really not efficient. You better manage your own matrices and you will get easily what you need.

Ok, so i better build my own camera.
In what space do I operate then ?
I mean if I have my own matrices and vectors
it should be object space until I call
gluLookat and set the values from the
camera class.


The camera transformation is applied after modeling transformation which place each scene object in the world space.
So camera matrix transforms coordinates from world space to eye space.