Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of...

20
1 Topics from Graphics 1 Image taken from http://www.felixgers.de/teaching/game/game-modules-talk/GameEngineAndModules.html

Transcript of Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of...

Page 1: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

1

Topics from Graphics 1

Image taken fromhttp://www.felixgers.de/teaching/game/game-modules-talk/GameEngineAndModules.html

Page 2: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

2

Synthetic Camera Model

Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/

Page 3: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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/

Page 4: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

4

LookAt

Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/

Page 5: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

5

PerspectiveFrustum: a truncated pyramid

Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/

and slightly modified

Page 6: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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/

Page 7: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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/

Page 8: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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

Page 9: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

9

Orthogonal Viewing

Images copied from http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/ART/

and slightly modified

Page 10: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

10

Texture Mapping

Image copied fromhttp://blog.tartiflop.com/2008/11/first-steps-in-away3d-part-3-texture-mapping/

Page 11: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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/

Page 12: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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.

Page 13: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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

Page 14: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

14

Planet Earth-Picture

Images copied from http://www.3dstudio-max.com/textures/images/earth.jpg

Page 15: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

15

Example-Planet Earth 3D

Page 16: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

16

Planet Earth-Mesh

Use Spherical Coordinates to determine the mesh coordinates

Page 17: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

17

Planet Earth-Mapping

Page 18: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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

Page 19: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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

Page 20: Topics from Graphics 1 - Kentruttan/GameEngines/lectures/ogreCamera.pdf18 Meshes A mesh of quadrilaterals as shown in the last slide or a mesh of triangles is used in graphics to draw

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