21
3/18/09 1 Professor Charles Rich Computer Science Department [email protected] IMGD 4000 (D 09) 1 Game Engines Technical Game Development II Pedagogical Goal Your technical skills should not be tied to any particular game engine Just like your programming skills should not be tied to any particular programming language Use the best tools for each job ... or the tools you were given IMGD 4000 (D 09) 2

Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

1

Professor Charles Rich Computer Science Department [email protected]

IMGD 4000 (D 09) 1

Game Engines

Technical Game Development II

Pedagogical Goal

  Your technical skills should not be tied to any particular game engine

  Just like your programming skills should not be tied to any particular programming language

  Use the best tools for each job

  ... or the tools you were given

IMGD 4000 (D 09) 2

Page 2: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

2

IMGD 4000 (D 09) 3

Definition

Game Engine A series of modules and interfaces that allows a

development team to focus on product game-play content, rather than technical content. [Julian Gold, OO Game Dev.]

  But this class is about “the technical content” !

IMGD 4000 (D 09) 4

Buy versus Build

  Depends on your needs, resources and constraints •  technical needs (e.g., “pushing the envelope” ?) •  financial resources (e.g., venture capital ?) •  time constraints (e.g., 1 mo. or 2 yr. ?) •  platform constraints (e.g., Flash ?) •  other factors (e.g., sequel ?)

  Most games commonly built today with some sort of “engine layer”

Page 3: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

3

IMGD 4000 (D 09) 5

Types of Engine Architectures (Roughly)

  Monolithic (e.g., Unreal Engine)

  Modular (e.g., C4 Engine)

  Tool Kit (e.g., jME)

IMGD 4000 (D 09) 6

Monolithic Engines (e.g., Unreal)

  “old style”--typically grew out of specific game

  tend to be genre-specific

  difficult to go beyond extensions/modifications not anticipated in (e.g., scripting) API

  proven, comprehensive capabilities

Page 4: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

4

IMGD 4000 (D 09) 7

Modular Engines (e.g., C4)

  “modern”--often developed by game engine company

  use object-oriented techniques for greater modularity

  much easier to extend/replace components than monolithic engines

  architecture a bit more “bundled” (IDE-like) than tool-kit engines (see next)

IMGD 4000 (D 09) 8

Tool Kit Engines (e.g., jME)

  highly object-oriented

  designed for maximum modifiability

  typically open source

  may not be as complete or mature

Page 5: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

5

IMGD 4000 (D 09) 9

Basic Game Engine Architecture Blocks

operating system

ai

animation

camera

controllers

effects

game

geometry

graphics

gui

input

level builder

modeler

physics

scene graph

sound

renderer

IMGD 4000 (D 09) 10

Choices: “It’s a Jungle Out There”

  290 3D engines reviewed at DevMaster.net

  We are not going to try to review them all here

Page 6: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

6

IMGD 4000 (D 09) 11

Many Evaluation Dimensions/Features [ DevMaster.net ]

If there’s a feature term here you don’t know, you should look it up!

IMGD 4000 (D 09) 12

Best Choice is Relative to Situation

  Similar issues of needs, resources and constraints (as in buy vs. build) •  platform, programming language constraints •  cost constraints (commercial run $ to $$$) •  specific technical features required (e.g., MMO) •  previous experience of staff •  support from developers, user community (e.g.,

forums) •  pedagogical goals (e.g., this course)

Page 7: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

7

IMGD 4000 (D 09) 13

Choice of C4 and jME for IMGD 3000/4000

  C4 Engine http://www.terathon.com/c4engine •  modular •  C++ language (industry standard) •  reasonable cost •  technically sophisticated •  good support community (forum)

IMGD 4000 (D 09) 14

Choice of C4 and jME for IMGD 3000/4000

  jME (jMonkeyEngine) http://jmonkeyengine.com

•  tool kit –  API to ODE and PhysX https://jmephysics.dev.java.net –  JGN for lightweight networking http://code.google.com/p/jgn –  FengGUI for HUD’s and other GUI’s http://www.fenggui.org

•  Java language –  “up and coming”, especially for mobile –  ties in with Darkstar assignment – much less error-prone than C++

•  free, open source •  technically sophisticated •  good support community (forum)

http://www.ardor3d.com

Page 8: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

8

IMGD 4000 (D 09) 15

C4 and jME Comparison

  Architecture

  Guided Tour of Tutorial Examples

  Feature comparison

16 IMGD 4000 (D 09)

