Ray Hedgecock Final Paperx - ACG

tangibleassistantΛογισμικό & κατασκευή λογ/κού

3 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

91 εμφανίσεις

Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

1



Physics Engines

A physics engine is typically a software library that provides an API
through which an approximation of certain physical systems may be simulated.
These systems include rigid body dynamics (including collision detection), soft
body
dynamics, and fluid dynamics. Their main uses today are in computer
graphics, video games and motion picture films. Sometimes, the term is used
more generally to describe any software system that can simulate physical
systems.

There are typically two typ
es of physics engines: the real
-
time engine
and the high
-
precision

engine. The real
-
time engine
is used in applications like
video games and other real
-
time applications, while the high
-
precision engine
requires more CPU/GPU processing power, and is ther
efore not suitable for
real
-
time applications. It is generally used for movies, where scenes are
rendered, then assembled into a continuous stream of frames.

It is also used
in scientific simulations for hyper accurate representations of
physical
systems
.

Scientific Engines

Physics engines have been commonly used on supercomputers since the
1980s for the simulation of fluid dynamics. In this type of simulation, particles
are assigned force vectors that are combined to show circulation and flow. Due
Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

2



to t
he speed and processing requirements of these processes, special
processors called vector processors were developed to accelerate calculations.
These processors are a special type of CPU that implements an instruction set
containing instructions that oper
ate on one
-
dimensional arrays. In other
words, it’s a CPU that can do vector algebra.

One of the first general purpose
computer
s
, called ENIAC, was actually used as
a very simple physics engine. It was used to
calculate ballistics tables for the US mili
tary to
estimate where an artillery shell would land
when fired at varying angles and with varying wind speeds
. The calculations
would be tabulated, and then handed out to the artillery commanders in the
form of a lookup table.

Tire manufacturers have al
so benefited from these engines. They use
them to simulate how new tire tread types will perform under wet and dry
conditions using various types of materials under different types of weight
loading. Companies that manufacture plumbing components, such a
s toilets
and sinks, also use physics engines to simulate fluid flow with varying designs
in materials and physical parameters.



Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

3



Game Engines

In computer games, the opposite result is desired over that of the
scientific engine. Speed is the name of the g
ame here, and game engines are
good at delivering this. Physical accuracy isn’t necessarily the desired result,
but physically accurate approximations are. In other words, it has to look
believable. This is why the simulations in games are geared toward
s providing
a perceptually correct approximation rather than a real simulation.

Game
engines typically do more than just the physics calculations, such as
networking and sometimes incorporate an editor for level design, depending on
the engine.

Collision
Detection

The main task of any physics engine is to perform collision detection,
resolve those collisions and other constraints, and provide the updated
transforms for all of the affected objects.

Objects in games interact with the
player, th
e
environment, and each other.

Most 3D objects in games are represented by two separate meshes. One
of these meshes is
a more

complex and detailed shape
, which is

visible to the
player in the game
. Such a shape could be
a
cup with a handle
. For
the
purpose
of speed, a
cylinder, which is invisible to the player,
is
overlaid on top
of the original mesh and is
used to represent the object to the physics engine
so that the physics engine treats the example
cup

as a simple cylinder.

It
Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

4



would
therefore

be impossi
ble to fire a projectile through the handle on the
cup
without hitting it
, because the
collision detection

model

i
s based on the
cylinder and
doesn’t include any handle
.


The simplified mesh used for physics processing is often referred to as
the

collision geometry
.

This
collision geometry could

be a

bounding box
,
a
sphere, or

a
convex hull
.

Engines that use bounding boxes or bounding
spheres as the final shape for collision detection are considered extremely
simple.
1


Generally a bounding box is only
used for
broad phase

collision
detection
, which

narrow
s

down the number of possible collisions before
the
more costly mesh
-
on
-
mesh collision detection is
calculated

in the
narrow phase

o
f
the
collision detection

algorithm
.

Finite Element
-
Based System

A different system for doing
rigid body
physics is to use a

finite

element
-
b
ased
system. In
this type of system
, a 3
D
volumetric

tessellation

is created of the 3D
object.
A tessellation is t
he process of creating
a two
-
dimensional plane using a repeated geometric shape.
This 2D
representation can then be bent or warped so it exists in three dimensions.



1

http://en.wikipedia.org/wiki/Physics_engine

Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

5



This

tessellation results in a number of finite elements which represent aspects
of the o
bject's physical properties such as toughness, plasticity, and volume
preservation.

Once
the objects

are
constructed, the finite elements are used by
a

solver

to model the stress within the 3D object.

(A solver is nothing more
than software that computes things like min/max problems or solves linear
and non
-
linear equations.)
The stress can be used to
model

