1 / 24

Chapter 3 Viewing

Chapter 3 Viewing. Contents. Overview: The Camera Analogy Viewing and Modeling Transformation Projection Transformation Viewport Transformation. Chapter Objectives . View a geometric model in any orientation Control the location in 3D space Clip Undesired portions of the model.

lore
Télécharger la présentation

Chapter 3 Viewing

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 3 Viewing

  2. Contents • Overview: The Camera Analogy • Viewing and Modeling Transformation • Projection Transformation • Viewport Transformation

  3. Chapter Objectives • View a geometric model in any orientation • Control the location in 3D space • Clip Undesired portions of the model

  4. Overview -The Camera Analogy-

  5. Overview: The Camera Analogy • Viewing Transformation • Positioning the view volume in the world • Modeling Transformation • Positioning models in the world • Projection Transformation • Determining the shape of the view volume • Viewport Transformation

  6. Method for Transformation - 1 • The Viewing Transformation • glTranslatef(); • glRotatef(); • gluLookAt(); • The Modeling Transformation • glTranslatef(); • glRotatef(); • glScalef();

  7. Method for Transformation - 2 • The Projection Transformation • Perspective • Orthographic • Order of Setting • glMatrixMode(types) • glLoadIdentity() • glFrustum() or gluPerspective(), glOrtho()

  8. General-Purpose Transformation Commands • glMatrixMode(GLenum mode) • Specifies which matrix will be modified • GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE • glLoadIdentity() • Sets the currently modifiable matrix to the 4*4 identity matrix

  9. General-Purpose Transformation Commands • glMultMatrix{fd}(const Type *m) • Multiply the current matrix by the matrix passed in as an argument • glLoadMatrix{fd}(const Type *m) • Set the 16 values of the current matrix to those specified by m

  10. Viewing and Modeling Transformations

  11. Thinking about Transformation • To performing viewing or modeling transformation • glMatrixMode(GL_MODELVIEW);

  12. 2 Types of Coordinate System • Example glMatrixMode(GL_MODELVIEW); glloadIdentity(); glMultiMatrixf(N); glMultiMatrixf(M); glBegin(GL_POINTS); glVertex3f(v); glEnd(); • Grand, Fixed Coordinate System • Moving a Local Coordinate System

  13. Modeling Transformation • Translate • Void glTranslate{fd}(x, y, z); • Rotate • Void glRotate{fd}(angle, x, y, z); • Scale • Void glScale{fd}(x, y, z); • glScalef(2.0, -1.5, 1.0);

  14. Viewing Transformation - 1 • glTranslate() or glRotate() • Moving forward camera = Moving Backward Object • gluLookAt() Void gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);

  15. Viewing Transformation - 2 • Creating a Custom Utility Routine Void PilotView(GLdouble planex, Gldouble planey, Gldouble planez, Gldouble roll, Gldouble pitch, Gldouble heading) { glRotated(roll, 0.0, 0.0, 1.0); glRotated(pitch, 0.0, 1.0, 0.0); glRotated(heading, 1.0, 0.0, 0.0); glTranslated(-planex, -planey, -planez); }

  16. Projection Transformations

  17. Projection Transformations • Purpose • To define a viewing volume • How an object is projected onto the screen • How to Clip the object • Setting for projection transformation • glMatrixMode(GL_PROJECTION); • glLoadIdentity();

  18. Perspective Projection - 1 • Foreshortening • The farther, the smaller object appears in the final image • glFrustum(left, right, bottm, top, near, far)

  19. Perspective Projection - 2 • gluPerspective(fov, aspect, near, far)

  20. Orthographic Projection -1 • View Volume • Rectangular parallelepiped

  21. Orthographic Projection -2 • glOrtho(left, right, bottom, top, near, far) • glOrtho2D (left, right, bottom, top)

  22. Viewport Transformation

  23. Defining the Viewport • glViewport(x, y, width, height) gluPerspective(fov, 2.0, near, far); glViewport(0, 0, 400, 200); • The Transformed Depth coordinates

  24. Program Demo • Transformation\lesson1.exe

More Related