PDA

View Full Version : Converting Mouse Coordinates to 3D Coordinates



Infamous
02-17-2002, 11:21 PM
Hello to everyone !

I like to know how I can easily convert the 2D coordinates of the mouse to 3D coordinates. Does anyone know something about this ?

Bob
02-18-2002, 12:14 AM
Use gluUnProject.

The win-Z coordinate (third parameter I think) can be a problem. Some people use glReadPixels to read the Z-buffer value at the mouse posision and pass it to gluUnProject.

Furrage
02-18-2002, 07:33 AM
win-z should be between 0 and 1 inclusive. I use this and get no problems.

However, if you changed glDepthRange the limits will be adjusted. If you haven't then stick to 0-1 and you should be fine.