PDA

View Full Version : Get cube points after transformations

Barbarosa
06-30-2013, 04:23 PM
Hello,

I have created a cube (with known vertices) and i rotate and traslate it. What i lack are the new positions of its vertices after the transformations. So the question is do i have to find the transformation matrix on paper in order to calculate the vertices, or there is some function to get them?

tonyo_au
06-30-2013, 11:42 PM
Why do you need the translated vertices?

Barbarosa
07-01-2013, 02:06 AM
I try to implement the separating axis theorem for some oriented bounding boxes (cubes in my case). So i need the unit vectors that represent the 3 local axis of each box. To find these unit vectors i subtract the vertices to get the vectors and then i normalize them. And that's where i stuck because i have to know the positions of the vertices after the transformations.

Carmine
07-01-2013, 10:52 AM
... i have to find the transformation matrix on paper in order to calculate the vertices, or there is some function to get them? Here's an example of how I do it using fixed pipeline OpenGL commands only.

void Retrieve_Transformed_Vector (void)
{
glMatrixMode (GL_MODELVIEW);

// same modeling transformations that are applied to cube go here.

glTranslatef (corner[0], corner[1], corner[2]);

glGetFloatv (GL_MODELVIEW_MATRIX, transmat); // read manual on transmat, should be a GLfloat transmat[16]
// transmat[12],[13],[14] are the new coordinates of corner
}

Barbarosa
07-01-2013, 05:02 PM
That's exactly what i was looking for. Thank you very much!