Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Game Physics. Traditional game physics Traditional game physics –Particle system –Rigid body dynamics –Flexible body dynamics Some state-of-art topics.

Similar presentations


Presentation on theme: "1 Game Physics. Traditional game physics Traditional game physics –Particle system –Rigid body dynamics –Flexible body dynamics Some state-of-art topics."— Presentation transcript:

1 1 Game Physics

2 Traditional game physics Traditional game physics –Particle system –Rigid body dynamics –Flexible body dynamics Some state-of-art topics Some state-of-art topics –Car physics –Fluid dynamics –Rag-doll physics Physics Physics –Rigid body kinematics –Newton’s Laws –Forces –Momenta –Energy 2 Introduction to Game Physics

3 Newton’s Laws Newton’s Laws –1 st Law »“ 靜者恆靜,動者恆成等速度運動 ” –2 nd Law »F = ma = m  v/  t –3 rd Law » 作用力與反作用力 Forces Forces –Gravity / Spring forces / Friction / Viscosity –Torque »  = r X F –Equilibrium 3 Basic Concepts from Physics (1/2)

4 Momenta Momenta –Linear momentum –Angular momentum –Moment of inertia 4 Basic Concepts from Physics (2/2)

5 5 Particles are objects with Particles are objects with –Mass –Position –Velocity –Respond to forces But no spatial extent (no size!) But no spatial extent (no size!) –Point mass Based on Newton Laws Based on Newton Laws –f = ma –x = f / m –v = f / m, x = v Particle Dynamics....

6 6 typedef struct { float m; /* mass */ float *x; /* position */ float *v; /* velocity */ float *f; /* force accumulator */ } *Particle; typedef struct { Particle *p /* array of pointers to particles */ int n; /* number of particles */ float t; /* simulation clock */ } *ParticleSystem; xvfmxvfm states xvfmxvfm xvfmxvfm xvfmxvfm xvfmxvfm xvfmxvfm … Particle n time Basic Particle System

7 7 /* gather states from the particles */ void ParticleGetState(ParticleSystem p, float *dst) { int i; for (i = 0; i n; i++) { *(dst++) = p->p[I]->x[0]; *(dst++) = p->p[I]->x[1]; *(dst++) = p->p[I]->x[2]; *(dst++) = p->p[I]->v[0]; *(dst++) = p->p[I]->v[1]; *(dst++) = p->p[I]->v[2]; } }

8 8 /* scatter states into the particles */ void ParticleSetState(ParticleSystem p, float *src) { int i; for (i = 0; i n; i++) { p->p[i]->x[0] = *(src++); p->p[i]->x[1] = *(src++); p->p[i]->x[2] = *(src++); p->p[i]->v[0] = *(src++); p->p[i]->v[1] = *(src++); p->p[i]->v[2] = *(src++); } }

9 9 /* calculate derivative, place in dst */ void ParticleDerivative(ParticleSystem p, float *dst) { int i; ClearForce(p); ComputeForce(p); for (i = 0; i n; i++) { *(dst++) = p->p[i]->v[0]; *(dst++) = p->p[i]->v[1]; *(dst++) = p->p[i]->v[2]; *(dst++) = p->p[i]->f[0]/p->p[i]->m; *(dst++) = p->p[i]->f[1]/p->p[i]->m; *(dst++) = p->p[i]->f[2]/p->p[i]->m; } }

10 10 /* Euler Solver */ void EulerStep(ParticleSystem p, float DeltaT) { ParticleDeriv(p, temp1); ScaleVector(temp1, DeltaT); ParticleGetState(p, temp2); AddVector(temp1, temp2, temp2); ParticleSetState(p, temp2); p->t += DeltaT; }

11 Mass of a Body Mass of a Body –Mass center Force Force –Linear momentum –P(t) = M v(t) –Velocity (v) Torque Torque –Angular momentum –L(t) = I  (t) –Local rotation (  ) Inertia Tensor Inertia Tensor Reference Reference –www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm 11 Rigid Body Dynamics

12 Spring-mass model Spring-mass model –F = k x –Not a stress-strain model –Lack of Elasticity, Plasticity, & Viscous-Elasticity –Can be unstable 12 Flexible Body Dynamics (1/2)

13 13 Flexible Body Dynamics (2/2) Finite element method Finite element method ( 有限元素法 ) –Solver for ODE/PDE –Boundary conditions –Energy equation –Stress-strain model –Very complicated computing process Conservation of energy Conservation of energy

14 14 Advanced Topics in Game Physics Fracture Mechanics ( 破壞力學模擬 ) Fracture Mechanics ( 破壞力學模擬 ) Fluid Dynamics ( 流體力學 ) Fluid Dynamics ( 流體力學 ) Car Dynamics ( 車輛動力學 ) Car Dynamics ( 車輛動力學 ) Rag-doll Physics ( 人體物理模擬 ) Rag-doll Physics ( 人體物理模擬 )

