I use gluUnProject to get 2D position of mouse in 3D position in OpenGL scene.
I use this source :
here is camera rotation and stuff
glGetDoublev(GL_MODELVIEW_MATRIX,ModelViewMatrix);
glGetDoublev(GL_PROJECTION_MATRIX,ProjectionMatrix);
glGetIntegerv(GL_VIEWPORT,ViewPort);
here is all drawing and stuff
and OnMouseClick :
GLdouble D2Z;
GLdouble D3X;
GLdouble D3Y;
GLdouble D3Z;
glReadPixels(Screen.Mouse.Position.X,768 - Screen.Mouse.Position.Y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &D2Z);
gluUnProject(Screen.Mouse.Position.X,768 - Screen.Mouse.Position.Y,D2Z,ModelViewMatrix,ProjectionMatrix,ViewPort,&D3X,&D3Y,&D3Z);
BUT, the position is always litle bit next to camera. in 3D world. Its always almost the same as position of camera. So thats not what i need. Can somebody help me with this problem ?
[This message has been edited by jirkamelich (edited 12-30-2002).]