(x,y) screen (x,y,z) world coordinates?
I'm coding up a simple mesh editor as a demo app for a mesh deformation algorithm I'm implementing... My program currently draws a mesh as wireframe with spheres at every vertex. I want the user to be able to select individual vertices of an arbitrary mesh and move them around with the mouse.
What is the best practice for this? The Red Book and NeHe have sections on "picking" and selection modes... It seems like these /should/ work...
I just want something that will be fairly easy to code up and will work reasonably well. Is picking the best way of providing a mechanism for the user to edit a mesh? If not, what are some other ways of converting from (x,y) screen coordinates to (x,y,z) world coordinates?
Thanks!
-Pete
Or look into gluUnProject:
Get MouseZ by glReadPixels().
glGetIntegerv(GL_VIEWPORT, viewport); glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);gluUnProject (MouseX,MouseY,MouseZ, mvmatrix, projmatrix, viewport, &WX,&WY,&WZ);
Get MouseZ by glReadPixels().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement