On classroom etiquette On classroom etiquette Please, silence your - - PDF document

on classroom etiquette on classroom etiquette
SMART_READER_LITE
LIVE PREVIEW

On classroom etiquette On classroom etiquette Please, silence your - - PDF document

Game Engine Architecture Game Engine Architecture Spring 2017 Spring 2017 0. Introduction and overview 0. Introduction and overview 0. Introduction and overview 0. Introduction and overview Juha Vihavainen Juha Vihavainen University of


slide-1
SLIDE 1

Game Engine Architecture Game Engine Architecture Spring 2017 Spring 2017

  • 0. Introduction and overview
  • 0. Introduction and overview
  • 0. Introduction and overview
  • 0. Introduction and overview

Juha Vihavainen Juha Vihavainen University of Helsinki University of Helsinki [Gregory, Chapter 1. [Gregory, Chapter 1. Introduction, pp. 3 Introduction, pp. 3 - 62 62 ] ] [McShaffry, Chapter 2. [McShaffry, Chapter 2. What's in a Game What's in a Game ]

On classroom etiquette On classroom etiquette

  • Please, silence your cell phone while in class.

Please, silence your cell phone while in class.

  • Please, do not take or make phone calls in class.

Please, do not take or make phone calls in class.

  • Please, do not keep up discussions among each

Please, do not keep up discussions among each

  • ther during lectures
  • ther during lectures
  • really, the lectures are voluntary and ongoing

really, the lectures are voluntary and ongoing

2

  • really, the lectures are voluntary and ongoing

really, the lectures are voluntary and ongoing discussions disturb others wishing to listen discussions disturb others wishing to listen

  • but, of course, do ask me questions . .

but, of course, do ask me questions . .

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-2
SLIDE 2

Preliminary course outline Preliminary course outline

  • Game engine subsystems and its general architecture

Game engine subsystems and its general architecture

  • Large

Large-scale C++ techniques in a games context scale C++ techniques in a games context

  • C++11/14 features (for "modern" C++ programming)

C++11/14 features (for "modern" C++ programming)

  • essential C++ programming techniques

essential C++ programming techniques

  • logical modularity (concepts) vs. physical modularity (files)

logical modularity (concepts) vs. physical modularity (files)

  • n programming standards and C++ style rules
  • n programming standards and C++ style rules
  • Simplified engine and component cases

Simplified engine and component cases

3

  • Simplified engine and component cases

Simplified engine and component cases

  • Miscellanous game technology, tools, and techniques

Miscellanous game technology, tools, and techniques

  • Game engine subsystems: rendering, physics, audio, scripting..

Game engine subsystems: rendering, physics, audio, scripting..

  • . . .

. . .

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

Course prerequisites Course prerequisites

  • General maturity in programming

General maturity in programming

  • bject
  • bject-oriented concepts, data structures, etc.
  • riented concepts, data structures, etc.
  • use of programming environments, and programming

use of programming environments, and programming experience.. experience..

  • Some knowledge of C++ is required

Some knowledge of C++ is required

  • Software Design

Software Design C++ (2014), or similar skills.. C++ (2014), or similar skills..

  • user

user-defined types, and basic OO idioms and patterns defined types, and basic OO idioms and patterns

  • how to use pointers and manage memory in C/C++

how to use pointers and manage memory in C/C++

4

  • how to use pointers and manage memory in C/C++

how to use pointers and manage memory in C/C++

  • some material on C++ will be given in the lecture notes

some material on C++ will be given in the lecture notes

  • Some knowledge on graphics programming is beneficial as

Some knowledge on graphics programming is beneficial as background and motivation, and for optional future projects background and motivation, and for optional future projects

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-3
SLIDE 3

The course The course textbook textbook textbook textbook

25.1.2017 25.1.2017 5

Topics of GEA book include Topics of GEA book include

  • large

large-scale C++ software architecture in a games context scale C++ software architecture in a games context

  • mathematics for game programming

mathematics for game programming mathematics for game programming mathematics for game programming

  • game development tools for debugging, source control and

game development tools for debugging, source control and profiling profiling

  • engine subsystems including engine foundation systems,

engine subsystems including engine foundation systems, rendering, sound, collision, physics, character animation rendering, sound, collision, physics, character animation and game world object models and game world object models multiplatform game engines multiplatform game engines

  • multiplatform game engines

multiplatform game engines

  • game programming in multiprocessor environments

game programming in multiprocessor environments

  • tools pipelines for game asset management

tools pipelines for game asset management

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 6

slide-4
SLIDE 4

Jason Gregory: Jason Gregory: Game Engine Architecture Game Engine Architecture (2. ed., 2014) (2. ed., 2014)

  • Ch. 1
  • Ch. 1 Introduction

Introduction

  • what is a game/game engine/cases..

what is a game/game engine/cases..

  • Ch. 2
  • Ch. 2 Tools of the trade

Tools of the trade

  • Ch. 9
  • Ch. 9 Tools for debugging and developm

Tools for debugging and developm. .

  • logging, tracing, debugging, cheats..

logging, tracing, debugging, cheats..

  • Ch. 10
  • Ch. 10 Rendering engine

Rendering engine

  • Ch. 2
  • Ch. 2 Tools of the trade

Tools of the trade

  • prog. envs, Visual Studio., version
  • prog. envs, Visual Studio., version

control, profiling, leak detection, etc. control, profiling, leak detection, etc.

  • Ch. 3
  • Ch. 3 Fundamentals of SE for games

Fundamentals of SE for games

  • C++ techniques and practices

C++ techniques and practices

  • Ch. 4
  • Ch. 4 3D math for games

3D math for games

  • points, vectors, matrices, quaternions..

points, vectors, matrices, quaternions..

  • Ch. 5
  • Ch. 5 Engine support systems

Engine support systems

  • memory, strings, start

memory, strings, start-

  • up, configs..

up, configs..

  • Ch. 10
  • Ch. 10 Rendering engine

Rendering engine

  • the rendering pipeline, visual effects

the rendering pipeline, visual effects

  • Ch. 11
  • Ch. 11 Animation systems

Animation systems

  • skeletons, poses, skinning..

skeletons, poses, skinning..

  • Ch. 12
  • Ch. 12 Collision and rigid body dynamics

Collision and rigid body dynamics

  • physics, collision detection, etc.

physics, collision detection, etc.

  • Ch. 13
  • Ch. 13 Audio

Audio (new in 2nd. edition) (new in 2nd. edition)

  • Ch. 14
  • Ch. 14 Introduction to gameplay systems

Introduction to gameplay systems

  • memory, strings, start

memory, strings, start-

  • up, configs..

up, configs..

  • Ch. 6
  • Ch. 6 Resources and the file system

Resources and the file system

  • Ch. 7
  • Ch. 7 Game loop and simulation

Game loop and simulation

  • main loop, and dealing with time..

main loop, and dealing with time..

  • Ch. 8
  • Ch. 8 Human interface devices

Human interface devices (HID) (HID)

  • implementing game objects/worlds

implementing game objects/worlds

  • Ch. 15
  • Ch. 15 Run

Run-

  • time gameplay foundations

time gameplay foundations

  • bject model architectures
  • bject model architectures
  • events and message passing

events and message passing

  • scripting, loading worlds..

scripting, loading worlds..

  • Ch. 16
  • Ch. 16 There's more

There's more? ?

Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 7 25.1.2017 25.1.2017

Related teaching Related teaching in our department in our department

  • Introduction to Game Programming

Introduction to Game Programming (Autumn 2016, 2017, 2nd period) (Autumn 2016, 2017, 2nd period)

  • Game Engine Architecture

Game Engine Architecture (this course, now: 2017, 3rd period) (this course, now: 2017, 3rd period)

  • serves as "

serves as "Game programming Game programming II" II"

  • requires/teaches programming skills in C/C++

requires/teaches programming skills in C/C++

  • Tietokonegrafiikka

Tietokonegrafiikka (Spring 2017, 4th period, Otto Nurmi) (Spring 2017, 4th period, Otto Nurmi)

  • computer graphics: rasterisation, shading, texturing..

computer graphics: rasterisation, shading, texturing..

  • based on

based on OpenGL OpenGL graphics library graphics library

  • Game Project

Game Project course course (Spring 2017, 4th period) (Spring 2017, 4th period) an optional project for IGP and GEA courses an optional project for IGP and GEA courses

  • an optional project for IGP and GEA courses

an optional project for IGP and GEA courses

  • Compiler design

Compiler design & & Code generation Code generation courses (Spring 2018) courses (Spring 2018)

  • for understanding script languages and their implementation;

for understanding script languages and their implementation; include practical implementation projects (interpreter, compiler) include practical implementation projects (interpreter, compiler)

Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 8 25.1.2017 25.1.2017

slide-5
SLIDE 5

Using C++ in game engine programming Using C++ in game engine programming

  • C++ is widely used in the game industry: "

C++ is widely used in the game industry: "industrial industrial-strength 3D strength 3D game engines are written primarily in C or C++, and any serious game engines are written primarily in C or C++, and any serious game programmer needs to know C++ game programmer needs to know C++" [Gregory, p. " [Gregory, p. XXII

XXII]

Games are complex applications to build Games are complex applications to build

  • Games are complex applications to build

Games are complex applications to build

  • multiple interactions within the program

multiple interactions within the program

  • need to use visual, audio, and other resources and file formats

need to use visual, audio, and other resources and file formats

  • interfacing with OS/hardware components/3rd

interfacing with OS/hardware components/3rd-party libs party libs

  • Graphics libraries require programming knowledge of C/C++

Graphics libraries require programming knowledge of C/C++

9

  • At least, rendering and scripting engines (VM) are written in C++

At least, rendering and scripting engines (VM) are written in C++

  • Most C++ programming features and techniques are relevant for

Most C++ programming features and techniques are relevant for game engine development(?) game engine development(?)

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

XNA XNA Game Studio / Game Studio / MonoGame MonoGame : a "graphic engine" : a "graphic engine"

A sample game framework and A sample game framework and scripting system (C#) scripting system (C#) 2D/3D games with a game engine 2D/3D games with a game engine 2D/3D games with a game engine 2D/3D games with a game engine

  • predefined game skeleton,

predefined game skeleton, components, and 2D sprites components, and 2D sprites

  • the engine provides support for

the engine provides support for 2D images, IO, and audio 2D images, IO, and audio

  • 3D scene is rendered on 2D

3D scene is rendered on 2D screen: needs to use the graphics screen: needs to use the graphics screen: needs to use the graphics screen: needs to use the graphics pipeline pipeline

  • set camera and view frustum

set camera and view frustum

  • using 3D models, and shaders

using 3D models, and shaders (GPU programs) (GPU programs)

10 10 25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-6
SLIDE 6

XNA Game Studio: a "graphic engine" XNA Game Studio: a "graphic engine"

  • Free tool/libraries for creating 2D and 3D games

Free tool/libraries for creating 2D and 3D games

  • Used

Used C# C# as the scripting language (an interesting choice..) as the scripting language (an interesting choice..)

  • Integrated with Visual Studio C#

Integrated with Visual Studio C#

  • use

use Visual Studio 2010 Visual Studio 2010 for for XNA version 4 XNA version 4 (September 2010) (September 2010) -

  • use

use Visual Studio 2010 Visual Studio 2010 for for XNA version 4 XNA version 4 (September 2010) (September 2010) - either Express or Full version either Express or Full version

  • Hardware requirements are identical to Microsoft Visual Studio

Hardware requirements are identical to Microsoft Visual Studio

  • Games could be run on Windows free

Games could be run on Windows free

  • r on Xbox 360 but did require arrangements/costs
  • r on Xbox 360 but did require arrangements/costs
  • But

But not as powerful as many other game engines (physics, GO model) not as powerful as many other game engines (physics, GO model)

  • not as powerful as many other game engines (physics, GO model)

not as powerful as many other game engines (physics, GO model)

  • was it really easy

was it really easy - required C# knowhow.. required C# knowhow..

  • Engines were build on the XNA design, e.g.,

Engines were build on the XNA design, e.g., MonoGame MonoGame

  • Unity killed XNA ??

Unity killed XNA ??

11 11 25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

XNA code sample XNA code sample

public class Game1 : Microsoft.Xna.Framework.Game { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; GraphicsDeviceManager graphics; public Matrix public Matrix CameraView CameraView { get; set; } { get; set; } public Matrix public Matrix CameraProjection CameraProjection { get; set; } { get; set; } public Vector3 public Vector3 CameraPosition CameraPosition ; . . . ; . . . public Game1 () { public Game1 () { graphics = new GraphicsDeviceManager (this); graphics = new GraphicsDeviceManager (this); Content.RootDirectory = "Content"; Content.RootDirectory = "Content";

rotating 3D objects & moving camera rotating 3D objects & moving camera

Content.RootDirectory = "Content"; Content.RootDirectory = "Content"; } } protected override void protected override void Initialize Initialize () { () { CameraPosition CameraPosition = new Vector3 (0.0f, 0.0f, 5000.0f); . . = new Vector3 (0.0f, 0.0f, 5000.0f); . . CameraProjection CameraProjection = = Matrix.CreatePerspectiveFieldOfView ( Matrix.CreatePerspectiveFieldOfView ( MathHelper.ToRadians (45.0f), AspectRatio, MathHelper.ToRadians (45.0f), AspectRatio, 1.0f, float.MaxValue); 1.0f, float.MaxValue); new Ship { new Ship { Position = new Vector3 (2000, 500, 50), Position = new Vector3 (2000, 500, 50), Rotation = MathHelper.ToRadians (40f), Rotation = MathHelper.ToRadians (40f), Scale = .75f }; . . . Scale = .75f }; . . . base.Initialize (); base.Initialize (); } } protected override void protected override void Update Update ( (GameTime gameTime GameTime gameTime) { ) { if (Keyboard.GetState ().IsKeyDown (Keys.Up)) if (Keyboard.GetState ().IsKeyDown (Keys.Up)) CameraPosition CameraPosition.Y += .Y += (float)gameTime.ElapsedGameTime.TotalMilliseconds * 5; (float)gameTime.ElapsedGameTime.TotalMilliseconds * 5; . . . . . . base.Update (gameTime); base.Update (gameTime); } . . . } . . . } }

12 12 25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-7
SLIDE 7

What is a What is a game game?

  • A "

A "game game" is an interactive experience that provides the player with an " is an interactive experience that provides the player with an increasingly challenging sequence of patterns which he or she learns increasingly challenging sequence of patterns which he or she learns and eventually masters and eventually masters (Gregory quoting (Gregory quoting Koster, Koster, A Theory of Fun for A Theory of Fun for Game Design Game Design,

, 2004 [26]

2004 [26]) Game Design Game Design,

, 2004 [26]

2004 [26])

  • Gregory: "

Gregory: "a game is a a game is a soft real soft real-time time interactive interactive agent agent-based based computer computer simulation simulation"

  • agent

agent = = any game entity, very often implemented as an object in any game entity, very often implemented as an object in an object an object-oriented programming language

  • riented programming language
  • The

The GEA textbook GEA textbook [Gregory] focuses on the implementation of a [Gregory] focuses on the implementation of a subset of games that comprise two subset of games that comprise two- and three and three-dimensional virtual dimensional virtual subset of games that comprise two subset of games that comprise two- and three and three-dimensional virtual dimensional virtual worlds with a small number of players (say, between 1 worlds with a small number of players (say, between 1-16): 16):

  • primary focus will be on game engines capable of producing first

primary focus will be on game engines capable of producing first- person shooters, third person shooters, third-person action/platform games, racing games, person action/platform games, racing games, fighting games, and the like fighting games, and the like

13 13

What is a What is a game engine game engine?

  • The

The game engine game engine term arose about the mid term arose about the mid-1990s 1990s

  • Doom

Doom by by id Software id Software was a FPS architected with a well was a FPS architected with a well-defined defined separation between its (1) core software components (the rendering separation between its (1) core software components (the rendering system, the collision detection, the audio, etc.) and (2) the art assets, system, the collision detection, the audio, etc.) and (2) the art assets, system, the collision detection, the audio, etc.) and (2) the art assets, system, the collision detection, the audio, etc.) and (2) the art assets, game worlds, and rules of play game worlds, and rules of play

  • Developers began licensing games and remaking them into new

