Gentle Introduction to Physics in Games and Demos
Transcript of Gentle Introduction to Physics in Games and Demos
![Page 1: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/1.jpg)
Gentle Introduction to Physics in Games and Demos
Jetro LauhaSeminar presentation
Assembly 2005, 28th - 31st July 2005
![Page 2: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/2.jpg)
Contents
● Basic components of physical simulation● Integration to the application● Physics featured in demoscene releases and
case study of Stair Dismount and sequels● Questions & Answers
![Page 3: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/3.jpg)
Basic Components ofPhysical Simulation
● Kinematics● Rigid body dynamics● Constraints and joints● Collision detection
![Page 4: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/4.jpg)
Kinematics
● Single particle– Mass
– Position
– Velocity
– Applied forces (e.g. gravity)
● Can be joined together with springs or constraints– Jakobsen's Verlet-system as an example (later)
![Page 5: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/5.jpg)
Rigid Body Dynamics
● Extension to particle physics– Orientation
– Angular velocity
– Shape
– Center of mass
– Inertia tensor
● Forces applied to arbitrary point– Relative to center (typically center of mass)
[Smi04]
![Page 6: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/6.jpg)
Constraints and Joints
● Joints limit degrees of freedom– position: 3, orientation: 3 – collectively 6
● Constraints, examples:– limit position to given region
– force position to given plane
– limit angle of hinge joint between given minimum and maximum angle
[Smi04]
∢=[15° ..75° ]
![Page 7: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/7.jpg)
Collision Detection
● Coarse test● Detailed contact
– position
– normal vector
– penetration depth
● Collision handling– body & surface material
properties (bounciness, slippiness) => coefficient of restitution, friction forces
A. B.
[Smi04]
![Page 8: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/8.jpg)
Integration to the Application
● Proxy geometries● Updating simulation● Use of existing packages (Middleware)● Verlet integration [Jak01]
– Short look at one specific physics implementation technique
![Page 9: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/9.jpg)
Proxy Geometries
● Primitive geometries– approximate given part of
original detailed model
● Physics simulator's understanding of the model – Rendering code handles
modification of detailed model to match with the proxy geometries (orientations, skinning)
![Page 10: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/10.jpg)
Updating Simulation
● Game applications contain several logical clocks– updating of game logic
– physics simulation
– rendering
● Use fixed size time step for physics simulation– Despite of several papers
recommending dynamic oneLa
st F
ram
e
subs
tep
subs
tep
subs
tep
Nex
t Fr
ame
Simulation Time
Game Time
[McL03, adaptation]
![Page 11: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/11.jpg)
Use of Existing Packages (Middleware)
● Saves implementation time● Saves development costs● Applicability to be carefully evaluated
AI & Planning Player Control Game Logic
Physics
Geometry Database Import and ExportGraphics Pipeline
[McL03, adaptation]
![Page 12: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/12.jpg)
Verlet Integration
● Simple, fast, relatively stable● Single particles, clothes, plants, ragdolls● Rigid bodies
– Combined from particles with constraints
– Simple basic building blocks used to create more complex systems
● Used in Hitman– Developer by IO Interactive, published by Eidos
[Jak01]
![Page 13: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/13.jpg)
Verlet Integration
x '=2 x−x*a⋅ t2
x*=x
[Jak01]
F=ma
x* previous position
2 x−x*=x x−x*x−x*~v
● Verlet integration
x=xv⋅ tv=va⋅ t
● Euler integration
![Page 14: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/14.jpg)
Verlet Integration[Jak01]
#define DAMPING (0.999)#define TIMESTEPSQ (0.02 * 0.02)
...
// pos,oldPos = position and previous position// accumForces = combined forces affecting// the particle
Vector3 pos, oldPos, accumForces;
...
pos += DAMPING * (pos – oldPos) + accumForces * TIMESTEPSQ;
![Page 15: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/15.jpg)
Verlet Integration[Jak01]
Particles too close each other
Particles too far from each other
Constrained tofixed distance
Body built ofparticles and constraints
![Page 16: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/16.jpg)
Verlet Integration[Jak01]
Separate collision systemwith particle system usedto define body rotation
Pin joint (ball-and-socket)
Hinge joint
![Page 17: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/17.jpg)
Physics Featured inDemoscene Releases
● Some demos featuring physics simulation
● Case study: Stair Dismount and sequels
![Page 18: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/18.jpg)
Some Demos FeaturingPhysics Simulation
Trauma:Mindtrap08/1997
tAAt:Laatukauraa -Quality Oat08/2002
PlayStation 2
Floppy:Dream Equation
10/2002&
Dream Equation II07/2003
Faktory:Feed your machine08/2003&47'111.008/2004
Screenshot from pouet.net
![Page 19: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/19.jpg)
Some Demos FeaturingPhysics Simulation
Fairlight:Digital Dynamix
08/2003
Mayoneez andthe boys:MOPED08/2004
Lonely Coders:Cubic Revolution
08/2004
4 KB intro
Nesnausk!:in.out.side:the shell05/2005
Screenshot from pouet.net
Screenshot from pouet.netScreenshot from pouet.net
![Page 20: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/20.jpg)
Case Study:Stair Dismount and Sequels
● Porrasturvat (Stair Dismount) – Assembly'02– Stairs and a ragdoll
● Rekkaturvat (Truck Dismount) – Assembly'03– Truck and the ragdoll, mini editor (ramps etc.)
● Dismount Levels (Preview) – Assembly'04– Generic editor, integrated scripting language
– Still in development (looking for contributors)
– Has small community
![Page 21: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/21.jpg)
Case Study:Stair Dismount and Sequels
● Juice used to model ragdoll● Use of open source libraries have saved a lot
of effort and time with development– SDL, SDL_image, SDL_mixer, FMOD, zlib, CFL,
libpng, libjpeg, ODE, libcurl, expat, libogg, AngelScript, TinyXml, Mersenne Twister
– Turska – limited but simple framework/UI library as spin off from the games, features-added-as-needed http://turska.sourceforge.net (v0.1.1)
![Page 22: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/22.jpg)
Case Study:Stair Dismount and Sequels
Ragdoll model in Juice
![Page 23: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/23.jpg)
Case Study:Stair Dismount and Sequels
![Page 24: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/24.jpg)
Case Study:Stair Dismount and Sequels
[Smi04]
![Page 25: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/25.jpg)
Case Study:Stair Dismount and Sequels
![Page 26: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/26.jpg)
Case Study:Stair Dismount and Sequels
![Page 27: Gentle Introduction to Physics in Games and Demos](https://reader031.fdocuments.in/reader031/viewer/2022020706/61fc9ab69d50e757a5218ec9/html5/thumbnails/27.jpg)
Questions & Answers
● My home page: http://jet.ro– This presentation will be available there.
● Other links– ODE: http://ode.org
– Dismount games: http://jet.ro/dismount/
– Juice: http://www.natew.com/juice/Viittaukset
Jak01 Jakobsen, T., Advanced Character Physics, Game Developers Conference, 2001.http://www.gdconf.com/archives/2001/ [2005-06-21]http://www.gamasutra.com/resource_guide/20030121/jacobson_01.shtml [2005-06-21]
McL03 McLaurin, M., Outsourcing Reality: Integrating a Commercial Physics Engine, 2003.http://www.gamasutra.com/resource_guide/20030121/maclaurin_01.shtml [2005-06-21]
Smi04 Smith, R., Open Dynamics Engine User Guide, 2001-2004.http://ode.org/ode-latest-userguide.html [2005-06-21]