Jump to content
  • Advertisement

Archived

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

penetrator

Mouse 3d coordinates

This topic is 5652 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, i have a simple terrain engine built on a 1024x1024 triangle strip. I''d like, when i move the mouse on a vertex, to get the x,y,z coordinates. So i coded the following mousemove routine: xPos = LOWORD(lParam); // horizontal position of cursor yPos = HIWORD(lParam); // vertical position of cursor glGetIntegerv (GL_VIEWPORT, viewport); glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix); glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); realy = viewport[3] - (GLint) yPos - 1; glReadPixels(xPos,viewport[3]-yPos-19,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,(void *)pixel_depth_cp); gluUnProject ((GLdouble) xPos, (GLdouble) realy, pixel_depth_cp[0], mvmatrix, projmatrix, viewport, &wx, &wy, &wz); Is this code correct ? I.e. wx, wy, wz really hold the vertex coordinates ? If i want to draw a simple 3d point exactly where i click the mouse, do i have to glTranslatef to wx,wy,wz ?.

Share this post


Link to post
Share on other sites
Advertisement
Don''t crosspost. I''ve answered in the other thread you made.


Don''t listen to me. I''ve had too much coffee.

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!