how can I know x, y, z after applying transformations?

Started by mireazma, May 18, 2014, 09:11:35

Previous topic - Next topic

mireazma

At first I took it for granted but it turned out I don't have access to x, y and z directly for a model, after I draw it at some coordinates resulted from a series of rotatef()/translatef() transformations. I'm not sure even now I can't.
Question: what's the way to get x, y, z?
The only way I can think of to do it is to store the final matrix and retrieve it next frame and work up on it but it is both resource consuming and it looks sooo smelly.

quew8

There is no way to get the result of applying transforms within OpenGL. If hardware was required to support that, even if you didn't use it, things would be slowed up no end. So yes you are right. You need to have a copy of the transformation matrices in your program and transform the vertices yourself.

For me: I calculate the model and projection-viewing matrices completely on the CPU. I combine them at the GPU level for the actual rendering since I only need the result of the model transform. My solution was to store the transformed vertices (only recalculating them when the model matrix changes and they are requested) which obviously saves on frame rate but consumes more memory. In short, whatever you do, it's going to impact performance