Moving Camera accurately

Hi guys,

I’ve been scouring the forum now for ages and can’t seem to find an answer to the issue I’m having, so apologies if this has already been asked.

I’m trying to pan around my scene accurately. I understand that I should use gluunproject with win z as 0 and 1 to create a ray. I then get the nearest point in the scene by calculating the distance between the object & the near & far clipping planes.

Everything is working up until this step!

I now want to pan the camera keeping this point equidistant to the mouse pointer position.

At the moment I’m dividing the selected point’s distance from the near clip plane point by the total distance between near & far clip planes. I’m hoping that this then gives me the depth value that the selected point is on, but I think this is wrong!

If anybody can give me any pointers they’ll be greatly appreciated!