Presentation is loading. Please wait.

Presentation is loading. Please wait.

242-515 AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.

Similar presentations


Presentation on theme: "242-515 AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development."— Presentation transcript:

1 242-515 AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development 242-515, Semester 1, 2014-2015 5. Game Architecture

2 242-515 AGD: 5. Game Arch.2 1.Simple Game Architecture 2.More Detailed Game Architecture 3.Graphics/Rendering 4.Game Programming Overview

3 1. Simple Game Architecture 3

4 I will focus on the graphics and maths techniques used inside the "Rendering Engine" box. These include: o basic 3D graphics theory o 3D graphics programming with the JMonkeyEngine game engine o 3D rendering algorithms underlying 3D game engines o shader programming (maybe) 4

5 242-515 AGD: 5. Game Arch.5 2. More Detailed Game Architecture

6 242-515 AGD: 5. Game Arch.6 Elements used in most games: o startup and shutdown o file IO (loaders, writers, datafile parsers) o input controls (keyboard, mouse, touch) o window management minimize, maximize, full-screen, resolution o maths (e.g. vectors, matrices) o data structures (e.g. linked lists) In JMonkeyEngine, many of these come from the standard Java libraries 2.1. Core Systems

7 242-515 AGD: 5. Game Arch.7 These can be separated into game media (stuff visible to the player) and data resources (data used internally by the game). 2.2. Resources (Assets) Data Resources: o user settings player items high score table o game settings fonts physics map o platform settings graphics and audio capabilities Media Resources: o images / textures o audio o video o shaders o 3D models

8 242-515 AGD: 5. Game Arch.8 The game engine will often reuse existing libraries: o GUI (in JMonkeyEngine (JME): Nifty GUI) o Physics (in JME: jBullet, a Java port of the Bullet Physics library) o skeletons (in JME: support for Blender joints) o AI o visual effects( in JME: OpenGL shaders, particle system) o terrain (in JME: the Ogre3D dotScene format) o scene graph (so important, that it's a part of the core in JME) 2.3. Third-Party Libraries

9 242-515 AGD: 5. Game Arch.9 A scene graph stores all the entities or objects in the scene, and the spatial relationship between them. 2.4. What is a Scene Graph?

10 242-515 AGD: 5. Game Arch.10 The scene graph data structure simplifies the creation of a scene by the user, and also: o makes it easier to transform groups of objects e.g. translate, rotate them o makes it easier to determine when objects are colliding and are visible to each other o makes it easier to display a scene with different Levels of Detail (LOD)

11 242-515 AGD: 5. Game Arch.11 Particles o smoke, fire, explosions, etc. Post processing / filter effects o reflective water, light scattering, fog o shadow mapping o High Dynamic Range (HDR) rendering increased contrast for greater detail o ambient occlusion (blocking) o depth of field blur o etc. 2.5. Visual Effects (in JME)

12 242-515 AGD: 5. Game Arch.12 Java binding to the Bullet physics library o a collision detection and rigid body dynamics library http://bulletphysics.org/wordpress/ Features include: o collisions, gravity, forces o mesh-accurate collision shapes o rigid body dynamics for vehicles and characters o physical joints and hinges o Blender integration o Ragdoll physics o Multi-threaded physics 2.6. Physics (in JME)

13 3. Graphics/Rendering Almost every game engine utilizes either OpenGL or DirectX for its graphics processing and rendering. JMonkeyEngine uses OpenGL. http://msdn.microsoft.com/en-US/directxhttp://www.opengl.org/

14 3.1. OpenGL A hardware-independent API, implemented on many different platforms. Several hundred functions, with many language bindings. An accepted industry standard: evolves slowly currently at version 4.2 Widely used for: games, modeling, scientific visualization, etc. 14

15 3.2. DirectX DirectX is a Microsoft API providing direct access to hardware. Only for Windows, currently at version 11.1 DirectX components: o Direct Graphics – 2D and 3D graphics o DirectInput – interface to input devices o DirectAudio – play sound and music o DirectPlay – communication across networks o DirectShow – multimedia support 15

16 3.3. OpenGL vs. DirectX OpenGL is aimed at 3D graphics only; DirectX is a more complete game development API. OpenGL is portable across platforms; DirectX is only for Windows. 16

17 3.4. What is Rendering? Rendering is the process of converting a 3D scene into a 2D picture (raster image) on the computer screen: o The 3D scene is composed of 3D models (geometries). o A model is composed of 3D graphics primitives o e.g. triangles, quadrilaterals 17 render

18 242-515 AGD: 5. Game Arch.18 4. Game Programming Most games consist of an startup phase, a game loop, and a shutdown phase: A game loop consists of three stages:

19 4.1. A Detailed Game Flowchart Read player input Update game state, using: Collision Detection, Game AI, Physics, etc Shutdown: store scores close files game over? Initialization: Load assets Load levels … Start Display Startup GUI Render (draw) game frame End

20 242-515 AGD: 5. Game Arch.20 An important element missing from the basic game loop is the need to keep the rate of frame drawing constant. A frame rate is the average number of frames drawn by the game loop each second. Typical frame rates: o 30 fps (i.e. 30 frames drawn in 1 second) o 50 fps The frame rate should stay constant so that the user sees the game updating at a fixed rate. 4.2. Frame Rates

21 242-515 AGD: 5. Game Arch.21 The frame rate should be the same on fast and slow computers. The problem is that a fast machine will carry out "updating" and "rendering" faster than a slow machine, and so the frame rate will be faster. We must change the game loop so that the frame rate isn't affected by a computer's speed. 4.3. Frame Rate Problem

22 242-515 AGD: 5. Game Arch.22 One way to fix this speed problem is to add a "wait" stage in the loop: delays the loop so the frame rate is not too fast UpdateStartupInput RenderWait Shutdown stop run game loop

23 242-515 AGD: 5. Game Arch.23 Waiting deals with a loop that is too fast, but what about a loop that is too slow? o e.g. because the computer is slow One solution is to skip the rendering (drawing) stage, making the loop faster: UpdateStartupInput RenderWait Shutdown stop run game loop Do we have extra time? yes no

24 242-515 AGD: 5. Game Arch.24 The good news is that JMonkeyEngine deals with maintaining a constant frame rate. We only have to write the "update" code for the loop, not the "rendering" or timing parts, which are dealt with by the engine.


Download ppt "242-515 AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development."

Similar presentations


Ads by Google