Contents / Previous / Next


The Viewing Transformation

Recall that the viewing transformation is analogous to positioning and aiming a camera.

By default, the camera as well as any objects in the scene are originally situated at the origin;
also, the camera initially points down the negative z-axis.

Once the matrix is initialized, the viewing transformation is specified with glTranslatef() and glRotatef().


Pilot View

For some specialized applications, you might want to define your own transformation routine.

Suppose you are writing a flight simulator and you would like to display the world from the point of view of the pilot of a plane with coordinates (x, y, z) and some roll, pitch, and heading (these are rotation angles of the plane relative to its center of gravity).

void pilotView{GLdouble planex, GLdouble planey,
                 GLdouble planez, GLdouble roll,
                 GLdouble pitch, GLdouble heading)
{
      glRotated(roll, 0.0, 0.0, 1.0);
      glRotated(pitch, 0.0, 1.0, 0.0);
      glRotated(heading, 1.0, 0.0, 0.0);
      glTranslated(-planex, -planey, -planez);
}