relationship between mouse position and coordinate and normal

I want to do something like this:
when the mouse moves upon a model rendered with openGL, the x,y,x coordinates and normal of the point on the model should be displayed. That is, how to convert from mouse position on the screen to the x,y,x coordinates and how to get the normal of this point?
Thanks for your direction in advance.

Ehehe… try to use glUnProject to retrieve mouse 3d coordinates

Thanks!

And how about the normal?

With gluUnProject you can get the position of your pixel in the world, and create a ray from your view position to this pixel. Now you can cast this ray with your world geometry to determine which triangle is hit, and get the intersection point and normal. All you need is a fast ray/triangle intersection function.

Y.

Any other ideas,plz?

Originally posted by ljz:
Any other ideas,plz?

Oh dear, another Shanedudddy…

Ysaneya has given you the best answer. Implementing it will teach you a great deal about 3d intersections/transformations that will prove invaluable with more advanced 3d development.

And don’t forget that the Mouse y Corrdinate muss be inverted,since the OpenGL uses the left bottom corner and not the left upper.

Originally posted by Buffalo:
And don’t forget that the Mouse y Corrdinate muss be inverted,since the OpenGL uses the left bottom corner and not the left upper.

It does if you say it does. You can always exhange top and bottom you provide to glFrustum or glOrtho or whatever else you use.

Thanks i dind’t now that