快猫短视频

Get real

COLM MASSEY is playing God again. He鈥檚 messing with the laws of physics, and
it鈥檚 causing havoc for the beings he has created. One minute he can have his
creatures crawling on the ground, held down by the force of a fiercely
exaggerated gravity. The next he can switch off friction so that they slide
round like demented ice-hockey pucks.

Massey is part of a 70-strong team of physicists, engineers and
mathematicians working for MathEngine, a software company based in Oxford.
MathEngine鈥檚 goal is to produce a programming tool that allows games designers
to add the laws of physics to their virtual worlds as easily as today鈥檚 graphics
packages allow them to use shapes, colours and textures. In Massey鈥檚 worlds, the
laws of physics, or at least some of them, are woven into the fabric of virtual
space just as the real laws of physics are built into the real Universe.

It鈥檚 a technique the company hopes will raise the next generation of computer
games to new heights of realism. It could help to build super-realistic
simulators that will be used to train operators of complex machinery. And
farther down the line, physics-based virtual worlds could have far-reaching
implications for researchers hunting through huge data sets or playing with
artificial evolution.

In any computer game, a program creates the illusion of movement by redrawing
successive frames with slight changes in the position of the characters. Until
recently, much of the action involved prerecorded animations that are triggered
by particular incidents in the game. When Lara Croft, the action heroine of the
hit game Tomb Raider, fires her gun at some evil-doer, the computer
confirms the hit and plays a short film of the victim keeling over and falling
on the ground.

MathEngine鈥檚 approach abandons this idea of pre-animation and instead
calculates from scratch most aspects of the movements shown on the screen, based
on the fundamental laws of physics. So developers can get rid of stereotyped,
pre-animated routines and create what every game player craves: a program that
never plays the same way twice. Sprucing up games with rich textures and colours
is no longer enough, says Chris Heckert, a self-taught physics devotee and chief
executive of a games startup company called Definition Six. 鈥淧hysics is having
its day now,鈥 says Heckert.

Building physics into games is a formidable task. Taken one at a time, the
laws of physics are difficult enough to handle in a computer algorithm. Put a
few of them together, and they interact in ways that rapidly become impossibly
complex and unwieldy. Still, the effort is worth making. Even modest progress
will make games look and sound more realistic.

To take a simple example, imagine that a game developer wants to show an
animation of a bat striking a baseball. Rather than creating a generic
animation, he or she creates a 鈥減hysics engine鈥 that uses Newton鈥檚 laws of
motion to calculate how the ball would move in the virtual world of the game.
Using the results of this calculation, the computer then works out how to draw
the ball on the screen in each successive frame. As a result, each hit is a
one-off in which the ball moves slightly differently, depending on exactly how
hard it was hit and in what direction鈥攋ust like in the real world.

With the physics engine in place, games developers can let rip with their
imaginations. 鈥淵ou can write a surfing game that allows the game player to
change the shape of the seabed and waves,鈥 says Tim Milward, the lead software
developer at MathEngine. 鈥淭his puts creativity in the hands of the player. And
there鈥檚 no reason to surf on the ocean: why not surf on a solar flare?鈥

Despite these obvious advantages, physics-based animations have for the most
part been off-limits for programmers till now. 鈥淲e know the laws of physics, but
that doesn鈥檛 mean we know how to implement them on the computer,鈥 says animation
researcher David Baraff, formerly at the Carnegie Mellon University Robotics
Institute in Pittsburgh and now a computer graphics researcher at Pixar
Animation. Baraff鈥檚 pioneering research with physics engines was used to create
the pod-racing scenes in the film Star Wars: Episode I鈥擳he Phantom
Menace.

One problem is the sheer number of objects involved in certain types of
simulation. 鈥淚f someone told me how billiard balls interact, I could easily
predict where a single ball would go when I hit it with my cue,鈥 says Baraff.
鈥淏ut if I dump millions of billiard balls on the table and try to predict which
one will be the first to go into the right corner pocket, that鈥檚 tough.鈥 Yet
that鈥檚 exactly how researchers model the behaviour of things such as smoke
particles and water molecules. Getting reasonable answers in real time is
clearly difficult.

Although faster computer processors will help, the real challenge is to
construct computer code that models the physics efficiently but without hogging
the computing resources. Games developers need to be able to redraw frames
quickly enough to fool the eye. That means roughly one frame every 1/25 of a
second鈥攁nd obviously, the calculations necessary for each frame need to be
completed in that time. 鈥淚n theory you could create an exact model of anything,鈥
says MathEngine researcher Dylan Menzies, 鈥渂ut if you take that approach, you
run into a horrific number of calculations.鈥