Page 9: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

9

17 IMGD 4000 (D 09)

18 IMGD 4000 (D 09)

Page 10: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

10

IMGD 4000 (D 09) 19

Guided Tour of Tutorial Examples

  Why are we doing this? •  not to save you the trouble of reading the

documentation! (You will need to anyways :-) –  leaving out many details (e.g., error checking) –  reordering for clarity (e.g., combining .h and .cpp files)

•  not interested in low-level C++ vs. Java coding differences

•  goal is to better understand the design space of engines by looking closely at different choices made

•  more generally, thoughtful reading of other people’s code is an important skill for software developers

–  paying close attention to modularity and architecture

module C4::Application *ConstructApplication(void) // called by C4 engine { return (new Game); }

class Game : public Application {

private: EntityRegistration ballEntityReg; // for World Editor MovementAction *forwardAction; // typical input control

Game() : ballEntityReg(kEntityBall, "model/Ball", kEntityPrecache, kControllerBall) { ballEntityReg.SetEntitySize(0.125F, 0.125F, 0.125F); ballEntityReg.SetEntityColor(ColorRGB(0.0F, 1.0F, 0.0F)); TheWorldMgr->SetWorldConstructor(&ConstructWorld); // create and register movement actions forwardAction = new MovementAction(kActionForward, kSpectatorMoveForward); TheInputMgr->AddAction(forwardAction); }

class MovementAction : public Action {

void Begin(void) { GameWorld *world = static_cast<GameWorld *>(TheWorldMgr->GetWorld()); SpectatorCamera *camera = world->GetSpectatorCamera(); camera->SetSpectatorFlags(camera->GetSpectatorFlags() | movementFlag); } };

World *ConstructWorld(const char *name, void *data) // called by TheWorldMgr { return (new GameWorld(name)); } };

20 IMGD 4000 (D 09)

Page 11: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

11

class GameWorld : public World {

private: SpectatorCamera spectatorCamera;

GameWorld(const char *name) : World(name), spectatorCamera(2.0F, 1.0F, 0.3F) {}

WorldResult Preprocess(void) { Zone *zone = GetRootZone(); const Marker *marker = zone->GetFirstMarker(); while (marker) // find World Editor marker for camera placement { MarkerType type = marker->GetMarkerType(); if (type == kMarkerLocator) { if (static_cast<const LocatorMarker *>(marker)->GetLocatorType() == kLocatorSpectator) { spectatorCamera.SetNodePosition(marker->GetWorldPosition()); const Vector3D direction = marker->GetWorldTransform()[0]; float azimuth = Atan(direction.y, direction.x); float altitude = Atan(direction.z, Sqrt(...)); spectatorCamera.SetCameraAzimuth(azimuth); spectatorCamera.SetCameraAltitude(altitude); } } marker = marker->ListElement<Marker>::Next(); } SetCamera(&spectatorCamera); // set world's camera for rendering return (kWorldOkay); } };

21 IMGD 4000 (D 09)

public abstract class AbstractGame { // in com.jme.app

protected DisplaySystem display;

public final void start() { initSystem(); initGame(); while (!finished && !display.isClosing()) { InputSystem.update(); update(); render(); } } }

public class SimpleGame extends AbstractGame {

public static void main(String[] args) { // called by JVM new SimpleGame().start(); }

protected Camera camera; protected InputHandler input; protected LightState lightState; protected Node rootNode; // NB

protected final void update() { timer.update(); // recalculate frame rate float tpf = timer.getTimePerFrame(); input.update(tpf); // check for key/mouse events rootNode.updateGeometricState(tpf, true); }

protected final void render() { display.getRenderer().clearBuffers(); display.getRenderer().draw(rootNode); }

22 IMGD 4000 (D 09)

Page 12: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

12

protected final void initSystem() { display = DisplaySystem.getDisplaySystem(properties.getRenderer()); display.createWindow(...); camera = display.getRenderer().createCamera(...); camera.setFrustumPerspective(...); camera.setFrame(...); camera.update(); display.getRenderer().setCamera(camera); // setup input controls input = new FirstPersonHandler(camera); }

protected final void initGame() { rootNode = new Node("rootNode"); // create ZBuffer ZBufferState buf = display.getRenderer().createZBufferState(); buf.setEnabled(true); buf.setFunction(ZBufferState.CF_LEQUAL); rootNode.setRenderState(buf); // set up basic default light PointLight light = new PointLight(); light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f)); light.setLocation(new Vector3f(100, 100, 100)); light.setEnabled(true); // attach light to a lightState and the lightState to rootNode lightState = display.getRenderer().createLightState(); lightState.setEnabled(true); lightState.attach(light); rootNode.setRenderState(lightState); // attach example box to root node rootNode.attachChild(new Box("my box",new Vector3f(0,0,0),new Vector3f(1,1,1))); // update geometric and rendering information rootNode.updateGeometricState(0.0f, true); rootNode.updateRenderState(); } }

23 IMGD 4000 (D 09)

IMGD 4000 (D 09) 24

Some Observations from Code Tour

  Code is overall more similar than different •  systematic separation of node vs. state (to allow

reuse of state desriptions) – C4: Light/LightObject, etc. –  jME: Light/LightState, etc.

•  controllers associated with nodes for response to events

Page 13: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

13

IMGD 4000 (D 09) 25

Some Observations from Code Tour

  Examples of how C4 more bundled, IDE-like: •  C4 makes heavier use of singleton “managers”

– C4 has single root node in WorldManager –  any jME program can call updateGeometricState on any

node

•  World editor more tightly integrated –  “markers” installed in world editor and searched for by

game initialization –  level editor not bundled into jME (cf. MonkeyWorld3D)

IMGD 4000 (D 09) 26

Detailed Feature Comparisons

  From DevMaster.net

  Caveats:

•  Info may not be up-to-date (especially for jME)

•  I have added a few comments of my own

•  Let’s not get bogged down in the details---the idea

is to get overall sense of emphasis

Page 14: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

14

IMGD 4000 (D 09) 27

General Features

Object-Oriented Design, Plug-in Architecture, Save/Load System: • Extremely clean class hierarchy for scene graph nodes, including geometries, cameras,         lights, sounds, zones, portals, triggers, markers, and special effects • General state serialization support for saving worlds • Quick save and quick load capabilities • Separation between per-instance and shared data • External scene graph referencing from within another scene graph • Support for pack files and a virtual directory hierarchy • Skinable GUI's

Modular OO based design with abstract interfaces for all low level APIs: • 3D Text Generation • Binding system for input controls • Support for using jME in a Java Applet • New Importer and Exporter System giving a standard framework for loading and saving jME    scenegraphs • A Binary Format implementation for the new import/export system that is more compact and    faster than standard Java serialization • Control Binding Management

IMGD 4000 (D 09) 28

Scripting

Graphical script editor

Efforts underway to add scripting extensions: • Current JVM’s include JavaScript and LiveConnect (easy api between Java and JS) [CR]

Page 15: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

15

IMGD 4000 (D 09) 29

Builtin-Editors

• Full-featured integrated cross-platform world editor • Interface panel editor • Complete built-in windowing system • Powerful and intuitive interface design • Advanced surface attribute manipulation and material management

Level editor considered separate project: • e.g., MonkeyWorld3D [CR]

IMGD 4000 (D 09) 30

Physics

Basic Physics, Collision Detection, Rigid Body: • Built-in character controller. • Built-in projectile controller. • Real-time fluid surface simulation. • Real-time cloth simulation.

Collision Detection: • Triangle accurate collision detection

Physics considered separate project: • e.g., jME Physics interface to ODE (Open Dynamics Engine), PhysX and others [CR]

Page 16: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

16

IMGD 4000 (D 09) 31

Lighting

Per-vertex, Per-pixel, Lightmapping, Radiosity, Gloss maps, Anisotropic: • Support for fully dynamic infinite, point, and spot lights • Gloss-mapped specular reflections • Ambient radiosity • Projected cube and spot textures • Cook-Torrance microfacet shading

Per-vertex, Lightmapping

IMGD 4000 (D 09) 32

Shadows

Shadow Mapping, Projected planar, Shadow Volume: • All shadows are rendered in real time at global scale • Three types of shadows are seamlessly combined in one world • True penumbral soft shadows for area light sources

Shadow Volume: • Z-Pass shadow volumes

Page 17: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

17

IMGD 4000 (D 09) 33

Texturing

Basic, Multi-texturing, Bumpmapping, Mipmapping, Projected: • Comprehensive bump mapping capabilities • Enhanced parallax mapping • Ambient occlusion channels • Emission/glow maps • Horizon mapping • Realistic water shading

Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump mapping

IMGD 4000 (D 09) 34

Shaders

Vertex, Pixel, High Level: • Extensive support for vertex programs and pixel shaders

Vertex, Pixel, High Level: • Support for OpenGL Vertex Programs. • Support for OpenGL Fragment Programs • Support for GLSL (cf. lecture on Fri, April 10)

Page 18: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

18

IMGD 4000 (D 09) 35

Scene Management

General, Portals, Occlusion Culling, LOD: • Efficient large-scale visibility determination • Advanced inter-zone lighting analysis at runtime • Special support for mirrors and remote portals • Object instancing and external scene referencing • Scene data can be imported from Collada format

General, Octrees, LOD: • Scene graph based architecture • Scene data can be imported from Collada format

IMGD 4000 (D 09) 36

Animation

Skeletal Animation, Animation Blending: • Full skeletal hierarchy support for deformable meshes • Powerful hierarchical animation blending system

Keyframe Animation, Skeletal Animation: • A Skin and Animatable Bone System enabling realistic representation of models and motion

Page 19: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

19

IMGD 4000 (D 09) 37

Meshes

Mesh Loading, Progressive: • Support for the Collada scene format, enabling models to be imported from 3D Studio MAX,    Maya, XSI, Blender, and other content creation packages

Mesh Loading, Skinning: • Handles it's internal format (.jme) and converts from/exports to ASE, 3DS, MD2, MD3, Milkshape, Obj and Collada • Support for importing files in the COLLADA format • New extension providing the ability to generate 3d meshes from text

IMGD 4000 (D 09) 38

Special Effects

Environment Mapping, Lens Flares, Billboarding, Particle System, Motion Blur, Sky, Water, Fire, Decals, Fog, Mirror: • Cube environment mapping • Environment-mapped bump mapping • Fully extensible particle systems • Surface markings on arbitrary geometry • Bump-mapped (fully lit) surface markings • Real-time fire and electrical effects • Transparent warping effects (heat haze, etc.) • Bumpy reflection and refraction • Postprocessed glow • Fog volumes • Full-scene cinematic motion blur • Interactive in-game interface panels

Environment Mapping, Lens Flares, Billboarding, Particle System, Sky, Water, Fire, Explosion, Fog: • Cloth Simulation • Water, with configurable reflection, refraction, wave generation and more • Bloom, with configurable intensity, blurring, resolution and more-Dot3 Bumpmapping

Page 20: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

20

IMGD 4000 (D 09) 39

Networking

Client-Server: • Fast, reliable network implementation using UDP/IP • Solid fault tolerance and hacker resistance • Advanced security measures, including packet encryption • Automatic message distribution to entity controllers

Networking viewed as separate project: • e.g., see JavaGameNetworking, Darkstar [CR]

IMGD 4000 (D 09) 40

Sound and Video

2D Sound, 3D Sound, Streaming Sound: • Fully spatialized 3D sound effects • Unlimited streaming music channels with seamless looping and concatenation • Doppler shift and other frequency effects • High-precision sound travel delay • Atmospheric absorption effects • Reverberation with multiple simultaneous environments • Directional sounds with cone attenuation • Obstruction attenuation applied to direct and reflected paths • Frequency-dependent volume settings for all effects • Permeation system determines how far sounds travel through interiors • Apple's QuickTime technology can be used to play movies or soundtracks from        numerous formats

3D Sound: • OpenAL support with 3D position

Page 21: Game Engines - WPIweb.cs.wpi.edu/~rich/courses/imgd4000-d09/lectures/A-Engines.pdf · Basic, Multi-texturing, Mipmapping, Procedural: • Support for simple texture based dot3 bump

3/18/09

21

IMGD 4000 (D 09) 41

Rendering

Fixed-function, Render-to-Texture: • Antialiasing (up to 8x) • Bilinear and trilinear filtration • Anisotropic filtration (up to 16x) • Vertical Sync control

Fixed-function, Render-to-Texture, Fonts, GUI: • Rendering system supports both rendering to a screen context as well as rendering to a texture. • Implements a Rendering Queue that automatically sorts opaque, transparent and screen objects    and renders them in the correct order • Multipass rendering system • Supports rendering into a web-page via applets • FBO support • Support for rendering to Framebuffer Objects

IMGD 4000 (D 09) 42

Summary Ratings (5 star scale)

Overall: 4.5 (56 votes) Features: 4.5 Ease of Use: 4.0 Stability: 4.5 Support: 4.5

Overall: 4.0 (30 votes) Features: 4.0 Ease of Use: 4.0 Stability: 4.0 Support: 4.5

?!?