Developers began licensing games and remaking them into new products by creating new art, world layouts, weapons, characters, products by creating new art, world layouts, weapons, characters, vehicles, and game rules with only minimal changes to the "engine" vehicles, and game rules with only minimal changes to the "engine" software software

  • Thus

Thus, game engines provide a selected set of core components, , game engines provide a selected set of core components, including the rendering engine, the collision and physics engine, the including the rendering engine, the collision and physics engine, the animation system, the audio system, the game world object model, animation system, the audio system, the game world object model, the artificial intelligence system, etc. the artificial intelligence system, etc.

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 14 14

slide-8
SLIDE 8

What is a What is a game engine game engine? (cont.) ? (cont.)

  • A "game engine" should be designed to be extensible and to be used as

A "game engine" should be designed to be extensible and to be used as the foundation for many different games without major modification the foundation for many different games without major modification

  • a game containing hard

a game containing hard-coded logic, or any special coded logic, or any special-case code case code becomes difficult or impossible to reuse to make a different game becomes difficult or impossible to reuse to make a different game becomes difficult or impossible to reuse to make a different game becomes difficult or impossible to reuse to make a different game

  • Especially, a

Especially, a data data-driven driven architecture architecture can separate a game engine can separate a game engine from a piece of software that is a game but not an engine; from a piece of software that is a game but not an engine;

  • ne definition for "data
  • ne definition for "data-driven":

