gluUnProject

It looks like gluUnProject does not offer the right OpenGL 3D coordinates if the drawing objects are rotated. gluUnProject does not have rotation matrix as a parameter. Please let me know if I am wrong. Is their anyway to get the 3D coordinates in a rotated scenery? Do we have to use glMultMatrix to multiply the coordinates we get from gluUnProject with the inverse matrix of rotation?

Originally posted by Rong Yao:
It looks like gluUnProject does not offer the right OpenGL 3D coordinates if the drawing objects are rotated. gluUnProject does not have rotation matrix as a parameter. Please let me know if I am wrong. Is their anyway to get the 3D coordinates in a rotated scenery? Do we have to use glMultMatrix to multiply the coordinates we get from gluUnProject with the inverse matrix of rotation?

gluUnProject maps screen coordinates (2D) to object coordinates (3D). And since it gets the modelview matrix as an input parameter it handles the rotations correctly. But it does not give you rotated coordinates of your objects as it is not designed to do such thing.
There is a way to get the rotated 3D coordinates but it does not involve glMultMatrix or gluUnProject. A search on this forum should give you the answer. And perhaps you want to ask google about the red book.
Hope I got your question right, perhaps you tell us what you want to do and we can help more.

[This message has been edited by satan (edited 07-23-2003).]

If you have MFC I have a demo on my site that might help you. I’m trying to allow the user to drag objects around the screen and click-drag to draw. gluProject and gluUnProject do about 90% of what I need so I’m going to have to do some more math, but if you’re curious as to the effects of rotation on the returned values it should help you.

daltxcoltsfan.tripod.com/OpenGL/OpenGL.htm

Thank you all.

I downloaded your files. However, I cannot compile it. Below is the error message:
fatal error RC1015: cannot open include file ‘res\ProjectAndUnprojectDemo.rc2’
Could you please help me to solve the problem? Thanks a lot!

Originally posted by DalTXColtsFan:
[b]If you have MFC I have a demo on my site that might help you. I’m trying to allow the user to drag objects around the screen and click-drag to draw. gluProject and gluUnProject do about 90% of what I need so I’m going to have to do some more math, but if you’re curious as to the effects of rotation on the returned values it should help you.

daltxcoltsfan.tripod.com/OpenGL/OpenGL.htm[/b]

Hi,

Try on this link.
http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/014739.html

Is there any easy way to detect if my mouse is on any object in the drawing or not?

Hi,

A long line will be created at z axis when the mouse was clicked on the screen. The intersection point of the line and objects will be calculated. Coordinates (x,y,z) of the object that you have clicked are equal to the intersection point.

please refer to red book in page 152… how to get the near clipping z value and far clipping z value.

Hope it can help.