Is it possible to get the 3D coordinates of the point the mouse is pointing to.
This example might help.
Thanks,
Rowan
Is it possible to get the 3D coordinates of the point the mouse is pointing to.
This example might help.
Thanks,
Rowan
Yes. You have to do the following. Make sure that the depth test is enabled ofcourse.
float winX = mouseX;
float winY = height - mouseY;
float winZ=0;
glReadPixels( winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
GLdouble MV[16];
GLdouble P[16];
GLint viewport[4];
glGetDoublev(GL_MODELVIEW_MATRIX, MV);
glGetDoublev(GL_PROJECTION_MATRIX, P);
glGetIntegerv(GL_VIEWPORT, viewport);
double objX=0, objY=0, objZ=0;
gluUnProject(winX, winY, winZ, MV, P, viewport, &objX, &objY, &objZ);
See if this helps.
Works a treat, thanks