camera position

Hi :-),
I have an OpenGL app (SGI) that allows for creating GL scenes but has full control over the camera movement.
I would appreciate any suggestions on the ways in which someone could calculate the current camera properties (for its frame) by making OpenGL only queries (glGet…, etc.). Something like the inverse of the gluLookAt function.
My objective is to store these properties (camera position, target position, up normal) to a file in order to play back the animation to a ‘pure’ OpenGL app on a PC.

Best Regards,
Stratos

er, why make life difficult for you? why not just get the state used to set the opengl state, instead?

the program you have must set the camera transforms somehow, right? What’s the bet its something like

gluLookAt(here[0], here[1], here[2], look[0], look[1], look[2], up[0], up[1], up[2]);

or something. Why not just save THOSE variables, rather than trying to get the modelview matrix from opengl and trying to solve the variables from that. (which, incidentially, would be freakily tricky).

alternatively — if that’s like too much hard work — you could just save the modelview matricies to a file.

I vote for the first suggestion, tho’

cheers,
John

Thanks a lot for your reply,

I would certainly agree that saving the gluLookAt parameters directly would be the easiest solution but unfortunately It does not seem globaly available anywhere in the project (somewhere in a precompiled library). The GL camera is driven from a motion tracker, filtered and processed for stereoscopic viewing somewhere in a third party library that I cannot access (as far as I have figured out until now 8-| )

However, I think that your second suggestion should work fine; I was so much blinded by my intention to use gluLookAt at the ‘play back’ up that forgot what it is doing …

Thanks
Stratos

If you get the modelview matrix, you can easily derive your camera position and orientation from it. The modelview matrix transforms your 3D models from object space to camera space, so you can think of it as a coordinate system for the camera.

Conveniently, the axes of this coordinate system can be read directly from the matrix. The first column is the X axis, the second is the Y axis, the third is the Z axis, and the fourth is the origin. You could take Y, Z and the origin and feed them back into gluLookAt() to get the same matrix back.

– Tom