driven":

  • all game contents & logic are driven by external data sources

all game contents & logic are driven by external data sources Note that there is also a separation between logical and physical Note that there is also a separation between logical and physical

  • Note that there is also a separation between logical and physical

Note that there is also a separation between logical and physical software architecture: the inheritance/component hierarchy software architecture: the inheritance/component hierarchy vs

  • vs. the

. the source and binary file structure (very relevant for C/C++ programs) source and binary file structure (very relevant for C/C++ programs)

  • Within each game component, a number of semi

Within each game component, a number of semi-standard design standard design alternatives are emerging (we can hope..) alternatives are emerging (we can hope..)

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 15 15

What is a What is a game engine game engine? (cont.) ? (cont.)

  • Originally, game engines were designed to run a particular

Originally, game engines were designed to run a particular-style game style game (of a given " (of a given "genre genre") on a particular hardware platform ") on a particular hardware platform

  • Now game engines are trying to support multiple

Now game engines are trying to support multiple platforms platforms, e.g., , e.g., Unreal Unreal: : Windows, Xbox 360, PlayStation 3, Mac OS X, Wii U, iOS, Windows, Xbox 360, PlayStation 3, Mac OS X, Wii U, iOS, Unreal Unreal: : Windows, Xbox 360, PlayStation 3, Mac OS X, Wii U, iOS, Windows, Xbox 360, PlayStation 3, Mac OS X, Wii U, iOS, Android.. Android..

  • The more general

