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


How can I get the values of transformed vertices?

Recommended Posts

greger    122
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
/*Vince*/    122
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
Eber Kain    130
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