Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How can I get the values of transformed vertices?

This topic is 6101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! I have some vertices saved in an array and I also have a redrawfunction that uses these vertices to redraw objects. Objects are lines, polylines, polygons or circels btw. Then I do some kind of transformation like a glTranslated(), glROtated() or similar and call the redrawfunction. The object is now placed elsewhere on the screen and that is fine. My concern is how do I get the NEW values of the vertices so I can update my arraylist to these new coordinates? If I don''t update it the next call to display() will place it where it originally was. It would be no problem if I only had one object in the array cause then I could just use the matrixstack but now I have almost unlimited number of objects stored and really need those new vertices. Grateful for any help

Share this post

Link to post
Share on other sites
Not sure I understood correctly, but I think you should maintain, for each object, a local coordinate system (say, left, up, look orthonormal vectors for a right hand coord system like OpenGL) as well as a world coordinate for the position.

To move your objects : modify the position vector (adding to it a translation vector)
To rotate your objects : modify hte local vectors (multiply them with a rotation matrix, see any graphics book for this)

By multiplying the vertices of your objects with the object's world matrix (see below), you get the NEW coordinates (position+orientation) of your objects, which you can fill your array with.

Alternatively, you can draw your objects like so:
after the camera transformation has been set (gluLookAt or glMultMatrix), do :
for each object
end for

with obj->worldMat being the world matrix of your object which you can build using the 3 local axis and your object position like so
left.x up.x look.x pos.x
objMat = left.y up.y look.y pos.y
left.z up.z look.z pos.z
0 0 0 1

but be careful, you should pass a column major matrix to OpenGL, and not the standard C style row major matrix.


Edited by - /*Vince*/ on November 7, 2001 9:12:29 AM

Share this post

Link to post
Share on other sites
You should read the areticle on matrices on this page


You can use the function glGetFloatv(); to return the value of transformed coordnates.

Details can be found in the red book.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!