140 likes | 378 Views
The Camera Analogy. Set up your tripod and point the camera at the scene (viewing transformation) Arrange the scene to be photographed into the desired composition (modeling transformation) Choose a camera lens or adjust the zoom (projection transformation)
E N D
The Camera Analogy • Set up your tripod and point the camera at the scene (viewing transformation) • Arrange the scene to be photographed into the desired composition (modeling transformation) • Choose a camera lens or adjust the zoom (projection transformation) • Determine how large you want the final photograph to be (viewport transformation)
Computer Steps • Viewing (Positioning the viewing volume in the world – moving the position and orientation of the eye) • Modeling (Positioning the models in the world – translate, scale, rotate) • Projection (Determine the shape of the view volume) • Viewport (Deciding how large/small you want the final photograph to be)
Stages of Vertex Transformation • The viewing and modeling transformations you specify are combined to form the modelview matrix. • The modelview matrix is applied to the incoming object coordinates to yield eye coordinates • Next, OpenGL applies the projection matrix to yield clip coordinates. This transformation defines a viewing volume and objects outside this volume are clipped so that they are not drawn in the final scene.
Stages of Vertex Transformation • If a perspective projection is being performed, a perspective division is done by dividing coordinates by w to produce normalized device coordinates. • Finally, the transformed coordinates are converted to window coordinates by applying the viewport transformation. You can manipulate the dimensions of the viewport to cause the final image to be enlarged, shrunk, or stretched.
The Viewing Transformation • Positioning the view volume in the world • Achieved in OpenGL by glMatrixMode (GL_MODELVIEW); glLoadIdentity() gluLookAt (eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);
Viewing: gluLookAT • Takes 9 GLdouble arguments • (eyex, eyey, eyez) is the position of the eye or the viewpoint. • (centerx, centery, centerz) specifies some point along the desired line of site, but typically specifies some point in the center of the scene being looked at. • (upx, upy, upz) arguments indicate which direction is up (that is the direction from the bottom to the top of the viewing volume).
Modeling • glTranslate*() to move objects in the world • glScale*() to resize objects in the world • glRotate*() to rotate objects in the world • Actually gluLookAt() encapsulates several OpenGL commands – specifically glTranslate*() and glRotate*().
Projection • Specify the view volume • We will start with an orthographic projection • The view volume will be a rectangular parallelpiped, or more informally, a box. • Distance from the camera will not affect how large an object appears. • Used in applications where it is crucial to maintain actual sizes of objects & angles
glOrtho() • Creates an orthographic parallel viewing volume. glOrtho (left, right, bottom, top, near, far); (left, bottom, -near) and (right, top, -near) are points on the near clipping plane. (left, bottom, -far) and (right, top, -far) are points on the far clipping plane.