Skip to main content
gamedev.net
🔒 Locked

Mouse 3d coordinates

Started by penetrator Jan 28, 2003 at 3:36 PM 0 replies 250+ views
Original Post
penetrator
penetrator
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 ?.
Sneftel
Sneftel
Don''t crosspost. I''ve answered in the other thread you made.


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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.