6. CGVR Viewing and Transformation
Total Page:16
File Type:pdf, Size:1020Kb
Realtime 3D Computer Graphics & Virtual Reality Viewing Per Poly. Per Transformation Poly. Vertex Vertex CPU DL Raster Frag FB CPU DL Raster Frag FB Texture Texture Pipeline Pixel Pixel object eye clip normalized window device v e r Modelview Projection Perspective Viewport t e Matrix Matrix Division Transform x Modelview Projection n other calculations here Modelview – material è color – shade model (flat) l – polygon rendering mode l – polygon culling l – clipping 1 Example Frame Rending n Establish World n Establish Viewpoint & Display Plane n Perform 3D Clipping n Projection of World onto Display Plane n Perform Hidden Surface Removal n Determine Display Colors n Rasterization of 2D Display *Rendering order may be changed based on algorithms involved! Classical and General Viewing 2 Viewing n Process for “Seeing” a world n Projection of a 3D world onto a 2D plane n Synthetic Camera Model Viewing Issues n Location of viewer n Location of view plane n What can be seen (Clipping) n How relationships are maintained – Parallel Lines – Angles – Distances (Foreshortening) – Relation to Viewer 3 Objects vs. Scenes n Some viewing techniques better suited for viewing single objects rather than entire scenes n Viewing an object from the outside (external viewing) – Engineering, External Buildings n Viewing an object from within (internal viewing) – Internal Buildings, Games Definitions n Projection: a transformation that maps from a higher dimensional space to a lower dimensional space (e.g. 3D->2D) n Center of projection (CoP): the position of the eye or camera with respect to which the projection is performed (also eye point, camera point, proj. reference point) n Projection plane: in a 3D->2D projection, the plane to which the projection is performed (also view plane) 4 Projectors n Projectors: lines from coordinate in Original Space to coordinate in Projected Space A A Projectors B Projectors A' B A' Projection B' Plane Projection B' Plane Center of Projection at Center of Infinity (Direction of Projection Projection) Perspective: Distance to CoP Parallel: Distance to CoP is is finite infinite Planar Geometric Projections n Projection onto a plane n Projectors are straight lines n Alternatives: – Some Cartographic Projections – Omnimax 5 Center of Projection Perspective View Parallel View Viewing Classification – Planar Geometric Projections – Parallel – Perspective n One-Point n Orthographic – Top (Plan) n Two-Point – Front n Three-Point – Side – Axonometric n Isometric n Dimetric n Trimetric n Oblique – Cabinet – Cavalier – Other 6 Projections Planar Geometric Projections Parallel Perspective One-point Orthographic Oblique Top Two-point (Plan) Cabinet Three-point Front Cavalier elevation Side Other elevation Axonometric Other Parallel Projections n Orthographic: Direction of projection is orthogonal to the projection plane – Elevations: Projection plane is perpendicular to a principal axis n Front n Top (Plan) n Side – Axonometric: Projection plane is not orthogonal to a principal axis – Isometric: Direction of projection makes equal angles with each principal axis. n Oblique: Direction of projection is not orthogonal to the projection plane; projection plane is normal to a principal axis – Cavalier: Direction of projection makes a 45° angle with the projection plane – Cabinet: Direction of projection makes a 63.4° angle with the projection plane 7 Parallel Projections: Orthographic Projections n Parallel Projectors Perpendicular to Projection Plane n Special Case of Perspective Projection Orthographic Projections: Multiview n Classical Drafting Views n Preserves both distance and angles n Suitable to Object Views, not scenes n Front-Elevation n Projection Plane Parallel to Principle Faces n Top or Plan-Elevation n Side-Elevation 8 Orthographic Projections: Axonometric Projections n Projection plane can have any orientation to object Axonometric Projections n Isometric – Symmetric to three faces n Dimetric – Symmetric to two faces n Trimetric – General Axonometric case 9 Axonometric Projections Cont. n Foreshortening: – Length is shorter in image space than an object space – Uniform Foreshortening – (As opposed to perspective projections where foreshortening is dependent on distance from object to COP n Parallel lines preserved n Angles are not preserved Oblique Projections n Parallel Projections not Perpendicular to Projection Plane 10 Oblique Projection Types n Cavalier – 45-degree Angles from Projection Plane n Cabinet – Arctan(2) or 63.4-degree Angles from Projection Plane Perspective Projections n One-point: – One principal axis cut by projection plane – One axis vanishing point n Two-point: – Two principal axes cut by projection plane – Two axis vanishing points n Three-point: – Three principal axes cut by projection plane – Three axis vanishing points 11 Perspective Projections n First discovered by Donatello, Brunelleschi, and DaVinci during Renaissance n Objects closer to viewer look larger n Parallel lines appear to converge to single point Perspective Projection n In the real world, objects exhibit perspective foreshortening: distant objects appear smaller n The basic situation: 12 Perspective Projection n When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world: How tall should this bunny be? Perspective Views n Objects further away look smaller n Natural look n Length is not preserved – Foreshortening of lines depends on distance from viewer 13 Perspective Projections Vanishing Points n Perspective Projection of any set of parallel line (not perpendicular to the projection plane) converge to a vanishing point n Infinity of vanishing points – one of each set of parallel lines 14 Axis Vanishing Points n Vanishing point of lines parallel to one of the three principal axes n There is one axis vanishing point for each axis cut by the projection plane n At most, 3 such points n Perspective Projections are categorized by number of axis vanishing points (x, y, z) One-Point Projection (x, y, z) +Z Center of Projection on the negative z- (xproj, yproj, 0) axis with viewplane in the x-y plane. xprojected = xd/(d+z) = x/(1+(z/d)) yprojected = yd/(d+z) = y/(1+(z/d)) (0, 0, -d) -Z é1 0 0 0ùéxù é x ù éx /(1+ (z / d))ù ê0 1 0 0úêyú ê y ú êy /(1+ (z / d))ú ê úê ú = ê ú = ê ú ê0 0 0 0úêzú ê 0 ú ê 0 ú ê úê ú ê ú ê ú ë0 0 1/ d 1ûë1û ë1+ (z / d)û ë 1 û 15 Another One-Point Projection +Z Center of Projection at the origin with view plane parallel to the x-y plane a distance d from the origin. xprojected = dx/z = x/(z/d) -Z yprojected = dy/z = y/(z/d) é1 0 0 0ùéxù é x ù éx /(z / d)ù ê0 1 0 0úêyú ê y ú êy /(z / d)ú ê úê ú = ê ú = ê ú ê0 0 1 0úêzú ê z ú ê d ú ê úê ú ê ú ê ú ë0 0 1/ d 0ûë1û ëz / d û ë 1 û Mper Points plotted are x/w, y/w where w = z/d Specifying An Arbitrary 3-D View n Two coordinate systems – World reference coordinate system (WRC) – Viewing reference coordinate system (VRC) n First specify a view plane and coordinate system (WRC) – View Reference Point (VRP) – View Plane Normal (VPN) – View Up Vector (VUP) n Specify a window on the view plane (VRC) – Max and min u,v values (Center of the window (CW)) – Projection Reference Point (PRP) – Front (F) and back (B) clipping planes (hither and yon) 16 Synthetic Camera Model Synthetic Camera Model 17 Camera Analogy n 3D is just like taking a photograph (lots of photographs!) viewing volume camera tripod model Camera 18 Camera Projection Camera Analogy and Transformations n Projection transformations – adjust the lens of the camera n Viewing transformations – tripod–define position and orientation of the viewing volume in the world n Modeling transformations – moving the model n Viewport transformations – enlarge or reduce the physical photograph 19 Coordinate Systems and Transformations n Steps in Forming an Image – specify geometry (world coordinates) – specify camera (camera coordinates) – project (window coordinates) – map to viewport (screen coordinates) n Each step uses transformations n Every transformation is equivalent to a change in coordinate systems (frames) Projection Specification 20 Projection Characteristics n Camera/Viewpoint Location n Camera/Viewpoint Direction n Camera/Viewpoint Orientation n Camera/Viewpoint Lens (View Volume) – Width/Height of Lens – Front/Back Clipping Planes n Parallel or Perspective Projections – Parallel is special case of Perspective OpenGL Camera or Projection Coordinates y Visible Objects in the -z direction x Display Plane centered at (0,0,0) z 21 Specifying Viewing Characteristics n Fixed Camera / Move World n “Look At” n View Volume / Display Plane Specification n Vector Specification Camera Location Relative to World Coordinates n Can be thought of in two ways: – Camera location is specified in world coordinates – World coordinate frame is located in camera coordinates n Camera transformations are reverse of World transformations 22 Fixed Camera / Move World n Fix the camera at a specific location/orientation n Transform the world such that the camera sees the world the “right” way – I.e., move the world, not the camera n Typical approach for OpenGL “Look At” n Setup the camera to “Look At” the world n Set the camera location n Set the “look at” point n Set the camera rotation angle n Example: gluLookAt 23 View Volume / Display Plane Specification n Specify View Volume and Display Plane Viewing Volume Far Clipping Plane Near Clipping Plane Projection Plane Fun with View Volumes n All projection information is captured in view volume and projection plane. n What happens if we play with these values? – Oblique Parallel Projections – Non-Right Frustum Perspective Projections n View Volume Values – Box Back Clipping Plane n Lower-Left Corner/Upper Right Corner of back and front planes n Back Plane Angles/Front Plane Angles View – Projection Plane Plane n Lower-Left Corner/Upper-Right Corner Front Clipping n Angle Plane n Location Relative to View Volume 24 Vector Specification n Most flexible method of viewing specification n View plane may be anywhere with respect to the world n Locate the View Plane (I.e.