PDA

View Full Version : how can I get GL to return the current transformation?



Schlogenburg
09-27-2000, 02:59 PM
say I translated a whole bunch of times and lost track of all of it, but I needed to know what I was translated to. Is there a function that will tell me what the world is translated to, ex. -10,5,15?

09-27-2000, 04:38 PM
float mat[16]
glGetFloatv(GL_MODELVIEW_MATRIX, mat)

mat now holds the current modelview matrix and mat[12] mat[13] mat[14] = translational component x,y,z

Schlogenburg
09-30-2000, 04:58 PM
No that didn't work at all. All I want to do is save the camera position in 3d space, x y z. Remember, not any rotations, just transformation. The problem is I have no idea of what the position is.


so later I want to be able to reload this transformation. and stick the camera exactly where it was.

Schlogenburg
09-30-2000, 08:01 PM
someone answer!!!

been working on this problem for 3 months!!

tdavie
10-01-2000, 02:18 AM
What he said earlier should work except for one thing, you want the projection matrix, not the modelview matrix.

Punchey
10-03-2000, 05:30 AM
You don't need to "know" the last location of your camera because I think you can simply select your projection matrix with something like glMatrixMode(GL_PROJECTION) and then "push" the matrix onto the matrix stack. Then "pop" it off the stack later when you want to reload it. I'm pretty new to GL too so someone tell me if I'm totally without a clue here.