15 15 Game FX

16 Improve the Visual & Sound Game Effects Improve the Visual & Sound Game Effects Includes Includes –Combat FX –Environment FX –Character FX –Scene FX –Sound FX FX Editor Needed FX Editor Needed –General 3D animation tools can not do it »Key-frame system is not working »FX animation is always Procedurally Procedurally Related to the previous frame Related to the previous frame Small Work But Large Effect Small Work But Large Effect 16 Introduction to Game FX

17 17 FX Editing Tool

18 18 Game Particle Effects Conquer Online

19 During the Combat During the Combat –Weapon motion blur –Weapon effect –Skill effect After the Combat After the Combat –Damage effect FX Editor FX Editor 19 Combat FX

20 20 Combat FX Example

21 Computer Animation : Computer Animation : –Image solution –Blending rendered image sequence »Render too many frames »Divide the frames »Average »Done! 21 Motion Blur – Image Solution

22 In Games, Use Transparent Objects to Simulate the Motion Blur In Games, Use Transparent Objects to Simulate the Motion Blur “False” Motion Blur “False” Motion Blur –Tracking the motion path of the object –Connecting them as a triangular mesh –Use time-dependent semi-transparency to simulate the “blur” –The path can be smoothed using Catmull-Rom spline »Local stability of the curve 22 Motion Blur – Geometry Solution

23 Almost All Game FXs Use this Trick Almost All Game FXs Use this Trick Geometry Object on which the Texture Animation Playing Geometry Object on which the Texture Animation Playing –Billboard –3D Plate –Cylinder –Sphere –Revolving a cross section curve Texture Sequence with Color-key Texture Sequence with Color-key Semi-transparent Textures Semi-transparent Textures –Alpha blending »Source color added to background Demo!!!! Demo!!!! 23 FX Uses Texture Animation

24 The FXs The FXs –Fire / exposure / smoke / dust Initial Value + Time dependency Initial Value + Time dependency Combined with Billboard FX Combined with Billboard FX –Billboard to play the texture animation –Particle system to calculate the motion path Gravity is the major force used Gravity is the major force used Emitter pattern Emitter pattern –Single emitter –Area emitter –Emitter on vertices Demo !!! Demo !!! 24 Particle System for FXs in Combat

25 Weather Weather –Use particle system »Rain »Snow »Wind Fog Fog –Traditional fog »From near to far »Hardware standard feature –Volume fog »Layered fog »Use vertex shader Day & Night Day & Night 25 Environment FX

26 Fatality Fatality –Case by case and need creative solutions Rendering Effects on Skins Rendering Effects on Skins –Environment mapping –Bump map –Normal map –Multiple texture map Flexible body Flexible body –Flexible body dynamics Fur Fur –Real-time fur rendering … 26 Character FX

27 Use a very large box or dome-like model to surround the whole game scene Use a very large box or dome-like model to surround the whole game scene Use textures on the box or dome as the backdrop Use textures on the box or dome as the backdrop Use multiple textures and texture coordinates animation to simulate the moving of the clouds Use multiple textures and texture coordinates animation to simulate the moving of the clouds 27 Scene FX – Sky Box

28 Runtime calculate the position and orientation of the camera with the sun Runtime calculate the position and orientation of the camera with the sun Put textures to simulate the len’s flare Put textures to simulate the len’s flare 28 Scene FX – Len’s Flare

29 Atmospheric light scattering Atmospheric light scattering Caused by dust, molecules, or water vapor Caused by dust, molecules, or water vapor –These can cause light to be: »Scattered into the line of sight (in-scattering) »Scattered out of the line of sight (out-scattering) »Absorbed altogether (absorption) 29 Scene FX – Light Scattering Skylight and sun light Skylight and sun light Can be Implemented by vertex shader Can be Implemented by vertex shader

30 30 Scene FX – Light Scattering Examples With scatteringWithout scattering

31 OGRE Particle System 31 OGRE Particle System Attributes http://www.ogre3d.org/docs/manual/manual_32.html OGRE Particle Editor http://www.game-cat.com/ogre/pe/ParticleEditor_Beta.zip OGRE Particle Editor Tutorial http://www.game-cat.com/ogre/pe/docs/PETutorial.htm

32 Particle System Definition Attributes (Partial) 32 Attribute NameValue FormatDescription quota Maximum number of particles at one time in the system (default 10). material Name of material used by all particles in the system (default none). particle_width Width of particles in world coordinates (default 100). particle_height Height of particles in world coordinates (default 100). cull_each | Cull particles individually (default false). sorted | Sort particles by depth from camera (default false). billboard_type | … Billboard-renderer-specific attribute (default point).


Download ppt "1 Game Physics. Traditional game physics Traditional game physics –Particle system –Rigid body dynamics –Flexible body dynamics Some state-of-art topics."

Similar presentations


Ads by Google