Вы находитесь на странице: 1из 6

Physics Engine for Simulation

R. Gaurav Agarwal
B. Tech Information Technology
R.M.K. Engineering College, Kavaraipettai, Chennai
India
E-mail: gauravagarwalr@aol.com Ph: 9176343852
Abstract- This paper explores the use of Physics Engine in Hybrid methods are possible that can be created
various fields such as in Development of Video Games, with the help of dedicated hardwares.
Computer Graphics, Film Making (Animation) and
Simulations. A clear illustration of the need for physics engine
can be seen in Fig. 1.
Most Virtual Reality (VR) applications use
libraries called physics engine for enforcing physics laws in
their virtual worlds. Although the concept of using physics
engines is ideal for development of VR applications, in
practice it does impose many limitations. For instance,
there are many physical laws created by nature, and one
physics engine cannot provide all of them.

Each physical law can be implemented


differently based on the requirements. Some of them are
optimized for fast response whereas others are designed for
being precise.

Keywords- Physics Engine, Virtual Reality, 3D Engine

I. INTRODUCTION

A physics engine is computer software that


provides an approximate simulation of certain simple
physical systems, such as rigid body dynamics
(including collision detection/response), soft body
dynamics, and fluid dynamics, of use in the domains
of computer graphics, video games and film. Their
main uses are in video games (typically as
middleware), in which case the simulations are in Fig. 1 These are four examples of a physics engine simulating an
real-time. The term is sometimes used more generally object falling onto a slope. The examples differ in accuracy of the
to describe any software system for simulating simulation:
physical phenomena, such as high-performance
1. No physics
scientific simulation. 2. Gravity, no collision detection.
3. Gravity and collision detection, no rotation
There are generally two classes of physics calculations.
engines, real-time and high-precision. High-precision 4. Gravity, collision detection and rotation calculations.
physics engines require more processing power to
calculate very precise physics and are usually used by II. BASIS FOR A PHYSICS ENGINE
scientists and computer animated movies. In video
games, or other forms of interactive computing, the A Physics Engine is a collection of library files
physics engine simplifies its calculations and lowers which implement complex algorithms to identify and
its accuracy so that they can be performed in time for provide approximate simulation of certain simple
the game to respond at an appropriate rate for physical systems, such as rigid body dynamics, soft
gameplay. This is referred to as real-time physics. body dynamics and fluid dynamics.
Computer games use physics engines to improve
realism. There are many solutions and challenges for a
Physics Engine. The different physical systems are as
discussed below:
A. Rigid-body dynamics C. Fluid Simulation

Rigid body dynamics is the study of the Fluid simulation is an increasingly popular
motion of rigid bodies. Unlike particles, which move tool in computer graphics for generating realistic
only in three degrees of freedom, rigid bodies occupy
animations of water, smoke, explosions, and related
space and have geometrical properties, such as a
center of mass, moments of inertia, etc., that phenomena. Given some input configuration of fluid
characterize motion in six degrees of freedom (three and scene geometry, a fluid simulator evolves the
directions plus rotation in three directions). Rigid motion of the fluid forward in time, making use of
bodies are also characterized as being non- the (possibly heavily simplified) Navier-Stokes
deformable, as opposed to deformable bodies. As equations which describe the physics of fluids. In
such, rigid body dynamics is used heavily in analyses computer graphics, such simulations range in
and computer simulations of physical systems and
complexity from extremely time-consuming high
machinery where rotational motion is important, but
material deformation does not have a significant quality animations for film & visual effects, to simple
effect on the motion of the system. real-time particle systems used in modern games.
Some techniques for liquid simulation is as follows:
The Rigid-body dynamics basically must
deal with:  Eulerian grid-based methods
 Smoothed particle hydrodynamics (SPH)
 Rigid body linear momentum
 Rigid body angular momentum methods
 Angular momentum and torque  Vorticity-based methods
 Lattice Boltzmann methods
