Download presentation

Presentation is loading. Please wait.

Published byTyler Pressnall Modified about 1 year ago

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

2
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)

3
The View Frustum left right

4
The View Frustum top bottom

5
The View Frustum near far

6
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);

7
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.

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

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

10
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”.

11
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);

12
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.

13
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.

14
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.

15
Spherical Coordinates yaw

16
Spherical Coordinates pitch

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

18
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.

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

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google