Hello,
I am using gluUnproject to get world coordinate from mouse coordinate. I do not know why it is producing weird result. I have used the following command:
gluUnProject( x, y, -1, modelview, projection, viewport, &nx, &ny, &nz);
gluUnProject( x, y, 1, modelview, projection, viewport, &fx, &fy, &fz);
I here -1, and 1 relate to near and far plane. In my program near plane is around 40.0 and far plane around 360.0. From the above equation I want to derive a ray originated at nx, ny, nz and directing towards (fx-nx), (fy-ny) and (fz-nz). I want to test when I place the mouse on a sphere, whether it intersects or not. But I am not getting correct result. Could any one give me suggestion about how to use it properly?