Advertisement

glTranslated()

Started by August 29, 2003 04:22 AM
3 comments, last by b3rs3rk 21 years, 6 months ago
how can i know the coordinates of an object after a glTranslated ? please answer me :/
so? any advices?
Advertisement
assuming u put all your tranformations in the Modelview matrix, the object coordinates are in the last column of that matrix:

GLdouble mvmatrix[16];
glGetDoublev( GL_MODELVIEW_MATRIX, mvmatrix );

This gives you:
(x,y,z) = (mvmatrix[12], mvmatrix[13], mvmatrix[14]);

But if there are no prior transformations to your glTranslated() call, then the position of the object is at the position u translated it to.

A word of advice, do your translations before your rotations.
very useful, tanks :D
but after a glRotatef ?
The object position is always in the last column of the matrix, whatever the transformations applied to it.

I''d advise you to take a look at Steve Bakers'' "Matrices can be your friends" article (http://sjbaker.org/steve/omniv/matrices_can_be_your_friends.html) for a very light view on the subject, and "The Matrix and Quaternion FAQ" (http://www.j3d.org/matrix_faq/matrfaq_latest.html) for a more in depth approach.

This topic is closed to new replies.

Advertisement