14
The Camera Analogy The Camera Analogy Set up your tripod and point the Set up your tripod and point the camera at the scene (viewing camera at the scene (viewing transformation) transformation) Arrange the scene to be photographed Arrange the scene to be photographed into the desired composition (modeling into the desired composition (modeling transformation) transformation) Choose a camera lens or adjust the Choose a camera lens or adjust the zoom (projection transformation) zoom (projection transformation) Determine how large you want the final Determine how large you want the final photograph to be (viewport photograph to be (viewport transformation) transformation)

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

Embed Size (px)

Citation preview

Page 1: 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

The Camera AnalogyThe Camera Analogy

►Set up your tripod and point the camera Set up your tripod and point the camera at the scene (viewing transformation)at the scene (viewing transformation)

►Arrange the scene to be photographed Arrange the scene to be photographed into the desired composition (modeling into the desired composition (modeling transformation)transformation)

►Choose a camera lens or adjust the zoom Choose a camera lens or adjust the zoom (projection transformation)(projection transformation)

►Determine how large you want the final Determine how large you want the final photograph to be (viewport photograph to be (viewport transformation)transformation)

Page 2: 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
Page 3: 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

Computer StepsComputer Steps

►Viewing (Positioning the viewing Viewing (Positioning the viewing volume in the world – moving the volume in the world – moving the position and orientation of the eye)position and orientation of the eye)

►Modeling (Positioning the models in Modeling (Positioning the models in the world – translate, scale, rotate)the world – translate, scale, rotate)

►Projection (Determine the shape of the Projection (Determine the shape of the view volume)view volume)

►Viewport (Deciding how large/small Viewport (Deciding how large/small you want the final photograph to be)you want the final photograph to be)

Page 4: 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
Page 5: 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

Stages of Vertex Stages of Vertex TransformationTransformation

► The viewing and modeling transformations The viewing and modeling transformations you specify are combined to form the you specify are combined to form the modelview matrix.modelview matrix.

► The modelview matrix is applied to the The modelview matrix is applied to the incoming object coordinates to yield incoming object coordinates to yield eye eye coordinatescoordinates

► Next, OpenGL applies the projection matrix Next, OpenGL applies the projection matrix to yield to yield clip coordinates. clip coordinates. This This transformation defines a viewing volume transformation defines a viewing volume and objects outside this volume are clipped and objects outside this volume are clipped so that they are not drawn in the final scene.so that they are not drawn in the final scene.

Page 6: 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

Stages of Vertex Stages of Vertex TransformationTransformation

► If a perspective projection is being If a perspective projection is being performed, a performed, a perspective divisionperspective division is done by is done by dividing coordinates by w to produce dividing coordinates by w to produce normalized device coordinatesnormalized device coordinates..

► Finally, the transformed coordinates are Finally, the transformed coordinates are converted to converted to window coordinateswindow coordinates by by applying the viewport transformation. You applying the viewport transformation. You can manipulate the dimensions of the can manipulate the dimensions of the viewport to cause the final image to be viewport to cause the final image to be enlarged, shrunk, or stretched.enlarged, shrunk, or stretched.

Page 7: 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

Stages of Vertex Stages of Vertex TransformationTransformation

Page 8: 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

The Viewing TransformationThe Viewing Transformation

►Positioning the view volume in the worldPositioning the view volume in the world►Achieved in OpenGL byAchieved in OpenGL by glMatrixMode (GL_MODELVIEW);glMatrixMode (GL_MODELVIEW); glLoadIdentity()glLoadIdentity() gluLookAt (eyex, eyey, eyez,gluLookAt (eyex, eyey, eyez, centerx, centery, centerz,centerx, centery, centerz, upx, upy, upz);upx, upy, upz);

Page 9: 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

Viewing: gluLookATViewing: gluLookAT

►Takes 9 GLdouble arguments Takes 9 GLdouble arguments (eyex, eyey, eyez) is the position of the (eyex, eyey, eyez) is the position of the

eye or the viewpoint.eye or the viewpoint. (centerx, centery, centerz) specifies some (centerx, centery, centerz) specifies some

point along the desired line of site, but point along the desired line of site, but typically specifies some point in the typically specifies some point in the center of the scene being looked at.center of the scene being looked at.

(upx, upy, upz) arguments indicate which (upx, upy, upz) arguments indicate which direction is up (that is the direction from direction is up (that is the direction from the bottom to the top of the viewing the bottom to the top of the viewing volume).volume).

Page 10: 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

ModelingModeling

►glTranslate*() to move objects in the glTranslate*() to move objects in the worldworld

►glScale*() to resize objects in the worldglScale*() to resize objects in the world►glRotate*() to rotate objects in the worldglRotate*() to rotate objects in the world►Actually gluLookAt() encapsulates Actually gluLookAt() encapsulates

several OpenGL commands – several OpenGL commands – specifically glTranslate*() and specifically glTranslate*() and glRotate*().glRotate*().

Page 11: 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

ProjectionProjection

►Specify the view volumeSpecify the view volume►We will start with an orthographic We will start with an orthographic

projectionprojection►The view volume will be a rectangular The view volume will be a rectangular

parallelpiped, or more informally, a box.parallelpiped, or more informally, a box.►Distance from the camera will not affect Distance from the camera will not affect

how large an object appears.how large an object appears.►Used in applications where it is crucial to Used in applications where it is crucial to

maintain actual sizes of objects & anglesmaintain actual sizes of objects & angles

Page 12: 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

Orthographic ProjectionOrthographic Projection

Page 13: 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

glOrtho()glOrtho()

►Creates an orthographic parallel Creates an orthographic parallel viewing volume.viewing volume.

glOrtho (left, right, bottom,glOrtho (left, right, bottom,

top, near, far);top, near, far);(left, bottom, -near)(left, bottom, -near) and and (right, top, -near)(right, top, -near)

are points are points on the near clipping on the near clipping plane.plane.

(left, bottom, -far)(left, bottom, -far) and and (right, top, -far)(right, top, -far) are points are points on the far clipping plane.on the far clipping plane.

Page 14: 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

Viewport TransformationViewport Transformation