View Full Version : Problem with pan!

08-18-2009, 09:51 AM
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.

08-19-2009, 10:16 PM
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 (http://www.nigels.com/glt/gltzpr/) 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.

08-20-2009, 05:11 AM
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!