In this tutorial, our virtual camera is established with the functions gluLookAt and gluPerspective (see the Virtual Camera tutorial). We investigate here motions of the camera which include orbiting, panning, trucking, and dollying. Trucking the camera means moving the eye-point to and from the look-at-point, while dollying involves moving the eye-point and the look-at-point together left and right.
Orbiting the camera can be thought of moving the eye-point over a sphere centered at the look-at-point. The easiest method for locating the eye-point on the sphere when the look-at-point is at the origin is to use spherical coordinates. If the look-at-point is not at the origin, we first perform a translation to move the look-at-point to the origin. Next, we perform the computations as discussed next to find the coordinates of the eye-point. Last, we apply the inverse translation to move the origin back to the original look-at-point.
Spherical coordinates consist of an angle of longitude (also called angle Theta), an angle of latitude (also called angle Phi) and the radius of the sphere. Of course, we need to convert the spherical coordinates to rectanglur coordinates to find the x, y and z coordinates of the eye-point.
The formulae for finding the rectanglur coordinates are given as follows:
x = radius * sin(Theta) * cos(Phi) z = -radius * cos(Theta) * cos(Phi) y = radius * sin(Phi)
Panning the camera is similar to orbiting. In the case of panning, the eye-point is fixed and we move the look-at-point over a sphere centered at the eye-point. The formulae for finding the rectangular coordinates of the look-at-point are the same as that for finding the coordinates of the eye-point when orbiting. As with orbiting, we must first translate the eye-point to the origin, if not already there, before performing the computations and then translate the origin back to the original eye-point.
Zooming is another type of camera animation when the projection method is gluPerspective. Zooming in and out means changing the camera's view angle. Making the view angle smaller causes the camera to "zoom-in" while making it bigger creates a "zoom-out" effect. Again, see the Virtual Camera tutorial on how to modifiy this camera parameter.