Suppose a developer is building a physics-based driving simulator, for
instance. An exact model would take into account not just the speed of the car
and the friction of the road surface, but also minutiae such as the weight of
the driver, the elasticity of the tyres and even their temperature. These last
two variables would depend on how far and how fast the car had been driven. The
computing effort needed to take all that into account would be immense.

Bare essentials

A successful physics engine must dramatically cut the number of calculations
by concentrating on the essentials. A simple model for a car can be made up of
two front wheels that rotate and steer, two back wheels that rotate, and a
chassis to join them together. Given the mass of these components, gravity and a
certain level of friction, a physics engine can calculate how such a car would
travel over any given terrain: whether it would skid on one corner or tip over
at another, for instance. The result would be a realistic driving simulation and
MathEngine has developed just such a model.

The physics of cars moving over solid ground is relatively simple Newtonian
stuff. Other situations are a tougher proposition, especially those, such as the
flow of a fluid over a solid, which involve more than one phase of matter. To
demonstrate how MathEngine tackles such problems, the team has put together a
simulation of a virtual sailboat moving through water. In real life, the forces
acting on a sailboat interact in an extremely complex way. The wind exerts a
force on the sail, which in turn exerts a force on the boat, propelling it
through the water. As the boat moves, the water exerts a force on the keel.
There is both aerodynamic and hydrodynamic drag. The problem is compounded
because these forces are interdependent. Change the orientation of the boat, and
the force on the sail and keel both change. Throw in a few calculations to take
care of the wake behind the boat and the model rapidly becomes nightmarish.

Working out these forces separately isn鈥檛 an option. The computations have to
be done together. 鈥淚f you were doing just one part of the model it would be
easy. But instead you have to solve for all parts at once because one affects
the other,鈥 says Milward. 鈥淲e can create a platform where all of this works
together,鈥 adds William Osborn, MathEngine鈥檚 director of research. To simplify
things, researchers skimp on some of the finer points, such as simulating the
way the boat cuts through waves.

But that鈥檚 where the problems start. When a large number of calculations are
being made, small errors and omissions can begin to add up, eventually creating
nonsensical results. This can lead to anything from a sailboat that won鈥檛 float
to a complete crash of the computer system. The trick that MathEngine is working
on is to find the best combination of numerical problem solving methods to keep
errors under control while maintaining a reasonable level of realism. One way to
monitor for errors is to periodically solve the equations using a more detailed
solution method. The more detailed method takes more time and more computational
power, but it is done only occasionally as a way to confirm the results from the
other method. Another way to avoid errors is to dynamically switch between more
detailed and less detailed solution methods based on what computer
resources are available.

Most games are about characters, however, not inanimate objects. Games
developers want to populate their virtual worlds with aliens, dinosaurs, stuffed
animals or realistic-looking humans. These creatures need to be capable of
independent movement, rather than just following pre-animated routines. Part of
MathEngine鈥檚 goal is to put together the tools necessary for developers to
construct realistic figures.

In the example of Lara Croft鈥檚 hapless victim, a physics engine would see him
as a collection of different shaped masses linked by hinges and ball-and-socket
joints. Shoot him in the stomach and the physics engine will calculate how the
impact throws him backwards, and how his arms and legs flail as he falls. Hit
him in the shoulder, and the physics engine will calculate how he spins off
balance and then tumbles to the ground.

MathEngine has put together a simulation that demonstrates this idea. It
shows a stick figure walking into a metal bar at waist height. Each time the
figure hits the bar at a slightly different angle, it falls over, flailing in a
different way every time. Such a figure could be included in a games-design
package as sophisticated 鈥渃lip art鈥. The game designer would be free to
customise things like the size of the body, facial features and clothing.

First steps

Falling down is relatively easy to simulate, but active motions such as
walking require advanced techniques like those being developed by Massey and his
Intelligent Control Group team at MathEngine. One of their creations is a simple
walking stick figure that looks like nothing more than a pelvis with two legs
attached, each with a knee joint. What is remarkable is that the creature taught
itself to walk, using a system of artificial evolution. Massey starts by giving
the creature the fitness criteria: 鈥淢ove as far as you can forward, while
keeping the centre of mass a certain distance from the ground.鈥 He creates a
hundred similar versions of the computer program that controls the creature鈥檚
movement its 鈥渂rain鈥. He then instructs the computer to test all the versions
for their ability to meet the fitness criteria. The versions that come closest
are then copied and allowed to mutate, and the cycle is repeated.