B. Soft body dynamics
III. CHALLENGES AND APPROACHES
Soft body dynamics is a field of computer
graphics that focuses on visually realistic physical The various challenges for a Physics Engine
simulations of the motion and properties of is handling deformable objects and simulating soft-
deformable objects (or soft bodies). Unlike in body dynamics.
simulation of rigid bodies, the shape of soft bodies
can change, meaning that the relative distance of two
points on the object is not fixed. While the relative
distances of points are not fixed, the body is expected
to retain its shape to some degree (unlike a fluid).
The scope of soft body dynamics is quite broad,
including simulation of soft organic materials such as Fig. 2 Depicting the compression and expansion phases of a
muscle, fat, hair and vegetation, as well as other collision between two solid bodies.

deformable materials such as clothing and fabric.


One other difficulty is in calculating Time-
Generally, these methods only provide visually
of-impact (TOI) problems of real world.
plausible emulations rather than accurate
scientific/engineering simulations, though there is Some of the solutions to these problems are
some crossover with scientific methods, particularly use of Ragdoll physics (a form of procedural
in the case of finite element simulations. Several animation).
physics engines currently provide software for soft-
body simulation. This simulation can be done by To solve the TOI problems two approaches
using a variety of approaches: are suggested.

 Mass-spring models  One solution is based on Brian Mirtich’s


 Finite element simulation concept of Conservative Advancement. The
 Energy minimization methods linear convex cast or the Swept Sphere as
 Shape matching described by Gino van den Bergen is an
 Rigid-body based deformation specific case of this.
A swept sphere is a 3D object that can that used to be obtained solely from wind tunnel
be created by pulling, or sweeping, a sphere testing.
along a path, leaving a trace that kind of
Tire manufacturers use physics simulations
resembles the shape of toothpaste when it comes to examine how new tire tread types will perform
out of the tube. While sweeping, the radius of the under wet and dry conditions, using new tire
sphere may be changed, and the path does not materials of varying flexibility and under different
need to be a straight line. Quite often, though, levels of weight loading.
swept spheres are used in collision detection as
Electronics manufacturers use fluid dynamic
an alternative to bounding boxes. In these cases,
modeling to examine how cooling air will flow
most of the time the path is a straight line and the through the computer case, to locate thermal hotspots
radius stays fixed. The object that is created by that may need additional cooling.
sweeping a sphere like that is a cylinder with
hemispheres, which have the same radius as the B. Gaming Engines
cylinder, attached to both ends. Detecting if a
In most computer games, speed of
point is within this object is computationally simulation is more important than accuracy of
quite simple, often easier than doing this with a simulation. Typically most 3D objects in a game are
bounding box. represented by two separate meshes or shapes. One of
these meshes is a highly complex and detailed shape
 The other solution is featured based, and which the player sees in the game, for example a vase
