(x,y) screen (x,y,z) world coordinates?

Started by
2 comments, last by megatron244 16 years, 10 months ago
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
Advertisement
Take a look at this
http://gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs
Author Freeworld3Dhttp://www.freeworld3d.org
Or look into gluUnProject:

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().
Why not simply use picking ? it's really not that difficult.

- Vince

This topic is closed to new replies.

Advertisement