Download presentation

Presentation is loading. Please wait.

Published byKirk Creek Modified over 2 years ago

1
3.2. I NTRODUCTION TO R EAL - TIME P HYSICS Overview of core principles behind real-time physics systems

2
Important concepts and aspects of use within game physics engines The concepts in this section will be tied together in later lectures.

3
Closing velocity, collision direction and contact normal, centre of mass, springs, coefficient of restitution

4
The closing velocity is the total speed at which two objects are moving together, calculated by finding the component of velocity in the direction of one object to the other. In game physics engines, by convention, it is more common to use separating velocity (i.e. opposite direction but same magnitude as closing velocity), given as:

5
The direction in which two objects are colliding is usually called the “collision normal” or “contact normal.” If two objects, body 1 and 2, are colliding then, by convention, the collision normal is given from the first object’s perspective, i.e. from the first body’s perspective the contact is incoming from the second body, i.e. the normal is

6
The centre of mass (or “centre of gravity”) is the balance point of an object. Any separating hyperplane passing through the centre of mass will result in two volumes of equal mass. The centre of mass of a sphere or cuboid of uniform density will be located at the geometric centre point. The centre of mass isn’t always contained within the object (e.g. a donut).

7
Springs have many uses within games, including obvious examples such as a car’s suspension, but also for representing soft and/or deformable bodies. Springs offer a good means of modelling cloth, rope, etc.

8
Video not available in on-line slides

9
Hook’s law states that the force exerted by a spring is linearly dependent upon the spring extension or compression from its rest position, i.e. where l holds the spring length, and l 0 the rest length, and k is the spring stiffness). More generally: Where d is a vector representing the current spring’s extension. The force exerted by the spring is equally applied at both ends of the spring, but in opposite directions, i.e. the spring acts to pull/push the objects together/apart in equal measure but in opposite directions. Aside: Real springs are subject to Hook’s law constrained by their limits of elasticity. In game springs can be assumed to have arbitrary wide limits of elasticity.

10
The application of Hook’s Law can be problematic if applied within an engine that updates the world using discrete steps. A spring with a high stiffness factor combined with a large extension/compression will result in a large applied force. In reality, this force is instantaneous and decreases as soon as the spring moves towards its resting length. Using a discrete time step, there is a danger that the force applied over the whole step will be sufficient to provide a ‘correction’ that results in an even larger expansion/compression in the opposite direction, which in turn, will result in an even greater ‘correction’ in the opposite direction, etc.

11
When two objects collide, they compress together, and the deformation of their surfaces causes forces to build up that bring the objects apart. From the game physics engine’s point of view this happens instantaneously. The vast majority of collisions behave in a dampened spring like manner as: v’ s is the separating velocity and c is the coefficient of restitution. The coefficient of restitution depends on the materials in collision (different pairs of material will have different coefficients). If the coefficient is 1.0, then the objects will bounce apart with the incident speed. If zero, then the objects coalesce and travel together

12
Resolve order and resting contacts

13
An accelerative force acts to change velocity over time. In some cases, e.g. a fast collision, a force is applied over a very short period of time (resulting in a change of velocity). This period of time is too brief to model within the physics engine, hence an ‘instantaneous’ change in velocity is known as an impulse. For forces: For impulses: Aside: Within the physics engine, impulses will not be accumulated, but rather will be instantaneously applied to update a velocity. Normal forces will be accumulated and applied at the end of the simulation step to produce an updated velocity, position, etc.

14
If an object has two simultaneous contacts, and the engine uses an iterative approach, then resolving one contact may change the other contact. The order in which contacts are resolved is important. A physically plausible approach is to resolve the most severe contact first (i.e. the contact with the lowest separating velocity or highest interpenetration) – this also helps avoid unnecessary work as correcting one contact may entail that other points of contact become separated/separating (and do not need to be further considered). Contact 1 Contact 2

15
A problem with this approach is when resolving one contact puts another (previously resolved) contact back into collision. For most systems, this can be managed by iterating over contacts until all have been resolved (or an iteration limit reached). The number of iterations should be at least the number of contacts (to give them all a chance of getting seen at least once) and can be greater. More iterations will be needed to resolve a complex, interconnected set of contact. Contact interpenetration increased

16
Typically, contacts are resolved for closing velocity and interpretation in separate passes, thereby permitting a different ordering when selecting which contact is to be resolved (based on the separating velocity or interpenetration depth). If the stages are combined then no one single optimal ordering is likely possible. Aside: The number of iterations used to resolve interpenetration might not necessarily be the same as the number used to resolving collisions

17
Consider the simulation of a particle resting on the ground and subject to gravity. In the first frame the particle accelerates downward, introducing a non-zero velocity. In the second frame the position is updated, and the velocity increases again. Now it has begun to interpenetrate with the ground. The collision detector picks up on the interpenetration and generates a collision. The contact resolver looks at the particle, corrects the interpenetration and applies a collision response from the contact with the ground (based on closing velocity, material restitutions, etc.). The generated upward velocity will be small, but it may be enough to be noticed given a long frame time.

18
One approach (using micro collisions) towards solving the problem is: Detecting the problem earlier (i.e. smaller velocity to correct) by returning contacts that are nearly, but not quite interpenetrating. If the particular object was stationary in the previous frame and the generated velocity is only due to gravity, then consider it to be a resting contact, and apply an impulse that will result in a zero separating velocity. In effect, the series of micro-collisions keep the objects apart.

19
A more physically realistic approach to handling resting contacts is to apply an upwards force from the ground, pushing the object back so that its total acceleration in the vertical direction becomes zero. Whilst more realistic, this approach is also considerably more complex as there may be multiple points of contact between the body and the ground (i.e. some means of deciding how the resting forces should be distributed across the various points of contact is needed).

20
Consult the recommended course text book for: Development of a range of force generators, including one for gravity and another for a drag force generator Development of spring based force generators – including basic spring, anchored spring, elastic bungee generator, buoyancy force generator, Development of a cable and rod constraint class Development of a simple particle physics engine (based on implementation of Netwon’s first and second laws) and a mass- aggregate physics engine

21
Directed physics reading Directed reading

22
Directed reading Read Chapter 5 of Game Physics Engine Development (pp69-79) on adding forces. Read Chapter 6 of Game Physics Engine Development (pp81-101) on modelling springs.

23
To do: Read the directed reading. Consider if you might wish to develop your own physics engine as your project. Today we explored: Range of important physical concepts. Range of important modelling concepts.

Similar presentations

OK

Motion & Force: Dynamics Physics 11. Galileo’s Inertia Galileo attempted to explain inertia based upon rolling a ball down a ramp Predict what would.

Motion & Force: Dynamics Physics 11. Galileo’s Inertia Galileo attempted to explain inertia based upon rolling a ball down a ramp Predict what would.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on social networking sites facebook Make a ppt on how to control noise pollution Story like ppt on parts of speech Ppt on air pollution act Ppt on different solid figures pictures Spleen anatomy and physiology ppt on cells Ppt on eddy current loss Ppt on blood stain pattern analysis equation Download ppt on query processing and optimization ppt Ppt on nelson mandela life