Topics from Graphics 1
Total Page:16
File Type:pdf, Size:1020Kb
Topics from Graphics 1 Image taken from http://www.felixgers.de/teaching/game/game-modules-talk/GameEngineAndModules.html 1 Synthetic Camera Model Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 2 Camera Specification Six degrees of freedom Position of center of lens (COP) Orientation Lens – focal length Film size (h,w) Orientation of film plane Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 3 LookAt Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 4 Perspective Frustum: a truncated pyramid Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 5 and slightly modified Using Field of View front plane fovy – angle in up direction aspect = w/h Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 6 Clipping Just as a real camera cannot “see” the whole world, the virtual camera can only see part of the world or object space Objects that are not within this view volume are said to be clipped out of the scene Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 7 Projection Projection: from 3D objects to 2D image Perspective projections: all projectors meet at the center of projection Parallel (orthogonal) projection: projectors are parallel, center of projection is replaced by a direction of projection 8 Orthogonal Viewing Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 9 and slightly modified Texture Mapping Image copied from http://blog.tartiflop.com/2008/11/first-steps-in-away3d-part-3-texture-mapping/ 10 Mapping a Texture A function f(u,v)=(x ,y ,z ) defines (u,v) (u,v) (u,v) the object position of each pixel in the texture, see this. The color of each pixel is the color of the point (u,v) of the texture. Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/ 11 Texture Mapping General Triangles When the triangle does not fit properly on the texture, one has to use interpolation to determine the color associate with the a point on the object. This is done automatically by graphic systems. All one needs to give are the (u,v) coordinates of the vertices. For the upper triangle counterclockwise from lower left they are (0,0), (1,1), (0,1). The counterclockwise order is used in right hand coordinate systems, like Ogre and Opengl. DirectX and Unity uses a left hand system Most graphic systems will let one map textures to quadrilaterals, in that case the texture coordinate are (0,0), (1,0), (1,1), (0,1) counterclockwise from lower left. 12 Texture Mapping and the Hardware Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect geometric complexity vertices Vertex shader rasterizer image Fragment shader 13 Planet Earth-Picture Images copied from http://www.3dstudio-max.com/textures/images/earth.jpg 14 Example-Planet Earth 3D 15 Planet Earth-Mesh Use Spherical Coordinates to determine the mesh coordinates 16 Planet Earth-Mapping 17 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw surfaces. When textures are attached to the quadrilaterals or triangle the surface appears solid. See Ogre Mesh Class, Describing a mesh Dynamically generating a mesh for information on how Ogre reads and stores meshes Images copied from http://www.codesampler.com/d3dbook/chapter_05/chapter_05_files/image001.jpg 18 Ogre Camera and Textures Ogre camera class, http://www.ogre3d.org/docs/api/1.9/class_ogre_1_1_camera.html Ogre Third Person Camera http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Simple+3rd+person+camera Ogre First Person Camera http://www.ogre3d.org/tikiwiki/Creating+a+simple+first-person+camera+system Ogre Texture http://www.ogre3d.org/tikiwiki/-Texture 19 Scene Graph In unity each object has a transformation and can include other objects and meshes. Together these produce the scene graph for the scene. Images copied from http://wiki.jmonkeyengine.org/doku.php/jme3:the_scene_graph 20.