1 / 33

Computer Graphics: Programming, Problem Solving, and Visual Communication

Computer Graphics: Programming, Problem Solving, and Visual Communication. Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource. Viewing and Projection. Making an image from a scene. Creating an Image from a Scene.

oriana
Télécharger la présentation

Computer Graphics: Programming, Problem Solving, and Visual Communication

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. Computer Graphics:Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

  2. Viewing and Projection Making an image from a scene

  3. Creating an Image from a Scene • Computer graphics has three main functions • Modeling, where you define a scene • Viewing and projection, where you define how the scene is to be seen • Rendering, where the model and view are translated into an image • In this chapter, we assume a scene has been modeled and we discuss how you define the way it is seen

  4. Two Main Parts • There are two main parts of defining how a scene is to be seen • Viewing, where you place the observer in the scene • Projection, where you specify how the observer’s view is created • This chapter covers both parts

  5. This is Part of the Geometry Pipeline • Modeling creates the scene in world coordinates, and this chapter covers the part of the pipeline shown here

  6. Specifying a View • To specify an image, you place the observer in the world with specific information • The location of the observer • The direction the observer is looking • The orientation of the observer • The breadth of field of the observer • The aspect ratio of the observer • The first three of these are viewing; the last two are part of projection • For the projection part, the observer must be looking through some sort of frame

  7. Half dome from the valley floor Half dome from the Glacier Point lookout Two Similar Views

  8. These Half Dome Views… • Are from different viewpoints • Are looking in slightly different directions • Have slightly different field of view • Valley floor is narrower (more zoomed in) • Glacier Point is wider (more zoomed out) • Have the same orientation (conventional up direction) and aspect ratio (1:1)

  9. How Do We Specify a View? • There are two parts to the specification • The viewing specification places the observer • The projection specifies the frame • Most graphics systems, including OpenGL, have you specify them separately because they operate independently

  10. A view of world space that includes a model and an observer The view of the object in the world as seen by the observer A Viewing Example

  11. For Viewing, You Define… • The eye point, which is the position of the observer • The “look-at” point or view reference point, which defines the direction the observer is looking • The up vector, which defines the orientation of the observer (in world space)

  12. The eye coordinates are left-handed! You specify the eyepoint You specify the view reference point, giving you the z-direction You specify the y-direction with the up vector The x-direction is computed as a cross product The Standard Viewing Model

  13. For Projection, You Define… • The type of projection • Perspective • Orthographic • The width of your viewing space • The height of your viewing space OR the aspect ratio of your viewing space • The front and back of your viewing volume

  14. Perspective view Orthographic view Perspective or Orthographic?

  15. Perspective or Orthographic (2) • Perspective views are more realistic (see the figure) • Orthographic views are standard in some engineering areas and give you accurate relative measurements

  16. Types of Perspective • One-point • Two coordinate directions parallel to view plane • Two-point • One coordinate direction parallel to view plane • Three-point • No coordinate direction parallel to view plane

  17. View Volumes • The region in world space that is seen with perspective (left) or orthographic (right) projections

  18. View Volumes in a Scene

  19. Clipping on the View Volume • Clipping is the process of determining what lies outside the view volume and removing that before it is processed • Six clipping planes to the left, right, top, bottom, front, and back of the volume

  20. Clipping… • Removes objects that lie entirely outside the volume (e.g. some of the trees) • Reworks each object that lies partly in and partly outside the volume • Line segments (left) or polygon (right)

  21. Field of View in Perspective Projections • Acts like defining the focal length of a camera -- wide angle (left) to telephoto (right)

  22. Drawing to a Viewport • A viewport is a rectangular region in the window to which you can draw • Default viewport is the entire window • You can define a smaller viewport so all drawing is restricted to that region • You can use separate modeling for each viewport

  23. Mapping to Screen Space • The final step in the geometry pipeline is mapping the image to screen space • The points in the viewing volume are projected to the viewplane at the front of the volume • This converts them to 2D points in the space

  24. Mapping to Screen Space (2) • The points in the 2D real space are then converted to 2D integer space by a simple proportional process, followed by a roundoff • These 2D integer points are vertex coordinates in the screen • Now ready for the rendering process

  25. Managing the View:Hidden Surfaces • An understandable 3D image scene needs to show some things in front of others • A graphics program simply draws things as you define them • You need a way to keep track of things in depth order

  26. Managing the View:Hidden Surfaces (2) • One way is for you to keep track of the depth of each object and draw them back to front (farthest to nearest) • This is the Painter’s Algorithm • A graphics system can provide a way to keep track of things in depth order • Depth buffering tracks this for each pixel and only shows those that are in front

  27. Managing the View:Double Buffering • Your program draws the objects you define one by one • It can take some time for the image of a complex scene to be drawn • In order to show only the completed scene, you can use double buffering • The image is drawn to the back buffer and then this is swapped to the front buffer for display

  28. Managing the View:Stereo Viewing • There are a number of ways to get a stereo view, but one is easy to do at this point • Divide your window into two viewports • Draw a scene twice in the separate viewports with eye points approximating a viewer’s eye locations

  29. Viewing and Projection in OpenGL • How you define a view • How you define a projection

  30. Viewing • Default view has the eye at the origin, looking at the point (0, 0, -1), with the up vector the y-axis • You can change this with the functions glMatrixMode( GL_MODELVIEW );glLoadIdentity();gluLookAt( eyex, eyey, eyez, lookatx, lookaty, lookatz, upx,upy,upz ) • There are times when you will want to use the default view

  31. The Perspective Projection • Default OpenGL approach is through the glFrustum function; this is difficult • More usual approach is through the functions glMatrixMode(GL_PROJECTION );glLoadIdentity();gluPerspective( view_angle, aspect_ratio, front, back );

  32. The Orthographic Projection • The orthgonal projection uses a much simpler view volume and is defined by specifying that volumeglMatrixMode( GL_PROJECTION )glLoadIdentity()glOrtho( left, right, bottom, top, near, far )

  33. Other Features • glutInit(GLUT_DEPTH | GLUT_DOUBLE …) • Depth testing • glEnable(GL_DEPTH_TEST) • Double buffering • glutSwapBuffers() • Stereo viewing • draw into separate viewports that enable eye conversion • other techniques discussed later

More Related