260 likes | 671 Views
Mathematics in Computer Games. Nicolas Redfern. Maths in Games. There are many uses for maths in games: Object interaction/collisions Gravity and other forces Breakable objects Realistic vehicle movement Realistic positional sound Particle systems Lighting. Object Interaction/Collisions.
E N D
Mathematics in Computer Games Nicolas Redfern
Maths in Games There are many uses for maths in games: • Object interaction/collisions • Gravity and other forces • Breakable objects • Realistic vehicle movement • Realistic positional sound • Particle systems • Lighting
Object Interaction/Collisions • Through use of mechanics, it is possible to allow objects in a game to collide realistically with each other. • Collisions are calculated using the following formula: v2-v1=-e(u2-u1) • u2 and u1 are the velocities before collision, and v2 and v1 are the velocities after collision. • e is the coefficient of restitution. In a game this would be set by the developers.
Gravity • Gravity is simulated in games to ensure that objects fall realistically. • On earth, the acceleration due to gravity is 9.8 m/s2.
Calculating the Height of the Tower • The items all took 2 seconds to fall (t) • Acceleration (a) (due to gravity) is 9.8 m/s2 • The initial velocity was 0 m/s2 (u) • Distance travelled is worked out using: s=ut+½at2 • s=0+9.8 (2)2/2 • s=19.6 m s=? u=0 v= a=9.8 t=2
Momentum in Portal • Portal is an action/puzzle game, that makes use of momentum in its puzzles.
Lighting • Lighting is of immense importance to games. A game can be much more immersive, if the lighting is realistic. • Often, dynamic lights are used, for moving light sources. + = colour luminance(colour)*colour
Illustrative Lighting in Team Fortress 2 Team Fortress 2 uses a cartoon-like look to achieve a unique visual style and comedic effect. It uses complex equations to produce lighting effects.
Character Lighting Equation • This is the equation that determines the lighting for characters in Team Fortress 2: • Spatially-varying directional ambient • Modified Lambertian terms • Unclamped Lambertian term • Scale, bias and exponent • Warping function • Albedo
Realistic positional sound • Many games use positional sound: this is where sound varies depending upon where it is coming from. • Another way in which sound is made more realistic is varying it upon the surrounding, environment. • The Doppler effect can also be simulated in game: as an object moves towards you, the sound becomes lower in pitch, and continues to do so as it moves away. • In Day Of Defeat: Source, another effect is applied: sounds far from the player lack higher frequencies and thus sound more like they naturally would, for example, abrupt pops for gunshots.
Breakable objects • Having objects that can be broken up, adds another level of realism to a game. • Usually, only certain objects can be broken, such as crates and fragile items.
Bibliography • Jason Mitchell, Moby Francke and Dhabih Eng, "Illustrative Rendering in Team Fortress 2," International Symposium on Non-Photorealistic Animation and Rendering, 2007 • Games: • Half-Life 2, Day Of Defeat: Source, Portal and Team Fortress 2 (Valve) • Garry’s Mod (Garry Newman) • Crysis (Crytek)