PDA

View Full Version : relationship between mouse position and coordinate and normal

ljz
12-25-2002, 05:01 AM
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?

Dexter
12-25-2002, 11:34 AM
Ehehe... try to use glUnProject to retrieve mouse 3d coordinates

ljz
12-30-2002, 05:12 PM
Thanks!

ljz
01-09-2003, 05:39 PM

Ysaneya
01-09-2003, 11:06 PM
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.

ljz
02-16-2003, 10:05 PM
Any other ideas,plz?

rgpc
02-16-2003, 11:07 PM
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.

Buffalo
02-17-2003, 04:58 AM
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.

V-man
02-18-2003, 09:25 AM
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.

Buffalo
02-18-2003, 12:54 PM
Thanks i dind't now that