fracture,
deformation and other physical effects with a high degree of realism and
uniqueness.

As the number of modeled elements is increased, the engine's
ability to model physical behavior increases.

The visual representation of the
3D object is altered by the finite element system through the use of
a

deformation shader

that is
run on the CPU or

GPU.

Until a few years ago, f
inite e
lement
-
based systems
had

been impractical
for use in games
, mainly

due to the performance
overhead
, but also due to

the lack of tools to create
the
finite element representations out of 3D
objects.

With
the introducti
on of
higher
performance processors and
the creation of
more
tools to rapidly create the volumetric tessellations

required in the games
, real
-
time finite element
systems
have begun

to be used in games
, more and more
. This started with
the game

Star Wars:

The Force Unleashed
, which was released in 2008
.

This
game
used

something called

Digital Molecular Matter

for the deformation and
Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

6



destruction effects of wood, steel, flesh and
plants

using an algorithm
developed by Dr. James O'Brien as a part of his PhD thesis.
2


Projectile Framerates

Another aspect of precision in

discrete collision detection

involves
the

frame
rate

of the simulation. This is the

number of moments in time per
second when physics
calculations are made
.

Each frame is treated as separate
from all other frames, and the space between frames is not calculated.

A low
framerate and a small fast
-
moving

object
can cause

a situation where the
object does not move smoothly through space but instead seems to
jump

from
one point in space to the next as each frame is calculated.

Projectiles moving
at
high enough

speeds will miss targets, if the target is sma
ll enough to fit in
the gap between the calculated frames o
f the fast moving projectile.

Various techniques are used to overcome this flaw, such as

Second Life
's
representation of projectiles as arrows with invisible trailing tails longer than
the gap in frames to collide with any object that might fit between the
calculated frames.

By contrast,

continuous collision detection

such as
what is
used
in

Bullet

or

Havok

does not suffer this problem.




2

http://graphics.berkeley.edu/papers/Obrien
-
GMA
-
1999
-
08/

Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

7



Physics Processing Unit (PPU)

A physics processing unit is a dedicated microprocessor that is designed
to handle the calculations of physics simulations. They are used quite
extensively in the r
ealm of video games. An example of calculations involving a
PPU are things like rigid body dynamics, soft body dynamics, collision
detection, fluid dynamics, hair simulation, cloth simulation (clothing), finite
element analysis and consequently the fractu
ring of objects. The idea with
PPUs is that they take some of the more intense floating point calculations
away from the CPU and free it up to run other processes. PPUs perform much
like a GPU does in that it’s created for a specialized purpose. The ter
m was
originally coined by Ageia’s marketing to describe their PhysX chip to
consumers, but the term has been adapted into main
-
stream terminology to
mean any chip that accomplishes the same process.

Limitations

The main limitation of any physics engine is the precision of the numbers
used in its calculations. This is especially true of physics engines used in video
games. When the precision is too low, rounding errors are introduced that
affect the results and
cause small fluctuations to appear in the model in the
form of artifacts and can drastically change the expected results. Objects will
appear
at unexpected locations and behave in un
-
natural and erratic ways.
The errors can be compounded in situations wh
ere two free
-
moving objects are
Physics Engines


Raymond Hedgecock



Final Paper




Paper 1

8



fit together with a precision greater than what the engine can calculate. This
can lead to an un
-
natural buildup of simulated energy in the object and can
cause the simulated objects to react in completely inaccurate ways.

Any type
of free
-
moving compound physics object can demonstrate this problem, such
as chain links in a chain, or bearings running on a bearing chase surface.
Higher precision will reduce this issue, but at a higher CPU cost.

List of Physics Engines

The f
ollowing is a list of real
-
time and high
-
precision physics engines.
This is not a comprehensive list, but lists the more common engines.

Real
-
time, open source engines:



Box2D



Bullet

& JBullet



Chipmunk
P
hysics
E
ngine



A
2D physics engine
.



Farseer Physics
Engine



A
2D physics engine for

Microsoft XNA

and

Silverlight
.



Newton Game Dynamics



Open Dynamics Engine



PAL (Physics Abstraction Layer)



A uniform API that supports multiple physics engines
.



Physics2D.Net



2D physics engine for the

.NET Framework

2.0 o
r greater.

Real
-
time, closed source engines:



Unreal


This is a game engine, but incorporates a powerful physics engine.



Quake


Again, a game engine, but the first of its kind to use pre
-
processed 3D environments.

High precision physics engines:



VisSim


Visual simulation engine for linear and nonlinear dynamics



Working Model


Created by Design Simulation Technologies