After several generations, the program that does the job best should emerge.
Massey believes a physics-based environment will help researchers in artificial
evolution develop more lifelike creatures. With the MathEngine toolkit,
researchers will have a ready-made physical environment in which they can
enhance both the brain and the physical shape of new creatures, just like the
real world where evolutionary pressures change the behaviour and the appearance
of organisms.

Graphics aren鈥檛 the only element of a realistic computer game. There鈥檚 sound
to take care of as well. 鈥淪ound conveys information in a very compelling way,鈥
says Dinesh Pai, who is creating computer simulations of the real world at the
Department of Computer Science at the University of British Columbia. 鈥淲ithout
it, the computer graphics environment is impoverished.鈥

Currently, most computer games use a few prerecorded sounds that can be
modified to some extent. But this gives a very limited repertoire. A better way
is to generate each sound dynamically, in direct response to whatever caused it.
This is where a physics-based environment could help. The acoustic
characteristics of each virtual object and its environment could be used to
create sounds.

One method for generating sound was invented by Pai and his former colleague
at the University of British Columbia, Kees van den Doel. Their approach is to
make a computer model of an object鈥攁 wooden box, say鈥攁nd then
compute the way it vibrates when hit. The result is a spectrum of vibrations
that is like a map of the sound it would create when hit by different objects.
This sound map is then saved. When the object is hit in the virtual
world鈥攂y a hammer, say鈥攖he correct sound can be 鈥渞ead off鈥 the map
and generated.

A physics-based environment, such as can be built with MathEngine鈥檚 toolkit,
can provide the input needed for sound-generating systems such as van den
Doel鈥檚. 鈥淥ur algorithms are based on the mechanisms that create the sound,鈥 says
Scott Van Duyne, an engineer at Staccato Systems in Mountain View, California,
which is developing a commercial sound application. MathEngine鈥檚 system can be
used as an input to the sound system. 鈥淭he forces and velocities can be used as
inputs into our algorithms,鈥 says van Duyne.

MathEngine鈥檚 research team is not only focused on creating ever more
realistic games. They have also created a physics-based application for guiding
computer users through three-dimensional environments such as rooms, buildings,
or cities. In this environment, a person sitting at a computer screen sees the
rooms as if looking through a video camera. The program directs the view of the
camera towards items that are deemed important, by assigning a notional physical
property such as electric charge to those items. Imagine, for example, that
somebody is visiting a virtual library and looking at a bookcase full of books.
That person would type in the name of the book he or she is looking for, and the
program would then assign an electric charge to that book. The camera, itself
charged with the opposite polarity, would then automatically shift to that area
of the bookshelf and zoom in on the book. MathEngine demonstrated the technology
in a marketing presentation for Nokia, the Finnish telecomms company.

Simulators that can be used to train people to operate complex machinery in
hazardous environments are another possible application. The company has
collaborated with Partek Forest a manufacturer of tree-harvesting machines based
in Finland. Its tractor-sized machines operate on uneven terrain, felling trees
and moving them about with a giant claw. To work safely the operators need to
learn how to control the claw, which has ten moving parts and swings back and
forth in front of the tractor cab, suspended from a heavy boom. Prerecorded
animations are of little use here, but with MathEngine鈥檚 physics the simulator
can display exactly how the machine operates in an infinite variety of
circumstances.

Other companies are also attempting to squeeze physics into the virtual
world. Ipion in Munich, Germany, and Telekinesys Research in Dublin, Ireland,
are vying to produce comprehensive physics engines for games. But while
MathEngine is putting its effort into producing an engine that is as widely
applicable as possible, these companies are focusing specifically on the
computer games market. 鈥淲e work one-on-one with game developers to solve
specific problems for specific genre games,鈥 says Hugh Reynolds, chief
technology officer at Telekinesys.

They have a battle ahead of them. A physics engine makes a virtual world more
realistic, but that in turn throws up challenges for the games designer. Alan
Milosevic, head of MathEngine, recognises that this can be a problem. 鈥淭he
software developer has to understand quite a lot of physics to make best use of
the toolkit,鈥 he says. If developers find the prospect too daunting, help is at
hand from a team of MathEngine field engineers. In the virtual world, even gods
make house calls.

  • Further reading:
    for demonstrations of physics-based simulations see
    www.mathengine.com,
    www.telekinesys.com/index2.html and
    www.ipion.com/frames.html

More from 快猫短视频

Explore the latest news, articles and features