I'm modelling a room -in which I'd like to be able to obtain the exact position that I click with the mouse in that room. How do I go about doing this?Any code?

Cheers

Moz

11-23-2000, 01:08 AM

If you mean the exact position in world coordinates, you can do it like this.

Save the screen coordinates (in pixels) when you click (as winx and winy). Then read the depth buffer to get the depth value (this will be winz) at that point (with glReadPixels). Then use gluUnProject to obtain the world coordinates.

This is an example of a callback function that you can use with glut. Register it like this:
glutMouseFunc(WhenIClick);
When you click, objx, objy and objz will hold the world coordinates of the point you clicked.