# The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003.

## Presentation on theme: "The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003."— Presentation transcript:

The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003

The View Frustum The view frustum is in the shape of a truncated pyramid, with its vertex at the eye, or camera. The frustum is defined by six planes. left and right (x direction) top and bottom (y direction) near and far (z direction)

The View Frustum left right

The View Frustum top bottom

The View Frustum near far

The Perspective Function The view frustum is defined by the function gluPerspective(). gluPerspective(viewAngle, aspectRatio, near, far). Example: gluPerspective(45, 4./3., 0.1, 100.0);

The Projection Matrix The Perspective function creates the projection matrix, which is used to project the 3D scene onto a 2D plane. We will discuss the projection matrix in more detail later.

The Graphics Pipeline View Matrix Projection Matrix Viewport Matrix Camera (Eye) Coordinates Device Coordinates Window Coordinates Model Matrix Object Coordinates World Coordinates

The Camera The camera determines the position, direction, and orientation of the view frustum in world coordinates. camera view frustum

The Camera The function gluLookAt() positions the camera. gluLookAt(eye.x, eye.y, eye.z, look.x, look.y, look.z, up.x, up.y, up.z). The camera is positioned at “eye”. The camera is pointed towards “look”. The camera is oriented in the direction “up”.

Fixed Camera We may place the camera in a fixed position. For example, place the camera at 5 on the z-axis, looking at the origin. gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

Movable Camera We may create a movable camera by making eye, look, and up variable. Normally up is fixed at (0, 1, 0). Often we fix look at (0, 0, 0). We may vary eye in rectangular or spherical coordinates.

Rectangular Coordinates We may use the x, y, and z keys to vary the x, y, and z coordinates of the camera. ‘X’, ‘x’: increment or decrement x. ‘Y’, ‘y’: increment or decrement y. ‘Z’, ‘z’: increment or decrement z.

Spherical Coordinates We call these distance, pitch, and yaw. Pitch and yaw are angles. The “roll” is normally fixed at 0  from the vertical. Measure pitch in the vertical plane. Measure yaw in the horizontal plane.

Spherical Coordinates yaw

Spherical Coordinates pitch

Spherical Coordinates eye.x = dist  cos(pitch)  sin(yaw). eye.y = dist  sin(pitch). eye.z = dist  cos(pitch)  cos(yaw).

Spherical Coordinates We may use the keyboard to vary the distance, pitch, and yaw coordinates of the camera. ‘+’, ‘–’: increment or decrement distance. ,  : increment or decrement pitch. ,  : increment or decrement yaw.

Example: Viewing the Cone CameraMover.cpp mesh.cpp LookMover.cpp

Download ppt "The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003."

Similar presentations