I have a question about OpenGL. I know how to find out the coordinate
of the point when the mouse cursor is over it using gluUnProject() but
i am wondering if there is a way in OpenGL that can help me find out
the surface normal at that point as the cursor is moved?
Any suggestion and comments will be MUCH appreciated.
Well there are no really easy ways. Your options are:
Find out which triangle has been clicked and interpolate it’s normal at the position where the mouse is. You can do this easily using barycentric coordinates (search).
The other option is to draw the scene by encoding normals into colors. The rgb value at each vertex should be (nx0.5+0.5, ny0.5+0.5, nz*0.5+0.5), gl will interpolate them for you. Then just read the color under the mouse and decode it. This could be an easier solution if you haven’t implemented triangle picking, but it doesn’t give as accurate results and is dependent on the user’s color depth. I’d go with the first one.