Sign in to follow this  
gashad

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

Recommended Posts

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

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this