Advanced Games Development Physics Engines 1 - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Advanced Games Development Physics Engines 1

Description:

Physics engines simulate Newtonian physics for models in a scene. Usually a separate library ... 'Freeze' models when they are moving very slowly, i.e. stop them ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 15
Provided by: lauren80
Category:

less

Transcript and Presenter's Notes

Title: Advanced Games Development Physics Engines 1


1
Advanced Games DevelopmentPhysics Engines 1
  • CO2301 Games Development 1
  • Week 5

2
Todays Lecture
  • Introduction
  • Collision Bodies
  • Physical Properties
  • Relationship with Scene Models
  • Practical Issues

3
Introduction
  • Physics engines simulate Newtonian physics for
    models in a scene
  • Usually a separate library
  • Real-time simulation of movement and interaction
  • Game provides the physical info about the world
  • Static mass, centre of gravity, etc.
  • Dynamic e.g. the forces acting on a model
  • Relationships Joints, degrees of freedom, etc
  • Physics engine simulates movement / collisions
    based on this information

4
Existing Physics Engines
  • A physics engine is difficult to write
  • Core component is a program called a solver
  • Solving simultaneous Newtonian equations
  • Needs precise maths and programming
  • Common to use existing physics engines, e.g
  • Havok Commercial engine popular for games
  • Vortex Commercial engine more targeted for
    simulation
  • ODE Fairly powerful freeware engine
  • SPE Lightweight, free for non-commercial use
  • Newton Freeware engine, easy to use
  • We will look at Newton in the lab

5
Rigid Body Simulation
  • Physics engines can simulate rigid or soft bodies
  • Rigid body simulation more straight-forward
  • Rigid bodies represented by their collision volume
  • The collision volume is a simplification of the
    visual model
  • e.g. a car may be modelled as a box
  • Or character as a set of boxes and cylinders

6
Collision Primitives
  • Can choose the collision volume from a set of
    simple primitives
  • Box (or cuboid)
  • Sphere (or ellipsoid)
  • Cone
  • Cylinder
  • Rounded cylinder (capsule or chamfer)
  • Each treated as a precise mathematical object
    rather than a polygonal mesh
  • Improves the speed of the engine and produces
    smoother movement
  • But simple primitives means inaccurate collision

7
Complex Collision Volumes
  • What if no suitable collision volume for a model,
    or precise collisions required?
  • Can use the boundary of the polygonal mesh of a
    model as its collision volume
  • This is called a convex hull
  • Increases time and memory required for the
    physics simulation
  • But will increase accuracy of collision
  • May be side-effects if the model lacks detail
  • E.g. a polygonal cylinder will not roll as
    smoothly as a mathematical one

8
Physical Properties - Static
  • Each body in the physics engine has some static
    physical properties
  • Mass amount of matter
  • Centre of gravity point of equilibrium of a
    model
  • Moments of inertia how mass is spread around a
    model
  • Elasticity bounciness
  • Friction several types, static, kinetic, rolling
  • Used to apply Newtons laws of motion
  • And to calculate the effect of interactions with
    other models

9
Physical Properties - Dynamic
  • Physics engine bodies also have a further set of
    dynamic properties (current state)
  • Position and orientation
  • Linear velocity current movement
  • Angular velocity current spin
  • Forces e.g. gravity, buoyancy, wind
  • Torques rotational forces, e.g. engine force
    spinning an axle
  • Damping Linear and angular slowing of
    velocities, often used for numerical stability
  • Initial state is set by the game, then state is
    dynamically updated by the physics engine

10
Physical Properties - Relationships
  • Bodies can be connected together
  • These connections usually represent joints
  • E.g. hinges, ball/socket joint, sliding joints
    etc.
  • A joint is defined by
  • The models involved in the joint
  • Degrees of freedom linear and angular, choice of
    these determines the joint type
  • Stiffness and springiness
  • Several joints can be used for more complexity
  • E.g. Chains, machines, rag-dolls, etc.
  • Rag-doll set of primitives connected like a
    human body

11
Physics Simulation Initialisation
  • Create a rigid body in the physics engine for
    each model in our scene
  • Choosing a suitable collision volume
  • Define the static properties for each body
  • E.g. Mass,
  • Define any joints connecting bodies together
  • Initialise the dynamic properties
  • E.g. Initial position and velocity
  • Ensure this matches the model position in 3D
    engine

12
Physics Simulation Update
  • Physics simulation runs in the game loop on a
    tick
  • Same as scene update tick, as it affects scene
    models
  • E.g. might aim to update physics at 50fps (every
    0.02s)
  • Each tick, a new state (position, velocity etc.)
    is calculated for each body
  • To do this, the physics engine needs to know the
    current forces / torques on the models
  • This information is provided by the game
  • The new positions of the physics bodies are
    copied to their scene models equivalents

13
Relationship with Scene Models
  • Implies a change when working with models that
    are in the physics simulation
  • No need to move or rotate these models
  • Although we may occasionally reposition or reset
    them
  • Instead define the forces/torques acting on them
  • Get their positions each frame from their physics
    bodies
  • A significant shift from previous projects
  • Two views of the same data 3D model physics
    body
  • Can be difficult to have precise control over a
    model

14
Practical Issues
  • Physics engines are often numerically unstable
  • Results can be inaccurate/difficult to control
  • Settings must be tweaked carefully to achieve
    efficient and stable results
  • In particular
  • Damp all velocities so movement is easily
    stabilised
  • Dont calculate physics for stationary bodies
  • Freeze models when they are moving very slowly,
    i.e. stop them
  • Limit size of physics world to maximise accuracy
Write a Comment
User Comments (0)
About PowerShow.com