calculates the TOI per feature pair. In with elegant curved and looping handles. However,
particular, Redon’s Algebraic Continuous for purposes of speed, a second highly simplified
Collision Detection method. invisible mesh is used to represent the object to the
physics engine. To the physics engine, the object may
IV. APPLICATIONS be processed as nothing more than a simple tall
cylinder. It is therefore impossible to insert a rod or
A. Scientific Engines fire a projectile through the handle holes on the vase,
because the physics engine does not know the
handles exist and only processes the rough cylindrical
Physics engines have been commonly used
shape. The simplified mesh used for physics
on supercomputers since the 1980s to simulate the processing is often referred to as the collision
flowing of atmospheric air and water, in order to geometry. This may be a bounding box, sphere, or
predict weather patterns. This is known as convex hull. Engines that use bounding boxes or
computational fluid dynamics modeling, where bounding spheres as the final shape for collision
particles of air are assigned a force vector, and these detection are considered extremely simple. Generally
combined forces are calculated across vast regions of a bounding box is used for broad phase collision
detection to narrow down the number of possible
space to show how the overall weather patterns will
collisions before costly mesh on mesh collision
circulate. Due to the requirements of speed and high detection is done in the narrow phase of collision
precision, special computer processors known as detection.
vector processors were developed to accelerate the
calculations. // Object-to-object 2D bounding-box collision
detector:
Generally weather prediction is still an short int Sprite_Collide(sprite_ptr object1, sprite_ptr
inaccurate science because the resolution of the object2)
{
simulated atmosphere is not detailed enough to match
int left1, left2;
real-world conditions, and small fluctuations not int right1, right2;
modeled in the simulation can drastically change the int top1, top2;
predicted results after several days. int bottom1, bottom2;

Similar fluid dynamic modeling is also commonly left1 = object1->x;


used for designing new types of aircraft and left2 = object2->x;
watercraft, and can provide engineers the information right1 = object1->x + object1->width;
right2 = object2->x + object2->width;
top1 = object1->y; properties (toughness, plasticity, volume
top2 = object2->y; preservation, etc...). Once constructed, the finite
bottom1 = object1->y + object1->height; elements are used by a finite element solver to model
bottom2 = object2->y + object2->height; the stress within the 3D object. The stress can be used
to drive fracture, deformation and other physical
if (bottom1 < top2) return(0); effects with a high degree of realism and uniqueness.
if (top1 > bottom2) return(0); As the number of elements in such a system is
if (right1 < left2) return(0); increased, its ability to model the physical behavior
if (left1 > right2) return(0); of the object increases. The visual representation of
the 3D object is altered by the finite element system
return(1); through the use of a deformation shader which either
}; runs on the CPU or on the GPU. Finite Element-
based systems have been impractical for use in games
A fairly simple algorithm for 2-dimensional in the past due to the performance overhead as well
objects is as given above. Below Fig. 3 depicts how a as the lack of tools to create finite element
physics engine helps in improving the gaming representations out of 3D art objects. With the advent
experience by making it realistic. of high performance CPUs and GPUs as well as tools
to rapidly create the volumetric tessellations, it is
now practical to have real-time finite element
systems in games. The first game to use a real-time
finite elements-based physics system was "Star Wars:
The Force Unleashed" (TFU) by LucasArts
Entertainment. TFU used the newly-created Digital
Molecular Matter (DMM) physics engine by Pixelux
Entertainment for the deformation and destruction
effects of wood, steel, flesh and plants. The
deformation and fracture performed by the DMM
solver used an algorithm developed by Dr. James
O'Brien as a part of his PhD thesis "Graphical
Modeling and Animation of Brittle Fracture".

In the real world, physics is always active.


Fig. 3 a) Depicting boxes placed on top of planks. There is a constant Brownian motion jitter to all
particles in our universe as the forces push back and
forth against each other. For a game physics engine,
such constant active precision is unnecessary and a
waste of the limited CPU power. For example, in the
3D virtual world Second Life, if an object is resting
on the floor and the object does not move beyond a
certain minimal distance in about two seconds, then
the physics calculations are disabled for the object
and it becomes frozen in place. It remains frozen
until a collision occurs with some other actively
physical object, and that reactivates physics
processing for the object. This freezing of stable non-
moving objects allows the physics engine to conserve
processing power and increase the framerate of other
Fig. 3 b) Boxes thrown into air due to an explosion, simulated with objects currently in motion, but can lead to unusual
help of a Physics Engine. problems such as a huge slow pendulum freezing in
place on the upswing, as it slows down and starts to
An alternative to using bounding box-based reverse direction. Often this process of deactivating
rigid body physics systems is to use a finite element- non-moving objects is referred to as "sleeping"; and
based system. In such a system, a 3-dimensional, some physics engines provide the ability to prevent it,
volumetric tessellation is created of the 3D object. ensuring such anomalies never occur, at the expense
The tessellation results in a number of Finite of always consuming processing power.
Elements which represent the object's physical
The primary limit of physics engine realism feel of real world desktops. A workspace in the
is the precision of the numbers representing the physical world typically has piles of documents.
position of an object and the forces acting on that Binders and other objects arranged in a way that
object. When the precision is too low, errors can provides considerable subtle information to the
creep into the calculations due to rounding, causing owner. Adding realism to the virtual desktop such
an object to overshoot or undershoot the correct that certain valuable characteristics of the real world
position. These errors are compounded in situations can be applied using physics engines is aim of
where two free-moving objects are fitted together creating a BumpTop.
with a precision that is greater than what the physics
engine can calculate. This can lead to an unnatural
buildup energy in the object due to the rounding
errors, that begins to violently shake and eventually
blow the objects apart. Any type of free-moving
compound physics object can demonstrate this
problem, but it is especially prone to affecting chain
links under high tension, and wheeled objects with
actively physical bearing surfaces. Higher precision
reduces the positional/force errors, but at the cost of
greater CPU power needed for the calculations.

