1 / 58

Chapter 5

Chapter 5. Viewing. OpenGL Perspective Matrix. planar geometric projections. parallel. perspective. 1 point. 2 point. 3 point. multiview orthographic. axonometric. oblique. isometric. dimetric. trimetric. Perspective Projection. Parallel Projection. Planar Geometric Projections.

bowie
Download Presentation

Chapter 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 Viewing

  2. OpenGL Perspective Matrix planar geometric projections parallel perspective 1 point 2 point 3 point multiview orthographic axonometric oblique isometric dimetric trimetric

  3. Perspective Projection

  4. Parallel Projection

  5. Planar Geometric Projections • Standard projections project onto a plane • Projectors are lines that either • converge at a center of projection • are parallel • Such projections preserve lines • but not necessarily angles

  6. Classical Projections

  7. Orthographic Projection Projectors are orthogonal to projection surface

  8. Multiview Orthographic Projection isometric (not multiview orthographic view) front in CAD and architecture, we often display three multiviews plus isometric side top Projection plane parallel to principal face Usually form front, top, side views

  9. Advantages and Disadvantages • Preserves both distances and angles • Shapes preserved • Can be used for measurements • Building plans • Manuals • Cannot see what object really looks like because many surfaces hidden from view • Often we add the isometric

  10. Axonometric Projections classify by how many angles of a corner of a projected cube are the same none: trimetric two: dimetric three: isometric q 1 q 2 q 3 Allow projection plane to move relative to object

  11. Types of Axonometric Projections

  12. Construction of Axonometric Projections Projectors are still orthogonal to the projection plane, but Projection plane can have any orientation w.r.t. the object

  13. Oblique Projection Arbitrary relationship between projectors and projection plane

  14. Perspective Projection Projectors coverge at center of projection

  15. Vanishing Points vanishing point Parallel lines (not parallel to the projection plan) on the object converge at a single point in the projection (the vanishing point) Drawing simple perspectives by hand uses these vanishing point(s)

  16. Three-Point Perspective No principal face parallel to projection plane Three vanishing points for cube

  17. Two-Point Perspective On principal direction parallel to projection plane Two vanishing points for cube

  18. One-Point Perspective One principal face parallel to projection plane One vanishing point for cube

  19. Computer Viewing • There are three aspects of the viewing process, all of which are implemented in the pipeline, • Positioning the camera • Setting the model-view matrix • Selecting a lens • Setting the projection matrix • Clipping • Setting the view volume

  20. Default Projection clipped out z=0 Default projection is orthogonal

  21. Moving the Camera Frame • If we want to visualize object with both positive and negative z values we can either • Move the camera in the positive z direction • Translate the camera frame • Move the objects in the negative z direction • Translate the world frame • Both of these views are equivalent and are determined by the model-view matrix • Want a translation (glTranslatef(0.0,0.0,-d);) • d > 0

  22. Moving Camera Back from Origin frames after translation by –d d > 0 default frames

  23. Moving the Camera (Object) • We can move the camera to any desired position by a sequence of rotations and translations • Example: positive x (side view of an object) • Rotate the camera • Move it away from origin • Model-view matrix C = TR

  24. Manually Generating an Isometric View – 1/3 y y 2 2  z z Rotating about the y axis by 45o Rotating about the x axis by 35.26o Translating along the z direction by d

  25. Manually Generating an Isometric View – 2/3

  26. Manually Generating an Isometric View – 3/3 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0, 0.0, -d); glRotatef(35.26, 1.0, 0.0, 0.0); glRotate(45.0, 0.0, 1.0, 0.0);

  27. The LookAt Function – 1/2 glMatrixMode(GL_MODELVIEW): glLoadIdentity(); gluLookAt(-1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); • The GLU library contains the function glLookAt to from the required modelview matrix through a simple interface • Note the need for setting an up direction • Still need to initialize • Can concatenate with modeling transformations • Example: isometric view of cube aligned with axes

  28. The LookAt Function – 2/2 glLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)

  29. Other Viewing APIs – 1/2 • The LookAt function is only one possible API for positioning the camera • Others include • View reference point, view plane normal, view up (PHIGS, GKS-3D) • Yaw, pitch, roll • Elevation, azimuth, twist • Direction angles

  30. Other Viewing APIs – 2/2

  31. Simple Perspective Center of projection at the origin Projection plane z = d, d < 0

  32. Perspective Equations xp = yp = zp = d Consider top and side views

  33. Homogeneous Coordinate Form consider q = Mp where M =  p = q =

  34. Perspective Division xp = yp = zp = d However w 1, so we must divide by w to return from homogeneous coordinates This perspective division yields the desired perspective equations We will consider the corresponding clipping volume with the OpenGL functions

  35. Orthogonal Projections xp = x yp = y zp = 0 • The default projection in the eye (camera) frame is orthogonal • For points within the default view volume • Most graphics systems use view normalization • All other views are converted to the default view by transformations that determine the projection matrix • Allows use of the same pipeline for all views

  36. Homogeneous Coordinate Representation xp = x yp = y zp = 0 wp = 1 pp = Mp M = In practice, we can letM = Iand set the z term to zero later

  37. Projections in OpenGL

  38. OpenGL Perspective glFrustum(xmin,xmax,ymin,ymax,near,far)

  39. Using Field of View front plane aspect = w/h With glFrustum it is often difficult to get the desired view gluPerpective(fovy, aspect, near, far) often provides a better interface

  40. OpenGL Orthogonal Viewing nearandfarmeasured from camera glOrtho(xmin,xmax,ymin,ymax,near,far) glOrtho(left,right,bottom,top,near,far)

  41. Hidden-Surface Removal

  42. Z-Buffer Algorithm Keep track of the smallest depth or z value for each pixel Z value is initialized to the farthest distance Worst-case time complexity is O(n), where n is the number of polygons glutInitDisplayMode(GLUT_DEPTH);glEnable(GL_DEPTH_TEST);glClear(GL_DEPTH_BUFFER_BIT);

  43. Culling Removing all the faces pointing away from the viewer. For example, rendering n cubes with culling can filter 3n polygons glEnable(GL_CULL);

  44. Parallel-Projection Matrices Orthographic projection of distorted object Perspective View

  45. Normalization Rather than derive a different projection matrix for each type of projection, we can convert all projections to orthogonal projections with the default view volume This strategy allows us to use standard transformations in the pipeline and makes for efficient clipping

  46. Pipeline View modelview transformation projection transformation perspective division 4D  3D nonsingular clipping projection 3D  2D against default cube

  47. Notes • We stay in four-dimensional homogeneous coordinates through both the modelview and projection transformations • Both these transformations are nonsingular • Default to identity matrices (orthogonal view) • Normalization lets us clip against simple cube regardless of type of projection • Delay final projection until end • Important for hidden-surface removal to retain depth information as long as possible

  48. Orthogonal Normalization -1 1 -1 1 -1 1 normalization find transformation to convert specified clipping volume to default Canonical view volume glOrtho(left,right,bottom,top,near,far)

  49. Orthogonal Matrix P = ST = • Two steps • Move center to origin T(-(left+right)/2, -(bottom+top)/2,(near+far)/2)) • Scale to have sides of length 2 S(2/(left-right),2/(top-bottom),2/(near-far))

  50. Final Projection Morth = P = MorthST Set z =0 Equivalent to the homogeneous coordinate transformation Hence, general orthogonal projection in 4D is

More Related