Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Computer Game Physics The very basics. 2 The Basics Force F Mass m Acceleration a: a = F/m Velocity v: v = a*t Position s: s = v*t …if F is constant.

Similar presentations


Presentation on theme: "1 Computer Game Physics The very basics. 2 The Basics Force F Mass m Acceleration a: a = F/m Velocity v: v = a*t Position s: s = v*t …if F is constant."— Presentation transcript:

1 1 Computer Game Physics The very basics

2 2 The Basics Force F Mass m Acceleration a: a = F/m Velocity v: v = a*t Position s: s = v*t …if F is constant

3 3 Conservation of Energy Kinetic Energy + Potential Energy = const. Ek = ½ m * v² Ep = m * g * h

4 4 How far and high will a ball fly, if it is kicked with a speed of 10m/s and an angle of 45 degrees ?

5 5 Game Physics Not trying to build a perfect physical model Most things can be approximated assuming Newtonian physics and rigid bodies Use discrete simulation (constant step) techniques Just worry about center of mass for most things

6 6 Position and Velocity Where is object at time t ? Equations x(t) = t * x_velocity + x_initial y(t) = t * y_velocity + y_initial Computation x = x + x_velocity y = y + y_velocity

7 7 Acceleration Computation x_velocity = x_velocity + x_acceleration y_velocity = y_velocity + y_acceleration Use piecewise linear approximation to continuous functions

8 8 Projectile Motion X = x + V x *t Y = y + V y * t V xi = cos(A) * V i V yi = sin(A) * V i V x = Vx - WR(V x - W)*t V y = V y – (WR(V y ) + G(y))*t W = windspeed (x only) A = inclination angle V i = initial velocity WR = wind resistance G(y) = gravity, depending on height (constant if height doesn’t change dramatically)

9 9 Friction Conversion of kinetic energy into heat Different types: –Static friction –Kinetic or sliding friction –Rolling friction

10 10 Friction Static friction For non moving objects only Can be seen as threshold of force needed to accelerate a mass

11 11 Friction Kinetic and rolling friction Depending on velocity Can be modeled as functions of velocity

12 12 Collisions Detect that collision has occurred (bounding box) Determine the time of the collision (may need to back up to point of collision) Determine where objects are when they touch Determine the collision normal (angle of incidence = angle of reflection) Determine the velocity vectors after the collision using the momentum

13 13 Momentum Momentum p = m * v The total momentum of a closed system is constant, as is the energy. This observation totally defines all collisions

14 14 Example: Collision of 2 spheres Assumption: Sphere 2 has zero velocity before collision Both spheres have same mass We get: Conservation of momentum: p1 = p1’ + p2’ Conservation of energy:m/2 v1²= m/2 v1’² + m/2 v2’² =>p1²= p1’² + p2’² These 2 equations together tell us that (because of the assumption of same mass !) the angle between v1’ and v2’ is 90deg. This makes life simple…

15 15 Collision of 2 spheres p1 p1’ p2’

16 16 Time-Based Modeling Time t is used in all kinematic equations that move objects (to avoid discontinuities caused by “slower” frame rates) This involves scaling dx and dy based on elapsed time (rather than a virtual clock) This allows constant movement regardless of processor slow downs


Download ppt "1 Computer Game Physics The very basics. 2 The Basics Force F Mass m Acceleration a: a = F/m Velocity v: v = a*t Position s: s = v*t …if F is constant."

Similar presentations


Ads by Google