Archived

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

penetrator

Mouse 3d coordinates

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
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