physics solutions for innovative game design

Post on 18-May-2015

5.180 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Give your iPhone games a dynamic real-world feel by integrating a physics engine. This session will give an overview of the current physics engines available for iPhone development, discussing the pros and cons of each. We will also discuss how to decide if a physics engine is right for your project or you are better off with custom code. We'll dive into some real world examples with Ragdoll Blaster which uses the Open Dynamics Engine and talk about optimization, debugging and other tips and tricks.

TRANSCRIPT

Physics Solutions for Innovative Game Design

Give your iPhone games a dynamic real-world feel by integrating a physics engine.

Andrei GradinariLead Engineer - Backflip Studios

Tom BlindLead Designer - Backflip Studios

History of Physics in Gamesand

"Physics Games"

History of Physics in GamesVery simple physics (Late 80-s to Early 90-s) - Racing games, flight sims, mini golf games, etc ...

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

History of Physics in GamesComplex real physics (Early 2000s) - Prey

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

History of Physics in GamesPhysics on GPUs: Almost real world complexity (Middle to Late 2000's)Crysis engine 3000 Barrels, real time:

History of Physics in GamesPhysics on GPUs: Almost real world complexity (Middle to Late 2000's)

What is a Physics Game?

These are NOT physics gamesEven though they use physics

Doom 3 Unreal

What is a Physics Game?

These are physics games!

Crayon Physics Fantastic Contraption

What is a Physics Game?

Physics EngineDefinition and How It Works

Physics Engine

A physics engine is a set of functions that lets you describe layout of your system of physics objects and then tells you how the state of this system changes over time.

Physics EngineDefine layout of your system of objects (shapes, positions, masses, dimensions, global gravity vector, etc...)

Physics EngineThe engine tells you how your system changes over time

Physics SimulationThe process handled by a physics engine that figures out what happens to the given set of objects over a certain period of time is called physics simulation

->Simulation->

Can be:Not Interactive (user input is not taken in consideration)

Interactive (user input affects the simulation). Interactive simulations are used in most games

Physics Simulation

Do you need a physics engine?

Sometimes, it's easier to do it yourself!

Less memory & CPU usageLess disk spaceLess time spent linking librariesSimpler, if you don't need anything fancy

Do you need a physics engine?

Rolling your own physics:

acceleration = force / massThings get trickier with collisions...

Do you need a physics engine?

The Physics of Paper TossForces are one-dimensional

Add flick force and wind force to determine landing point

Animate to make it look pretty

No physics library needed!

Typical Physics Engine

Consists of:

Rigid Body Dynamics Simulation Engine

Collision Detection Engine

Typical Physics Engine

Building blocks of your physics world:Geometric Shapes (describe what your objects look like)

Joints (describe how your objects are connected to each other)

Typical Physics Engine

Typical Physics Engine

Collision contact points generation (collision detection engine)

Creating temporary joints based on contact points, and attaching them to respective physics objects

Performing actual simulation step (rigid body dynamics engine)

Simulation Step:

Simple Simulation Example (Step 1)

Simple Simulation Example (Step 2)

Simple Simulation Example (Step 3)

Performance Tips and Tricks

Keep things simpleMore objects in your physics simulation = more time spent to simulate the system = lower framerate as a result.

Approximate complex volumes with sets of simple volumes

Performance gain is well worth it.User will never see the difference, as long as you do it right. It's still fine to render fully detailed models, while simulating simple shapes on the physics side.

Performance Tips and Tricks

Example of complex volumes approximation.Rendered models:

Performance Tips and Tricks

Example of complex volumes approximation.Simulated shapes:

Performance Tips and Tricks

Performance Tips and TricksDo not simulate static objects

They should never be simulated in Rigid Bodies Dynamics Engine, because they never move.

Do not simulate dynamic objects that are stationary at the moment.

ODE, for example, automatically does this for you. It is called Auto Disable.

Use spatial partitioning

Setup collision detection engine to generate as few contact points as possible

Several small steps vs one large step

Several small steps:

More realistic simulation, especially when simulating dynamically changing forces

Less problems with objects flying through each other.

One large step:

Less realistic simulation

Better performance

Performance Tips and Tricks

Probable instability problems with simulation and their causes:

Large simulation step

Large forces applied to bodies

Large masses, especially when mixed with small masses

High speeds of the objects

Fast spinning objects

High friction

Performance Tips and Tricks

A Brief Comparison of Physics Engines Used on the iPhone

2DBox2DChipmunk

3DODEBullet

Box2DOptimized for 2D gamesWorks well with cocos2dUsed in many iPhone games such as Crayon Physics and Rolando

Comparison of Physics Engines

ChipmunkVery lightweightWritten in pure CMade by the creators of Crayon Ball for the iPhone"Makes you smarter, stronger, and more attractive to the opposite gender!"

Comparison of Physics Engines

Open Dynamics Engine (ODE)Industry veteranSupports full 3D simulationFast, even on the iPhoneUsed in Touchgrind and Ragdoll Blaster

Comparison of Physics Engines

Bullet Physics LibraryComparison of Physics Engines

Highly optimized for many architecturesMulti-threadedThird most popular physics library according to survey by Game Developer Magazine (Aug. 2009)Used by Oolong Engine (Kids vs. Zombies, iPhysics)

Contemporary physics in games on consoles and PC's = the nearest future of physics in mobile games...

jobs@backflipstudios.com

Thanks!

top related