To implement “Pan & Zoom Effect” there are two ways.
- Change the Image size for every zoomFactor
- Change the Camera’s (gluLookAt) position for every zoomFactor
I have implemented this by varying the camera’s position.
Scaled the image initially (for example 8X) and altered the camera’s ‘z’ position to fit the image as it was in 1X (without zoom)
Initially with no user inputs, the image fits the full window and camera is at (say for example) at z = 10.
I move closer (z = 8), which produces zoomed In effect.
At this point my view volume is restricted to a portion of the full image. [Actual full image is stretched beyond the view volume]
Now here when i pan the image (moving camera in X/Y), the boundary check has to be implemented…
i.e., When image is panned left side (camera moves right) i could see the portion of the image excluded to the right side of view volume (coz of the above zoom In effect). As i proceed moving and when the right end of the image encounters the right end of the window (view volume), further pan motion should be restricted.
‘z’ distance from image
Ur suggestions are appreciated.