C. Other Uses

1) Surgery Simulation: Fig. 5(a) Typical virtual desktop with structured organization. (b)
Real desk, where items are casually organized. (c) A BumpTop
Surgery simulations are of prototype with piles as the fundamental organizational object, and
significant value in medical training as they provide a physical simulation affording casual, potentially more realistic
interaction.
less costly mean of training new surgeons. The
quality of a surgery simulation is defined by how V. HARDWARE UNITS
realistic it is in a physical sense. These physics
aspects however have little to do the high-level A physics processing unit (PPU) is a
functionalities of the application. In particular, laws dedicated microprocessor designed to handle the
are needed for simulating cutting and skin calculations of physics, especially in the physics
deformation. engine of video games. Examples of calculations
involving a PPU might include rigid body dynamics,
soft body dynamics, collision detection, fluid
dynamics, hair and clothing simulation, finite
element analysis, and fracturing of objects. The idea
is that specialized processors offload time consuming
tasks from a computer's CPU, much like how a GPU
(Graphics Processing Unit) performs graphics
operations in the main CPU's place.

The first dedicated Physics Processing Unit


(PPU) from Ageia (later merged into nVidia), called
PhysX, which functions in a similar manner to the
Graphic Processing Unit (GPU) in a graphics card -
off-loading the majority of the physics processing
weight off the CPU and into a dedicated processor.
The unit was most effective in accelerating particle
systems. Only a small performance improvement was
Fig. 4 Class Hierarchy of Physical Objects in Surgery Application. measured for rigid body physics.

2) Virtual Desktop – A BumpTop:

Despite the metaphor, current


virtual desktops bear little resemblance to the look or
hardware interface. AMD has also announced the
AMD Stream Processor product line which combines
a CPU and GPU technology on one chip.

VI. FUTURE WORK

A Physics Engine can be used to solve


certain real-world problems where collision can be
detected and provide a response to it. These engines
can thereby, be used to detect collisions well in
advance using a complex set of inputs. Hence, the
simulation can be used for providing a mechanism to
trigger a response for the possible collision.

REFERENCES

[1] Collision Detection with Swept Spheres and


Fig. 6 Ageia’s Physics Processing Unit (PPU). Ellipsoids by Jorrit Rouwé from
http://www.three14.demon.nl/
GPGPU ("General Purpose processing on
Graphics Processing Unit") is another promising [2] Continuous Collision Detection and Physics
approach for realtime physics engines, including rigid by Erwin Coumans, Sony Computer
body dynamics. ATI and NVIDIA provide rigid body Entertainment.
dynamics on their latest graphics cards. [3] http://www.howstuffworks.com/
[4] Role of Extensible Physics Engine in
NVIDIA's GeForce 8 Series supports a
Surgery Simulations by Saeid Nourian,
GPU-based Newtonian physics acceleration
technology named Quantum Effects Technology - Xiaojun Shen and Nicolas D. Georganas.
which will compete directly with the PhysX PPU [5] Keepin’ It Real: Pushing the Desktop
hardware. NVIDIA provides an SDK Toolkit for Metaphor with Physics, Piles and the Pen by
what they call CUDA (Compute Unified Device Anand Agarwala and Ravin Balakrishnan.
Architecture) technology that offers both a low and [6] www.wikipedia.com
high-level API to the GPU. Few technical details are [7] http://www.gamedev.net/
available about the physics side of it, and it is not yet
clear whether this is part of Havok FX SDK, and/or
nVidia PhysX SDK, or a completely separate engine.

Fig. 7 NVIDIA’s GeForce 8800Ultra.

ATI & AMD offer a similar SDK for their


ATI-based GPUs and that SDK and technology is
called CTM (Close to Metal) which provides a thin

Вам также может понравиться