The View Frustum and the Camera Lecture 19

  • Slides: 19
Download presentation
The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003

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,

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. n n n left and right (x direction) top and bottom (y direction) near and far (z direction)

The View Frustum left right

The View Frustum left right

The View Frustum top bottom

The View Frustum top bottom

The View Frustum near far

The View Frustum near far

The Perspective Function The view frustum is defined by the function glu. Perspective(). glu.

The Perspective Function The view frustum is defined by the function glu. Perspective(). glu. Perspective(view. Angle, aspect. Ratio, near, far). Example: glu. Perspective(45, 4. /3. , 0. 1, 100. 0);

The Projection Matrix The Perspective function creates the projection matrix, which is used to

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

The Graphics Pipeline Model Matrix Object Coordinates View Matrix World Coordinates Projection Matrix Camera

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

The Camera The camera determines the position, direction, and orientation of the view frustum

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

The Camera The function glu. Look. At() positions the camera. glu. Look. At(eye. x,

The Camera The function glu. Look. At() positions the camera. glu. Look. At(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

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. glu. Look. At(0. 0, 5. 0, 0. 0, 1. 0, 0. 0);

Movable Camera We may create a movable camera by making eye, look, and up

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

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.

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 yaw

Spherical Coordinates pitch

Spherical Coordinates pitch

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

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

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 Camera. Mover. cpp n mesh. cpp Look. Mover. cpp

Example: Viewing the Cone Camera. Mover. cpp n mesh. cpp Look. Mover. cpp