The more general-purpose a game component is, the less optimal it purpose a game component is, the less optimal it may be for a particular game on a particular platform may be for a particular game on a particular platform

  • as usual, optimal efficiency may require customization and trade

as usual, optimal efficiency may require customization and trade-

  • ffs (
  • ffs (bindings

bindings) based on assumptions about target hardware ) based on assumptions about target hardware

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 16 16

...

slide-9
SLIDE 9

The main components of a game engine The main components of a game engine

  • Scene graphs

Scene graphs (i.e., a hierarchical spatial representation of a (i.e., a hierarchical spatial representation of a graphical scene/level) graphical scene/level)

  • may well need multiple different versions depending on

may well need multiple different versions depending on

  • may well need multiple different versions depending on

may well need multiple different versions depending on level characteristics (outdoors, dungeon, or whatever) level characteristics (outdoors, dungeon, or whatever)

  • A

A rendering engine rendering engine for 2D and/or 3D graphics for 2D and/or 3D graphics

  • A

A physics engine physics engine for more for more-or

  • r-less realistic world simulation

less realistic world simulation and collision detection (strongly interrelated and used together) and collision detection (strongly interrelated and used together)

  • Sound and music

Sound and music

17 17

  • Sound and music

Sound and music

  • Character

Character animation animation

  • Artificial intelligence

Artificial intelligence

  • Scripting

Scripting

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

These may also be realized as kind of subengines

Game engine (pros and cons) Game engine (pros and cons)

Benefits Benefits (mostly the same as general ones for software reuse) (mostly the same as general ones for software reuse)

  • provides simplified access to underlying technologies

provides simplified access to underlying technologies

  • rganizes and speeds up development process
  • rganizes and speeds up development process
  • reusing the same game engine (software) to create multiple

reusing the same game engine (software) to create multiple

  • reusing the same game engine (software) to create multiple

reusing the same game engine (software) to create multiple different games different games

  • less testing and debugging

less testing and debugging

  • many features directly available

many features directly available

  • better focus on the game design aspects

better focus on the game design aspects

  • enables the game to run on multiple platforms (consoles,

enables the game to run on multiple platforms (consoles,

  • perating systems)
  • perating systems)

18 18

  • perating systems)
  • perating systems)

