PDA

View Full Version : Coordinate Calculation



12-04-2001, 10:23 AM
'Sup,
While programming in OpenGL, I've come across the problem of actually *locating* specific coordinates after translations have been done.
Is there any easy way to access these vertex coordinates after all transformations are processed? i.e. my alternative is to multiply all the transformation matrices and the vertex, but i'd like to know if there's any faster and/or easier way to access these coordinates.
Thanks,
-Brian

pythagoras
12-05-2001, 08:19 AM
If you start transforming your model from the world origin, when it is fully transfomed you can call:
float transformMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, &transformMatrix);
The matrix (transformMatrix[16]) now holds the transformation that took the model from the world origin to its current position. By multiplying this matrix times any vertex in your model, you transform the vertex into world coordinates.

HTH, G.