PDA

View Full Version : Determine Coordinations ...



abominable
05-11-2010, 07:40 AM
I create a cube (100x100x100) inside a world(1000x900x900). And using glTranslatef() transfer the cube around the world. Apparently there are occasions were my cube is transfered outside my world. Is there some way to determine my cube's coordinations after or before applying the glTranslatef().

Thank you very much.

Dark Photon
05-11-2010, 01:06 PM
I create a cube (100x100x100) inside a world(1000x900x900). And using glTranslatef() transfer the cube around the world. Apparently there are occasions were my cube is transfered outside my world. Is there some way to determine my cube's coordinations after or before applying the glTranslatef().
Typically your glTranslate is used to append a transform to the MODELVIEW transform.

You can grab the current MODELVIEW and do some transforms with it on the CPU to see where object space points end up in eye space.

What are you trying to accomplish? Or are you puzzled about how the viewing transformations work? The OpenGL Programming Guide has a good description of all this if you're interested.

abominable
05-15-2010, 07:12 PM
Well I am currently reading the red book and try a few examples of my own. What do you mean by "grab the current MODELVIEW" ?

Thanx for your reply.

Rosario Leonardi
05-16-2010, 04:09 AM
You usually apply a transformation to your object before you draw them. There is three way to apply transormation:
use old deprecated openGL function like glTranslate, glRotate, glScale.. etc.. Use your math library to compute the transformation matrix and then use glLoadMatrix Apply the transformation matrix as an uniform in your shader
In the last two points you already know the modelview matrix.

In case 1 openGL compute the matrix for you (taking care of multiple transformation, hierarchy, and camera transformation). To get the current modelview matrix you have to call
glGetFloatv(GL_MODELVIEW_MATRIX)
obviously I don't have/want to repeat again that using glGet slow down the whole program. So if performance is critical use point 2 or 3

abominable
05-16-2010, 08:22 AM
Wow.. Thanx for the info. I will check them out.