130 likes | 379 Views
Chapter 5. Viewing. Classical and Computer Viewing Positioning of the Camera Simple Projections Projections in OpenGL Hidden-Surface Removal Walking Through a Scene Parallel-Projection Matrices Perspective-Projection Matrices Projections and Shadows. Classical and Computer Viewing (1).
E N D
Chapter 5. Viewing • Classical and Computer Viewing • Positioning of the Camera • Simple Projections • Projections in OpenGL • Hidden-Surface Removal • Walking Through a Scene • Parallel-Projection Matrices • Perspective-Projection Matrices • Projections and Shadows
Classical and Computer Viewing (1) • Basic Elements in Viewing [F0501] • objects, projectors (projection vectors), a projection plane • center of projection (COP) • the point at which all projectors meet • the center of the lens in the camera or in eye • Origin of camera frame • types of viewing • perspective views: view with a finite COP • parallel views: view with a COP at infinity [F0502] • direction of projection (DOP) • Classical Viewing • main types of views [F0503] • Orthographic Projection [F0504]
Classical and Computer Viewing (2) • Multiview Orthographic Projection [F0505] • the projection plane is parallel to one of the principal faces (front, back, top, bottom, right, left) of the object • the view preserves both distances and angles • Axonometric Projection [F0506,F0507] • the projection plane can have any orientation with respect to the object • isometric • the projection plane is placed symmetrically with respect to the three principal faces that meet at a corner of a rectangular object • the foreshortening of distances is the same • dimetric • the projection plane is placed symmetrically with respect to two principal faces • trimetric • general cases
Classical and Computer Viewing (3) • Oblique Projection [F0508] • the projectors may have an arbitrary angle with the projection plane • the angles in planes parallel to the projection plane are preserved • Perspective Viewing • vanishing point [F0509] • the point at which a set of projected parallel lines appears to converge • principal vanishing point [F0510] • vanishing point for any set of lines that are parallel to one of the principal direction (axes) of an object • no. of principal vanishing points in a projection = no. of principal axes intersecting the view plan • 1-/2-/3-point perspective
Classical and Computer Viewing (4) • Summary of Projection • parallel projection • orthographic (orthogonal) projection • the projectors are perpendicular to the projection plane • multiview orthographic projection • axonometric projection • dimetric • trimetric - isometric • oblique projection • perspective projection • one-point perspective • two-point perspective • three-point perspective
Positioning of the Camera (1) • Positioning of the Camera Frame • initial camera position in OpenGL • at the origin of the world frame pointing the negative z direction • relation between camera and objects [F0512] • a movement of camera = its corresponding reverse movement of objects • example of camera positioning [F0513] • update the MODELVIEW matrix
Positioning of the Camera (2) • Viewing API in PHIGS and GKS-3D • setting the camera frame • view reference point (VRP) • the point where the camera is centered set_View_reference_point(x, y, z) • view-plane normal (VPN) • the orientation of the view plane (normal vector) set_view_plane_normal(nx, ny, nz) • view-up vector (VUP) • the up direction of the camera set_view_up(ux, uy, uz) • viewing-coordinate system (u-v-n system) • n : normal vector • v : view-up vector (the orthogonal vector to n on the view plane) • u : the cross product of v and n
Positioning of the Camera (3) • Look-At Function in OpenGL [F0516] • define the position of the camera • gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz) • (eyex, eyey, eyez): camera location • (atx, aty, atz): the normal vector of the view plane with the eyepoint • (upx, upy, upz): the view-up vector • Other Viewing APIs • roll (좌우동), pitch (상하동), and yaw (편요각) [F0517] • applications involving flight simulator, etc. • origin : the center of mass of the vehicle • coordinate system : aligned along the axes of the vehicle • elevation (앙각) and azimuth (방위각) in polar coordinate [F0518] • applications involving objects that rotate about other objects
Simple Projections • Perspective Projection [F0520&21&22] M= | 1 0 0 0 | | 0 1 0 0 | | 0 0 1 0 | | 0 0 1/d 0| • Orthographic Projection [F0523]
Projections in OpenGL • Perspective Viewing in OpenGL • viewing volume [F0524] • truncated pyramid -> frustum • glFrustum(xmin, xmax, ymin, ymax, zmin, zmax) [F0525] • zmin and zmax should be positive • no symmetricity requirement with respect to the z axis • gluPerspective(fovy, aspect, near, far) [F0527] • fovy : field of view in the up (y) direction • aspect : aspect ratio (width divided by height) of the projection plane • near, far planes • Parallel Viewing in OpenGL [F0528] • glOrtho(xmin, xmax, ymin, ymax, zmin, zmax) • view volume : parallelepiped • zmin, zmax may have any sign (+, -)
Hidden-Surface Removal • Hidden-Surface-Removal Algorithm (Chapter 7) • remove those surfaces that should not be visible to the viewer • object-space algorithm approaches • order the surfaces of the objects in the scene • image-space algorithm approaches • determine the relationship among objects on each projector • z-buffer algorithm • Z-buffer Algorithm [F0529] • use a z-buffer (depth-buffer) to store the necessary depth information auxInitDisplayMode(AUX_RGB | AUX_DEPTH); // initialize the buffer glEnable(GL_DEPTH_TEST); // enable hidden-surface removal glClear(GL_DEPTH_BUFFER_BIT); // clear the buffer
Walking Through a Scene • Moving the Camera • the viewer looks at a fixed point [Appendix A.11] • gluLookAt(…) in OpenGL • the viewer does not look at a fixed point • use rotation and translation matrices to alter the model-view matrix