1 / 39

Computer Graphics Representation

Basic Issues of 3D Modeling. Given a internal model of a 3D world, with textures and light sources how do you project it on the screen from any perspective fast.Restrictions on geometryRestrictions on viewing perspectiveLots of algorithmsQuestionsHow do I draw on the screen?How should I speci

imogene
Download Presentation

Computer Graphics Representation

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 Representation Until now we have been able to work with geometric entities without using any frame of reference, such a coordinate system Need a frame of reference to relate points and objects to our physical world. For example, where is a point? Can’t answer without a reference system World coordinates Camera coordinates

    2. Basic Issues of 3D Modeling Given a internal model of a 3D world, with textures and light sources how do you project it on the screen from any perspective fast. Restrictions on geometry Restrictions on viewing perspective Lots of algorithms Questions How do I draw on the screen? How should I specify them for lighting and texture?

    3. Overview: simple 3D graphics 3D space Points, Lines, Polygons, and Objects in 3D Coordinate Systems Translation, Scaling, and Rotation in 3D Projections Solid Modeling Hidden-surface removal Painter’s Algorithm Z-Buffering

    4. 3D Space

    5. Points, Lines, Polygons Points: x, y, z Line: two points Polygon: list of vertices, color/texture

    6. Objects Made up of sets of polygons Which are made up of lines Which are made of points No curved surfaces Just a “shell” Not a solid object Everything is a set of points In local coordinate system

    7. Instancing In modeling, we often start with a simple object centered at the origin, oriented with the axis, and at a standard size We apply an instance transformation to its vertices to Scale Orient Locate

    8. Transformations Modeling Viewing orient camera projection Animation Map to screen Transformations are used both by the applications programmer to move and orient objects (either statically or dynamically) and by OpenGL to implement the viewing pipeline. Three transformations (model-view, perspective, texture) are part of the state. Their matrices can be set by application programs but the operations are carried out within the viewing pipeline.Transformations are used both by the applications programmer to move and orient objects (either statically or dynamically) and by OpenGL to implement the viewing pipeline. Three transformations (model-view, perspective, texture) are part of the state. Their matrices can be set by application programs but the operations are carried out within the viewing pipeline.

    9. General Transformations A transformation maps points to other points and/or vectors to other vectors

    10. How many ways? Although we can move a point to a new location in infinite ways, when we move many points there is usually only one way

    11. Object Transformations Since all objects are just sets of points, we just need to translate, scale, rotate the points. To manipulate a 3D point, use matrix multiplication. Translation: [x’ y’ z’ 1] = [x y z 1] | 1 0 0 0 | | 0 1 0 0 | | 0 0 1 0 | | dx dy dz 1 |

    12. Scaling S = S(sx, sy, sz) =

    13. Reflection corresponds to negative scale factors

    14. Rotation (2D) Consider rotation about the origin by q degrees radius stays the same, angle increases by q

    15. Rotation About a Fixed Point other than the Origin Move fixed point to origin Rotate Move fixed point back M = T(-pf) R(q) T(pf)

    16. Rotation Parallel to x-axis [x’ y’ z’ 1] = [x y z 1] | 1 0 0 0 | | 0 cos r sin r 0 | | 0 -sin r cos r 0 | | 0 0 0 1 | Parallel to y-axis [x’ y’ z’ 1] = [x y z 1] | cos r 0 -sin r 0 | | 0 1 0 0 | | sin r 0 cos r 0 | | 0 0 0 1 | Parallel to z-axis [x’ y’ z’ 1] = [x y z 1] | cos r sin r 0 0 | |-sin r cos r 0 0 | | 0 0 1 0 | | 0 0 0 1 |

    17. Three Coordinate Systems World-centered: Where objects are in the world Object-centered: Relative to position of object View-centered: Relative to the position of viewer Simplest case is viewing down z-axis

    18. Coordinate Systems and Transformations Steps in Forming an Image specify geometry (world coordinates) specify camera (camera coordinates) project (window coordinates) map to viewport (screen coordinates) Each step uses transformations Every transformation is equivalent to a change in coordinate systems (frames) Every transformation can be thought of as changing the representation of a vertex from one coordinate system or frame to another. Thus, initially vertices are specified in world or application coordinates. However, to view them, OpenGL must convert these representations to ones in the reference system of the camera. This change of representations is described by a transformation matrix (the model-view matrix). Similarly, the projection matrix converts from camera coordinates to window coordinates.Every transformation can be thought of as changing the representation of a vertex from one coordinate system or frame to another. Thus, initially vertices are specified in world or application coordinates. However, to view them, OpenGL must convert these representations to ones in the reference system of the camera. This change of representations is described by a transformation matrix (the model-view matrix). Similarly, the projection matrix converts from camera coordinates to window coordinates.

    19. Camera Analogy 3D is just like taking a photograph (lots of photographs!) This model has become know as the synthetic camera model. Note that both the objects to be viewed and the camera are three-dimensional while the resulting image is two dimensional.This model has become know as the synthetic camera model. Note that both the objects to be viewed and the camera are three-dimensional while the resulting image is two dimensional.

    20. Moving the Camera If objects are on both sides of z=0, we must move camera frame

    21. Camera Analogy and Transformations Projection transformations adjust the lens of the camera Viewing transformations tripod–define position and orientation of the viewing volume in the world Modeling transformations moving the model Viewport transformations enlarge or reduce the physical photograph Note that human vision and a camera lens have cone-shaped viewing volumes. OpenGL (and almost all computer graphics APIs) describe a pyramid-shaped viewing volume. Therefore, the computer will “see” differently from the natural viewpoints, especially along the edges of viewing volumes. This is particularly pronounced for wide-angle “fish-eye” camera lenses.Note that human vision and a camera lens have cone-shaped viewing volumes. OpenGL (and almost all computer graphics APIs) describe a pyramid-shaped viewing volume. Therefore, the computer will “see” differently from the natural viewpoints, especially along the edges of viewing volumes. This is particularly pronounced for wide-angle “fish-eye” camera lenses.

    22. Projections Mapping a 3D object onto a 2D viewing surface

    23. Projections Parallel If viewing down z-axis, just discard z component Perspective If viewing down z-axis, scale points based on distance. x_screen = x / z y_screen = y / z

    24. Clipping

    25. Testing if Surface is Visible

    26. Ray Tracing Image space technique that mimics physical processes of light Extremely computationally intensive, but beautiful Hidden surface removal Transparency Reflections Refraction Ambient lighting Point source lighting Shadows

    27. Shading Compute lighting based on angle of light on polygon surface.

    28. Gouraud Shading Compute shading for each pixel by averaging shading based on distance and shading of vertices.

    29. Transparency Use an extra set of bits to determine transparency Alpha Blend present value of the color buffer with new values.

    30. Texture Mapping Apply stored bit map to a surface Average textels covered by pixel image

    31. 3D Collision Detection Can’t be done in image space Usually use hierarchical approach First find objects in same 3D cells Second test for overlaps in bounding sphere or box Third Good enough! Check for polygon collisions Accurate 3D collision detection is very expensive

    32. Programming Transformations Prior to rendering, view, locate, and orient: eye/camera position 3D geometry Manage the matrices including matrix stack Combine (composite) transformations Because transformation matrices are part of the state, they must be defined prior to any vertices to which they are to apply. In modeling, we often have objects specified in their own coordinate systems and must use OpenGL transformations to bring the objects into the scene. OpenGL provides matrix stacks for each type of supported matrix (model-view, projection, texture) to store matrices.Because transformation matrices are part of the state, they must be defined prior to any vertices to which they are to apply. In modeling, we often have objects specified in their own coordinate systems and must use OpenGL transformations to bring the objects into the scene. OpenGL provides matrix stacks for each type of supported matrix (model-view, projection, texture) to store matrices.

    33. other calculations here material č color shade model (flat) polygon rendering mode polygon culling clipping Transformation Pipeline The depth of matrix stacks are implementation-dependent, but the Modelview matrix stack is guaranteed to be at least 32 matrices deep, and the Projection matrix stack is guaranteed to be at least 2 matrices deep. The material-to-color, flat-shading, and clipping calculations take place after the Modelview matrix calculations, but before the Projection matrix. The polygon culling and rendering mode operations take place after the Viewport operations. There is also a texture matrix stack, which is outside the scope of this course. It is an advanced texture mapping topic. The depth of matrix stacks are implementation-dependent, but the Modelview matrix stack is guaranteed to be at least 32 matrices deep, and the Projection matrix stack is guaranteed to be at least 2 matrices deep. The material-to-color, flat-shading, and clipping calculations take place after the Modelview matrix calculations, but before the Projection matrix. The polygon culling and rendering mode operations take place after the Viewport operations. There is also a texture matrix stack, which is outside the scope of this course. It is an advanced texture mapping topic.

    34. Viewing Transformations Position the camera/eye in the scene place the tripod down; aim camera To “fly through” a scene change viewing transformation and redraw scene gluLookAt() multiplies itself onto the current matrix, so it usually comes after glMatrixMode(GL_MODELVIEW) and glLoadIdentity(). Because of degenerate positions, gluLookAt() is not recommended for most animated fly-over applications. An alternative is to specify a sequence of rotations and translations that are concatenated with an initial identity matrix. Note: that the name modelview matrix is appropriate since moving objects in the model front of the camera is equivalent to moving the camera to view a set of objects.gluLookAt() multiplies itself onto the current matrix, so it usually comes after glMatrixMode(GL_MODELVIEW) and glLoadIdentity(). Because of degenerate positions, gluLookAt() is not recommended for most animated fly-over applications. An alternative is to specify a sequence of rotations and translations that are concatenated with an initial identity matrix. Note: that the name modelview matrix is appropriate since moving objects in the model front of the camera is equivalent to moving the camera to view a set of objects.

    35. Connection: Viewing and Modeling Moving camera is equivalent to moving every object in the world towards a stationary camera Viewing transformations are equivalent to several modeling transformations Instead of gluLookAt(, one can use the following combinations of glTranslate() and glRotate() to achieve a viewing transformation. Like gluLookAt(), these transformations should be multiplied onto the ModelView matrix, which should have an initial identity matrix. To create a viewing transformation in which the viewer orbits an object, use this sequence (which is known as “polar view”): glTranslated(0, 0, -distance) glRotated(-twist, 0, 0, 1) glRotated(-incidence, 1, 0, 0) glRotated(azimuth, 0, 0, 1) To create a viewing transformation which orients the viewer (roll, pitch, and heading) at position (x, y, z), use this sequence (known as “pilot view”): glRotated(roll, 0, 0, 1) glRotated(pitch, 0, 1, 0) glRotated(heading, 1, 0, 0) glTranslated(-x, -y, -z) Instead of gluLookAt(, one can use the following combinations of glTranslate() and glRotate() to achieve a viewing transformation. Like gluLookAt(), these transformations should be multiplied onto the ModelView matrix, which should have an initial identity matrix. To create a viewing transformation in which the viewer orbits an object, use this sequence (which is known as “polar view”): glTranslated(0, 0, -distance) glRotated(-twist, 0, 0, 1) glRotated(-incidence, 1, 0, 0) glRotated(azimuth, 0, 0, 1) To create a viewing transformation which orients the viewer (roll, pitch, and heading) at position (x, y, z), use this sequence (known as “pilot view”): glRotated(roll, 0, 0, 1) glRotated(pitch, 0, 1, 0) glRotated(heading, 1, 0, 0) glTranslated(-x, -y, -z)

    36. Pipeline Implementation v

    37. Solid Modeling Which surfaces should be drawn? Object space methods Hidden Surface Removal Painters Algorithm BSP Trees Image space methods Z-Buffering Ray Casting

    38. Projection Tutorial The RIGHT mouse button controls different menus. The screen-space view menu allows you to choose different models. The command-manipulation menu allows you to select different projection commands (including glOrtho and glFrustum).The RIGHT mouse button controls different menus. The screen-space view menu allows you to choose different models. The command-manipulation menu allows you to select different projection commands (including glOrtho and glFrustum).

    39. Transformation Tutorial For right now, concentrate on changing the effect of one command at a time. After each time that you change one command, you may want to reset the values before continuing on to the next command. The RIGHT mouse button controls different menus. The screen-space view menu allows you to choose different models. The command-manipulation menu allows you to change the order of the glTranslatef() and glRotatef() commands. Later, we will see the effect of changing the order of modeling commands.For right now, concentrate on changing the effect of one command at a time. After each time that you change one command, you may want to reset the values before continuing on to the next command. The RIGHT mouse button controls different menus. The screen-space view menu allows you to choose different models. The command-manipulation menu allows you to change the order of the glTranslatef() and glRotatef() commands. Later, we will see the effect of changing the order of modeling commands.

    40. Objectives Introduce standard transformations Rotations Translation Scaling Derive homogeneous coordinate transformation matrices Learn to build arbitrary transformation matrices from simple transformations

More Related