Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Get cube points after transformations

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    7

    Get cube points after transformations

    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?

    Thanks in advance

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Why do you need the translated vertices?

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    7
    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.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    185
    Quote Originally Posted by Barbarosa View Post
    ... 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.
    Code :
    void Retrieve_Transformed_Vector (void)
    {
        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity ();
     
        // 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
    }

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    7
    That's exactly what i was looking for. Thank you very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •