POINT pt; GetCursorPos(&pt);
GLint viewport[4];
GLdouble mvmatrix[16], projmatrix[16];
GLint realy; // OpenGL y coordinate position
GLdouble wx, wy, wz; // returned world x, y, z coords
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);// note viewport[3] is height of window in pixels
realy = viewport[3] - (GLint) pt.y - 1;
float depth;
glReadPixels(pt.x,realy,1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
gluUnProject((GLdouble) pt.x, (GLdouble) realy, depth, mvmatrix, projmatrix, viewport, &wx, &wy, &wz);
cursor_world_coords = VECTOR(wx,wy,wz);
but know i was asking me how i can find out on which Object the Coordinate is. The problem that i had is that every object has a pos but the objects are bigger than the pos so it happens that the mouse is over an object but don`t see it. Are there any good examples or tutorials on this?
Thanks
Punika
[ Power Productions ]
Edited by - Punika on January 24, 2001 4:29:20 PM
Question: dragging object under a mouse
Ok,
everythin works fine with this code:
Punika
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement