Three-Dimensional Viewing Hearn & Baker Chapter 7 COMPUTER GRAPHICS Three-Dimensional Viewing Hearn & Baker Chapter 7
Overview 3D viewing involves some tasks that are not present in 2D viewing: Projection, Visibility checks, Lighting effects, etc.
Overview First, set up viewing (or camera) coordinate reference The position and orientation for a view plane (or projection plane) that corresponds to a camera film plane Figure 10-1 Coordinate reference for obtaining a selected view of a three-dimensional scene.
Projections Parallel projection Perspective projection As used in engineering and architectural drawings Shows accurate dimensions Perspective projection Objects far away are shown smaller than nearby same size objects Figure 10-2 Three parallel-projection views of an object, showing relative proportions from different viewing positions.
Depth Cueing Depth info is important to identify viewing direction Depth cueing: Vary the brightness of lines according to distance
3D Viewing Pipeline Choose a viewing position (place the camera) Decide on camera orientation Direction and rotation (up direction) Figure 10-5 Photographing a scene involves selection of the camera position and orientation.
Some viewing operations in 3D are same as in 2D 3D Viewing Pipeline Some viewing operations in 3D are same as in 2D 2D viewport, 2D clipping window, etc. Some are different Even though clipping window is 2D on the view plane, the scene is clipped against a volume (view volume)
3D Viewing Pipeline Figure 10-6 General three-dimensional transformation pipeline, from modeling coordinates (MC) to world coordinates (WC) to viewing coordinates (VC) to projection coordinates (PC) to normalized coordinates (NC) and, ultimately, to device coordinates (DC).
3D Viewing-Coordinate Parameters Select View point (or viewing position, eye position, camera position) P0=(x0,y0,z0) View-up vector V to define yview Direction to define zview Figure 10-7 A right-handed viewing-coordinate system, with axes x view, y view, and z view, relative to a right-handed world-coordinate frame.
The View-Plane Normal Vector Viewing direction is along zview axis So, view plane (or projection plane) is normally perpendicular to this axis Orientation of the view plane (and direction of positive zview axis) can be defined by a view-plane normal vector N Figure 10-8 Orientation of the view plane and view-plane normal vector N.
The View-Plane Normal Vector Then, a scalar parameter is used to set the position of the view plane at coordinate zvp along zview axis Figure 10-9 Three possible positions for the view plane along the z view axis.
The View-Up Vector After view plane normal N, we choose a direction for view-up vector V (used to determine positive yview) V should be perpendicular to N Viewing routines typically adjust user-defined V Often, V=(0,1,0) is a convenient choice Figure 10-11 Adjusting the input direction of the view-up vector V to an orientation perpendicular to the view-plane normal vector N.
The uvn Viewing-Coordinate Reference Frame Right-handed viewing systems are more common, but sometimes left-handed viewing systems are used In left-handed viewing systems viewing direction is towards the positive zview direction Left-handed coordinate references are often used to represent screen coordinates and for the normalization transformation
The uvn Viewing-Coordinate Reference Frame View-plane normal N defines zview axis direction View-up vector V is used to obtain yview axis direction We need to determine xview axis direction cross product of N and V gives U in xview axis direction cross product of N and U gives adjusted V u, v, n are unit vectors in directions U, V, N Figure 10-12 A right-handed viewing system defined with unit vectors u, v, and n.
Generating 3D Viewing Effects By varying viewing parameters, different viewing effects can be achieved
Transformation from World to Viewing Coordinates Translate viewing coordinate origin (P0) to the world coordinate origin Align xview, yview, zview with xw, yw, zw
Transformation from World to Viewing Coordinates The transformation matrix is the product of these translation and rotation matrices
Projection Transformations In parallel projection, coordinate positions are transferred to view plane along parallel lines orthogonal/orthographic oblique For perspective projection, coordinates are transferred to view plane along lines that converge at a point
Orthogonal Projections Projection along lines parallel to the view-plane normal N Front, side, rear orthogonal projections are often called elevations The top one is called plan view Figure 10-17 Orthogonal projections of an object, displaying plan and elevation views.
Axonometric and Isometric Orthogonal Projections . Orthogonal projections which show more than one face of an object are called axonometric orthogonal projections Isometric: Most common axonometric o.p.s that are generated by aligning projection plane so that it intersects principal axes at the same distance from origin
Orthogonal Projection Coordinates If projection direction is parallel to zview xp=x, yp=y z coordinate is kept for visibility detection procedures Figure 10-19 An orthogonal projection of a spatial position onto a view plane.
Clipping Window and Orthogonal Projection View Volume Edges of the clipping window specify the x and y limits These are used to form the top, bottom, and two sides of a clipping region called the orthogonal-projection view volume Limit the volume in zview direction by near-far (or front-back) clipping planes
Figure 10-22 A finite orthogonal view volume with the view plane “in front” of the near plane.
Normalization Transformation for an Orthogonal Projection mapping coordinates into a normalized view volume with coordinates in the range -1 to 1
Oblique Parallel Projections Projection path is not perpendicular to view plane It can be defined with a vector direction The effect is same as z-axis shearing transformation Figure 10-25 An oblique parallel projection of a cube, shown in a top view (a), produces a view (b) containing multiple surfaces of the cube.
Figure 10-32 Top view of an oblique parallel-projection transformation Figure 10-32 Top view of an oblique parallel-projection transformation. The oblique view volume is converted into a rectangular parallelepiped, and objects in the view volume, such as the green block, are mapped to orthogonal-projection coordinates.
Perspective Projections Project objects to view plane along converging paths to projection reference point (or center of projection) Figure 10-33 A perspective projection of two equal-length line segments at different distances from the view plane.
Perspective Projections If it is at origin On the viewplane, z’=zvp. Solve this for u Substitute this u into x’ and y’ equations If projection reference point is on zview Figure 10-34 A perspective projection of a point P with coordinates (x, y, z) to a selected projection reference point. The intersection position on the view plane is (xp, yp, zvp ).
Figure 10-35 A perspective-projection view of an object is upside down when the projection reference point is between the object and the view plane. Q. What if the scene is between the projection reference point and the view plane?
Figure 10-36 Changing perspective effects by moving the projection reference point away from the view plane.
Vanishing Points Lines parallel to view plane are still parallel But, other lines parallel to each other are now converging The point such lines converge at are vanishing points Vanishing points for lines parallel to principal axes are principal vanishing points How many principal v.p.s can be seen depends on projection plane orientation 1-point, 2-point, or 3-point projections
Perspective Projection View Volume An infinite pyramid of vision is chopped off by near and far clipping planes and we get a truncated pyramid (or frustum)
Perspective-Projection Transformation Matrix Cannot directly apply a matrix and get the result 2 steps are required First, calculate the homogeneous coordinates using perspective projection matrix Ph=Mpers P Then, after normalization and clipping, divide by h (homogeneous parameter, h=zprp-z) sz (scaling) and tz (translation) factors for normalizing projected z coordinate values (they depend on the selected normalization range
Symmetric Perspective Projection Frustum If the line from perspective reference point through clipping window center (centerline) is perpendicular to view plane, we have a symmetric frustum Clipping window can be specified by width and height, or field-of-view angle and aspect ratio With a symmetric frustum, perspective transformation is a mapping to orthogonal coordinates (figure on next slide)
Figure 10-44 A symmetric frustum view volume is mapped to an orthogonal parallelepiped by a perspective-projection transformation.
Oblique Perspective-Projection Frustum Centerline not perpendicular to view plane First, transform this into a symmetric frustum (z-axis shearing) Then proceed as before
Viewport Transformation and 3D Screen Coordinates Once we have normalized projection coordinates, clipping can be done on the symmetric cube (or unit cube) After clipping, cube contents can be transferred to screen coordinates For x and y, same as in 2D Depth info (z coordinates) must be retained for visibility testing and surface rendering
3D Clipping Algorithms No matter what the projection details were, we now have a normalized cube, so we clip against planes parallel to Cartesian planes (either at coordinates 0 and 1, or -1 and 1) The task is to identify object sections within the cube (save parts inside and eliminate parts outside) Algorithms are extensions of the 2D algorithms
3D Region Codes The idea is the same as in 2D (we added 2 more bits for near and far planes) A point is now P=(xh,yh,zh,h) h can be a value other than 1 (in perspective projection), so, the inequalities to be satisfied are -1<=xh/h<=1 -1<= yh/h<=1 -1<= zh/h<=1
3D Region Codes And bit values can be decided by h values should be nonzero and often positive (these can be easily checked) So, our inequalities become -h <= xh <= h, -h <= yh <= h, and -h <= zh <= h And bit values can be decided by bit 1 = 1 if h + xh < 0 (left) bit 2 = 1 if h - xh < 0 (right) bit 3 = 1 if h + yh < 0 (bottom) bit 4 = 1 if h - yh < 0 (top) bit 5 = 1 if h + zh < 0 (near) bit 6 = 1 if h - zh < 0 (far)
Figure 10-50 Values for the three-dimensional, six-bit region code that identifies spatial positions relative to the boundaries of a view volume.
__ Figure 10-51 Three-dimensional region codes for two line segments. Line P1P2 intersects the right and top clipping boundaries of the view volume, while line P3P4 is completely below the bottom clipping plane. __
Figure 10-52 Three-dimensional object clipping Figure 10-52 Three-dimensional object clipping. Surface sections that are outside the view-volume clipping planes are eliminated from the object description, and new surface facets may need to be constructed.
Figure 10-53 Clipping a line segment against a plane with normal vector N.
Figure 10-54 Clipping the surfaces of a pyramid against a plane with normal vector N. The surfaces in front of the plane are saved, and the surfaces of the pyramid behind the plane are eliminated.