Mouse Co-ordinates

hi friends,

   How to Convert mouse 2D Co-ordinates into screen 3d Co-ordinates.Please help me regarding this issue.

regards

S.Dastagir

Look at gluUnproject. BTW, this is not advanced.

i just can give u an not very advanced sample i used for select 3d object as an 2d selection, for selection i calculate 2 circles around the objects and look if the mouse radius is within the object circle

Mouse.y is the Winproc kooridnatecoordinates


typedef struct {
GLfloat x   ;
GLfloat y;
GLfloat x3D;
GLfloat y3D;
bool lbuttonDown;
bool rbuttonDown;
}mouse;
mouse Mouse;

this is the winproc part


///
	case WM_MOUSEMOVE:
{
	Mouse.x =(short)LOWORD(lParam);
	Mouse.y= (short)HIWORD(lParam);
	// Check to see if the left button is held down:
	 break;

nHeight,nWidth is the size of the opengl window


GLfloat nh=nHeight/2;
GLfloat nw=nWidth/2;
Mouse.y3D=-(Mouse.y-nh-nHeight)/10;
Mouse.x3D=(Mouse.x-nw-nWidth)/10;