Object Selection

I’m trying to write a 3D modeler and I’m having a problem trying to do object selection. I’m trying to map the Client mouse co-ordinates to a point on the camera “near frame” in World co-ordinates, unfortunately my mapping isn’t right at all. Once I have a point on the near frame I send rays off to the objects to do depth based object selection (which works!).

If someone could sketch out the mapping it would be an enormous help. I’m trying to do it for both openGL and DirectX by the way if it matters.


For this approach you should use gluUnproject. It needs the x and y value from the screen and the z value from the z-buffer where you picked. You get it with glReadPixels.

Other possibilities would be to pick with the help of openGL’s object picking functions.

I used the first approach too, seems better to me.