Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Obtaining a final transformed vertex

mwronskimwronski Member Posts: 62
I need to know how to get the final vertex coords (in relation to the origin) after transformations of another vertex.

eg.

glLoadIdentity();
glTranslatef(0,0-10); // or any other numbers
glRotatef(45,0,1,0); // ...
glBegin(GL_POINTS);
glVertex3f(5,5,0);
glEnd();

glLoadIdentity();
//Now I need to get a single glVertex command that will do the same as the above...

glBegin(GL_POINTS);
glVertex3f(?,?,?);
glEnd();


For example, with only:
glTranslatef(0,0,-10);
glBegin(GL_POINTS);
glVertex3f(5,5,0);
glEnd();

what I am trying to find is the final vertex from the above, which is easy in this case:
glLoadIdentity();
glVertex3f(5,5,-10);
but add rotations and it becomes a bit harder...


I think you must get the current matrix (modelview) and somehow apply it to the vertex you currently have. Help?

Comments

  • ZaffireZaffire Member Posts: 22
    : I need to know how to get the final vertex coords (in relation to the origin) after transformations of another vertex.
    :
    : eg.
    :
    : glLoadIdentity();
    : glTranslatef(0,0-10); // or any other numbers
    : glRotatef(45,0,1,0); // ...
    : glBegin(GL_POINTS);
    : glVertex3f(5,5,0);
    : glEnd();
    :
    : glLoadIdentity();
    : //Now I need to get a single glVertex command that will do the same as the above...
    :
    : glBegin(GL_POINTS);
    : glVertex3f(?,?,?);
    : glEnd();
    :
    :
    : For example, with only:
    : glTranslatef(0,0,-10);
    : glBegin(GL_POINTS);
    : glVertex3f(5,5,0);
    : glEnd();
    :
    : what I am trying to find is the final vertex from the above, which is easy in this case:
    : glLoadIdentity();
    : glVertex3f(5,5,-10);
    : but add rotations and it becomes a bit harder...
    :
    :
    : I think you must get the current matrix (modelview) and somehow apply it to the vertex you currently have. Help?
    :

    I'm curious what you're trying to do with this...are you worried about getting back to where you were after performing some transformation? are you familiar with the glPushMatrix()/glPopMatrix() functions? these will let you push the current modelview matrix onto a stack, do your transformations, and then restore the modelview by popping the stored matrix off of the stack... in order to do what you're proposing, you're going to need to set up your own transformation matrices (translation, rotation, etc.) and multiply your vectors manually. it can be done, but it's tedious. that's why I ask why it's necessary, because there are circumstances which need it, but most don't. hope I've been helpful...


    Zaffire

Sign In or Register to comment.