Problem with pan!

Hi guys,

I’m trying to pan in an ortho projection using a camera located perpendicular to the plane. I calculate the distance between the last position of the mouse and the new one every time the mouse is moving and I shift the camera to this delta distance.

It works but I want the scene be synchronized with the mouse pointer in that way they move together keeping the objects in the scene at the same distance to the mouse cursor where they were located when the panning started. But it’s not like that; the objects in the scene are shifted a little more than the mouse cursor.

If I multiply this delta distance by a factor say 0.004 it works better but I’m still having the problem. Can someone explain me how can I calculate this factor and why it’s needed?


PD: I unproject the mouse coordinates before calculate the delta distance.

That is a difficult question to answer directly. I don’t have the answer you ask for.

However, there is a library at GltZPR - Zoom, Pan, Rotate that might help you get started. I would try compiling it and running it. Then take a look at the code – it is a single C file. This may help to see how someone else accomplished something similar to what you ask.

Hi Marshats again!

I found the solution yesterday in the night. This factor is the amount of OpenGL pixels that appear in the viewport divided by the amount of window’s pixels.

Thank you very much once again!