Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of...
Transcript of Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of...
1
Topics from Graphics 1
Image taken fromhttp://www.felixgers.de/teaching/game/game-modules-talk/GameEngineAndModules.html
2
Synthetic Camera Model
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
3
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/
4
LookAt
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
5
PerspectiveFrustum: a truncated pyramid
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
and slightly modified
6
Using Field of View
fovy – angle in up directionaspect = w/h
front plane
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
7
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/
8
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
9
Orthogonal Viewing
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
and slightly modified
10
Texture Mapping
Image copied fromhttp://blog.tartiflop.com/2008/11/first-steps-in-away3d-part-3-texture-mapping/
11
A function f(u,v)=(x(u,v)
,y(u,v)
,z(u,v)
) defines the object position of each pixel in the texture, see this. The color of each pixelis the colorof the point(u,v) of thetexture.
Mapping a Texture
Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/
12
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.
13
Texture Mapping and the Hardware
Vertex shadervertices
Fragment shaderimagerasterizer
Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect geometric
complexity
14
Planet Earth-Picture
Images copied from http://www.3dstudio-max.com/textures/images/earth.jpg
15
Example-Planet Earth 3D
16
Planet Earth-Mesh
Use Spherical Coordinates to determine the mesh coordinates
17
Planet Earth-Mapping
18
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.
SeeOgre Mesh Class, Describing a mesh
Dynamically generating a mesh
for information onhow Ogre reads andstores meshes
Images copied from http://www.codesampler.com/d3dbook/chapter_05/chapter_05_files/image001.jpg
19
Ogre Camera and Textures
Ogre camera class, http://www.ogre3d.org/docs/api/1.9/class_ogre_1_1_camera.html
Ogre Third Person Camerahttp://www.ogre3d.org/tikiwiki/tiki-index.php?page=Simple+3rd+person+camera
Ogre First Person Camerahttp://www.ogre3d.org/tikiwiki/Creating+a+simple+first-person+camera+system
Ogre Texturehttp://www.ogre3d.org/tikiwiki/-Texture
20
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