Drawbacks Drawbacks (potential costs and complexity) (potential costs and complexity)

  • dependencies on the quality of design, available features,

dependencies on the quality of design, available features, implementation decisions, licensing schemes, third implementation decisions, licensing schemes, third-party libraries party libraries

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-10
SLIDE 10

Other general game engine tasks Other general game engine tasks

  • Initialization

Initialization: linking/using multiple different APIs and libraries : linking/using multiple different APIs and libraries

  • Managing the

Managing the game loop game loop and real/simulation time ( and real/simulation time (system clock system clock)

  • Reading input

Reading input (and giving it meaning for game control/mechanics) (and giving it meaning for game control/mechanics)

  • Managing memory, and string/name management

Managing memory, and string/name management

  • File systems, and resource caching

File systems, and resource caching (make resources available (make resources available - but but hide, e.g., level loading; prefetch for speed optimization) hide, e.g., level loading; prefetch for speed optimization)

  • Dynamically loaded libraries

Dynamically loaded libraries (DLLs), e.g., to delay loading or (DLLs), e.g., to delay loading or to replace renderer engine or some other subsystem or subengine to replace renderer engine or some other subsystem or subengine Threads Threads and thread synchronization and thread synchronization

19 19

  • Threads

Threads and thread synchronization and thread synchronization

  • parallel execution: multi

parallel execution: multi-core, GPU, physics card (?) core, GPU, physics card (?)

  • Network

Network communication communication

  • Shutdown

Shutdown

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

Game engine API

Your game

Hardware abstraction layer – DirectX, OpenGL, … Graphics engine Sound engine Physics engine AI engine Scripting engine

. . .

20 20

Hardware layer - sound card, graphics card (physics card?) For a bit more detailed architecture, see the following slides [Gregory, p. 33] .

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-11
SLIDE 11

There are hundreds of game engines, e.g.: There are hundreds of game engines, e.g.:

  • Unreal Engine

Unreal Engine 4 (free for making free games, otherwise royalties) (free for making free games, otherwise royalties)

  • Unity

Unity 5 5 (free/professional versions) (free/professional versions)

  • CryENGINE

CryENGINE also also free for non free for non-commercial use.. commercial use.. OGRE OGRE graphics engine (open source) graphics engine (open source)

  • OGRE

OGRE graphics engine (open source) graphics engine (open source)

  • Blender

Blender game engine (completely free) game engine (completely free)

  • Check out online sources (

Check out online sources (http://www.devmaster.net/engines/ http://www.devmaster.net/engines/ )

  • Why so many graphic APIs & game engines?

Why so many graphic APIs & game engines?

  • possibly for differing target applications and requirements

possibly for differing target applications and requirements

  • real

real-time vs. non time vs. non-real real-time applications time applications

21 21

  • real

real-time vs. non time vs. non-real real-time applications time applications

  • provide application specific optimizations

provide application specific optimizations

  • provide genre

provide genre-specific game entities and functionality specific game entities and functionality

  • provide custom

provide custom platform platform optimizations and dependencies

  • ptimizations and dependencies
  • pen source vs.
  • pen source vs. manufacturer

manufacturer-specific specific APIs APIs

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

Game engine Game engine architecture by architecture by [Gregory, p. 33] [Gregory, p. 33] (sorry, it (sorry, it is is big big)

slide-12
SLIDE 12

A simplified GE architecture A simplified GE architecture (Antti Hietasaari, 2016) Antti Hietasaari, 2016)

(Game-specific subsystems) (Game-engine subsystems) (Game-engine core systems) 25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 23 23 (Utility subsystems) (Resource files) (mem. mgt, testing, math, strings, platform independence, 3rd-patry llibraries)

Gameplay Gameplay foundation systems foundation systems

  • Provide the (most direct) support for implementing the game logic

Provide the (most direct) support for implementing the game logic

  • "Gameplay

Gameplay" = the rules of a game world, the abilities/properties of " = the rules of a game world, the abilities/properties of

(Parent/child model)

  • "Gameplay

Gameplay" = the rules of a game world, the abilities/properties of " = the rules of a game world, the abilities/properties of the player and other entities in the world, and goals and objectives the player and other entities in the world, and goals and objectives

  • Related "

Related "software object model software object model" = the specific way to " = the specific way to implement implement this this engine: what language? use inheritance/components/templates? how engine: what language? use inheritance/components/templates? how to refer/identify entities ( to refer/identify entities (GUID GUID), create, update, and destroy objects.. ), create, update, and destroy objects..

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 24 24

slide-13
SLIDE 13

Scripting engines in game programs Scripting engines in game programs

  • Potential advantages

Potential advantages (depending on the scripting language depending on the scripting language):

  • a convenient high

a convenient high-level language to level language to control a game control a game

  • strongly promotes "

strongly promotes "data data-driven design driven design": a ": a game engine should not game engine should not contain any game contain any game-specific code specific code

  • can change the game rules/behaviour while the game is running

can change the game rules/behaviour while the game is running

  • can provide state machines, configuration, and option set up..

can provide state machines, configuration, and option set up..

  • A script can provide parameters and actions for a game

A script can provide parameters and actions for a game

  • data parameters: time

data parameters: time-of

  • f-day => determine overall lighting etc.,

day => determine overall lighting etc.,

  • bject mass/friction, game options, AI goals and objectives
  • bject mass/friction, game options, AI goals and objectives
  • behavior: set lights, move objects, select path, calculate decisions

behavior: set lights, move objects, select path, calculate decisions

25 25

  • behavior: set lights, move objects, select path, calculate decisions

behavior: set lights, move objects, select path, calculate decisions (e.g., state machines in script) (e.g., state machines in script)

  • Problems

Problems: how to bind scripts to game logic and objects? performance? : how to bind scripts to game logic and objects? performance? custom languages may lack mature custom languages may lack mature development development support support tools (IDEs); tools (IDEs); we may have learning curve for (yet another) new language we may have learning curve for (yet another) new language

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

Game Game-specific sub specific subsystem systems

  • On top of the gameplay foundation and the other low

On top of the gameplay foundation and the other low-level level components, we implement the components, we implement the actual game actual game itself itself

  • Typical game entities include

Typical game entities include

  • static background geometry (buildings, roads, terrain), rigid

static background geometry (buildings, roads, terrain), rigid

  • static background geometry (buildings, roads, terrain), rigid

static background geometry (buildings, roads, terrain), rigid bodies (rocks, cans, chairs), player & non bodies (rocks, cans, chairs), player & non-player characters, player characters, weapons, power weapons, power-ups, projectiles, vehicles, lights (dynamic/ ups, projectiles, vehicles, lights (dynamic/ static), game static), game-tailored cameras tailored cameras

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 26 26

slide-14
SLIDE 14

Tools and the Tools and the asset pipeline asset pipeline

  • 3D modeling tools use very complex

3D modeling tools use very complex internal internal data formats are rarely data formats are rarely suitable for direct use in game software suitable for direct use in game software

  • they support, e.g., full hierarchy of 3D transformations (position,

they support, e.g., full hierarchy of 3D transformations (position,

  • rientation, scale, shear), interconnections as a directed acyclic
  • rientation, scale, shear), interconnections as a directed acyclic

graph (DAG) of scene nodes, edit history (for undo/redo) graph (DAG) of scene nodes, edit history (for undo/redo) graph (DAG) of scene nodes, edit history (for undo/redo) graph (DAG) of scene nodes, edit history (for undo/redo)

  • are often too slow to read at game run time

are often too slow to read at game run time

  • in some cases use a closed proprietary custom format

in some cases use a closed proprietary custom format

  • A game engine typically only needs a tiny fraction of all such

A game engine typically only needs a tiny fraction of all such information in order to render the model in information in order to render the model in-game; a 2 game; a 2-way process: way process: 1. 1. Data produced by a tool is first Data produced by a tool is first exported exported to a more accessible to a more accessible standardized format, or another custom file format standardized format, or another custom file format 2. 2. Exported data is further processed before being sent to the Exported data is further processed before being sent to the game engine game engine - possibly differently for each target platform possibly differently for each target platform

  • Each engine needs such an

Each engine needs such an asset conditioning pipeline

sset conditioning pipeline of its own

  • f its own

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 27 27

[Gregory, Fig.1.35, p.55] direct data flow dependencies, use

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 28 28

Tools and the asset pipeline.

slide-15
SLIDE 15

Approaches to tool architecture (in different engines) Approaches to tool architecture (in different engines)

1. 2.

1. 1. Standalone tools architecture Standalone tools architecture

3.

1. 1. Standalone tools architecture Standalone tools architecture 2. 2. Tools share a framework with Tools share a framework with games games 3. 3. Unreal Engine Unreal Engine's tool architecture 's tool architecture

29 29

[Gregory, Fig.1.36-8, p.60-61]

Applying "model Applying "model-view" architecture for games view" architecture for games

  • Model

Model-view view architecture (a MVC variant, here V includes C) architecture (a MVC variant, here V includes C)

  • separate content (data = "model") from view & input processing

separate content (data = "model") from view & input processing

  • use the proven "standard" solution for GUI systems

use the proven "standard" solution for GUI systems use the proven "standard" solution for GUI systems use the proven "standard" solution for GUI systems

  • Goals and principles for game programming

Goals and principles for game programming

  • provide multiple views on the same shared data (game state)

provide multiple views on the same shared data (game state)

  • loose coupling between parts:

loose coupling between parts: update events update events are used for notification are used for notification

  • f changes
  • f changes
  • human players, AI agents, network views can be uniformly treated

human players, AI agents, network views can be uniformly treated an event system can provide centralized debugging/logging etc. an event system can provide centralized debugging/logging etc.

30 30

  • an event system can provide centralized debugging/logging etc.

an event system can provide centralized debugging/logging etc.

  • Implementation may not be so simple

Implementation may not be so simple

  • need to provide a general message system (using

need to provide a general message system (using callback callbacks, or s, or applying the applying the Observer Observer design pattern) design pattern)

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-16
SLIDE 16

"Ideal model "Ideal model-view" game architecture (sketch) view" game architecture (sketch)

Game logic Game view . . . Game view (Human) easy to add/replace views; provide symmetric handling

  • f game views

Game logic state & data physics, events command interpreter Game view (Human) display, audio input handling Application support layer Game view (AI agent) stimulus interpreter decision system game state & commands game world simulation

31 31

Application support layer Devices: input, files RAM, time OS: PLs, DLL threads networking Game lifetime: core libs, main loop, init&shutdown Modified from [McShaffry, 2013]

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

Example data flow in model Example data flow in model-view system view system

  • The

The support layer support layer gets low gets low-level input from physical devices and level input from physical devices and creates input events/commands creates input events/commands

  • the interpreter of the

the interpreter of the human view human view transforms input to general transforms input to general game events/commands game events/commands game events/commands game events/commands

  • The interpreter of the

The interpreter of the game logic game logic receives messages and updates the receives messages and updates the state of the game accordingly state of the game accordingly

  • can handle

can handle uniformly uniformly messages messages from from all the views: input system, all the views: input system, AI agents, the scripting engine, a playback file, or network AI agents, the scripting engine, a playback file, or network connections connections

32 32

  • can also allow user commands from a screen

can also allow user commands from a screen command console command console (txt commands using a script engine, or a custom AST interpreter) (txt commands using a script engine, or a custom AST interpreter)

  • sends notifications to separate

sends notifications to separate views views to be processed locally (or to be processed locally (or possibly to be forwarded) possibly to be forwarded)

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki

slide-17
SLIDE 17

Summary Summary

  • Computer games are a very specialized application area

Computer games are a very specialized application area

  • can be small (casual games), or very complicated commercial

can be small (casual games), or very complicated commercial- quality interactive 3D real quality interactive 3D real-time simulation systems time simulation systems Game engines provide the foundation on which to build new game Game engines provide the foundation on which to build new game

  • Game engines provide the foundation on which to build new game

Game engines provide the foundation on which to build new game programs (very similarly to programs (very similarly to applications frameworks applications frameworks)

  • provide concepts/models for a game world and its entities

provide concepts/models for a game world and its entities

  • reuse libraries and components (also managing and hiding new

reuse libraries and components (also managing and hiding new versions of libraries and updating for such versions) versions of libraries and updating for such versions)

  • reuse design ideas and experience

reuse design ideas and experience

  • Some problems are by nature general and can (possibly) be solved by

Some problems are by nature general and can (possibly) be solved by standard software practices (style rules, testing, patterns,..) standard software practices (style rules, testing, patterns,..)

  • Hopefully, also some game

Hopefully, also some game-specific techniques and ideas can be specific techniques and ideas can be identified and used as working solutions identified and used as working solutions

25.1.2017 25.1.2017 Juha Vihavainen / University of Helsinki Juha Vihavainen / University of Helsinki 33 33