Videogames are getting seriously physical: The engine is the real-time force of nature. Now when you fight, the entire game environment fights back.

By Mark Frauenfelder

The cartoon babe on the screen has blond pigtails and a sexy leather outfit
with strategically placed peepholes in the pants. Her expression radiates
confidence as she floats in black space above a thin white line representing
the floor. She's ready for anything.

"I'll turn on the gravity," says Mike Skolones, an athletic, sandy-haired
engineer at MathEngine,
a British software firm whose US branch offices occupy a rustic building
in Petaluma, California.

He punches a key and the figure drops to the ground. Landing on her feet,
she flaps her arms and nearly falls on her face. She manages to find her
footing and stands upright again, beaming.

"Watch what happens when
I drop her from a greater height," Skolones says. This time, her knees
buckle upon impact and she
crumples forward - still smiling - into a heap of twitching limbs.
It looks painful.

"One of the neat things about building physics into a game is that things
don't happen the same way twice," says Skolones, who holds a PhD in physics
from UC Davis. "See, I'll drop her from the same height again." She hits
the ground, tumbles backward, and flops to one side.

When you see a typical game's spectacular crash-and-burn scene
for the second or third time, the illusion of being in an alternate universe
evaporates and you find yourself sitting before a video screen. But whenever
Skolones' model falls,
it happens differently, as though she were a real body plummeting through
real space onto a real floor. Her body's every twist, turn, and tumble
is computed in real time
by MathEngine's physics toolkit, a package of code that lets programmers
define virtual objects and environments in terms of physical characteristics.
"To reproduce that behavior using conventional animation," the engineer
says, "you'd need to animate an infinite number of sequences."

I witness a more subtle demonstration of real-time physics simulation at
the tiny Palo Alto office of Havok, a competing physics-engine shop. On
the screen, a computer-generated sailboat floats in a stone-lined pool
of water. The company's genial Irish-born cofounder, Hugh Reynolds, shows
me how to push the boat with a mouse. When I nudge it, air fills the sail,
causing the ship to tilt leeward. Ripples in the water deflect off the stones,
intersecting with one another. I urge the boat onward, and it glides
effortlessly
into the wall. Reynolds tosses in a handful of virtual coins; they spin
through the air, splash into the water, and sink.

"It's so much fun to play with this stuff that it's hard to get our engineers
to do any work," Reynolds says with a grin.

I don't doubt it. I've never encountered a digital simulation that seemed
so real. It isn't the graphics; I've seen better CG
demos. But here the world behind the screen doesn't just compute, it responds.
It's as though someone sprinkled pixie dust on the processor. Suddenly,
there's a there there, a tangible world inside the box.

After decades of academic research, industrial use, and government development
- and one notable commercial flop - real-time physics simulation is pumping
games full
of dynamic realism to match their visual verisimilitude. MathEngine and
Havok (which, after swallowing various contenders, have no direct competitors
apart from each other) have already licensed their engines to some two
dozen gamemakers.

MathEngine signed up Argonaut Games (creator of the best-seller Croc:
Legend of the Gobbos) and Vivid Image (developer of Street
Racer). Sony Online recently used MathEngine's algorithms to spice
up its demo of PlanetSide, a follow-up to the multiplayer
smash, EverQuest.

Havok counts among its licensees Acclaim, Blizzard, Ubisoft, and Valve.
Now it's poised to storm
the Internet; last May, Macromedia incorporated Havok technology into the
latest 3-D-capable version of the popular Shockwave multimedia player.

In an unnamed adventure title in development at Nihilistic Software, Havok's
code is being used to liberate the game world's inhabitants from the
constraints
of scripted action. "We have a character who's very agile; he can grab
a wall or leap onto a pole, and do all kinds
of wacky acrobatics," says RobHuebner, Nihilistic's technology director.
"Physics is the core of our gameplay."

And it costs. MathEngine licenses its software development kit, or SDK,
for $50,000 per title; Havok charges between $40,000 and $70,000 per game,
depending on options. Little surprise that some gamemakers are brewing
their own physics code. Texas-based developer Motorsims, for instance,
hired both a former Boeing engineer and a PhD with expertise in vehicle
collisions to help develop its racing games AMA Superbike
and Trans Am.

Why the sudden frenzy of interest in physics? For the most part, the answer
lies in the dramatic improvements in game platforms. New home computers
and the latest Net-ready consoles (notably
the Xbox, which incorporates a 733-MHz Pentium III plus a 250-MHz graphics
processor) free up the central processor for physics calculations by delegating
rendering tasks to a dedicated graphics chip. The Xbox and, to a lesser
extent, Nintendo's GameCube and Sony's PlayStation 2 are capable of running
programs that would have brought earlier generations of hardware shuddering
to a halt. So, animations that once could be viewed only after waiting
minutes or hours can be calculated on the fly.

The game industry is betting on physics as a follow-up to the galvanizing
impact of 3-D imagery. In fact, graphics have gotten so good that they're
making other aspects
of games look bad. "As you increase visual quality," says Seamus Blackley,
who coded physics engines for DreamWorks Interactive before heading up
Xbox development at Microsoft, "it becomes more important to make the dynamic
reality as sophisticated as the visual reality."

Most objects in a game act as though they've been painted on a theater
backdrop. If you try to use them, the facade falls down. "In Super
Mario 64 or Doom, you come across things like
boxes that can't move as they would in the real world," complains Chris
Hecker,
who programmed 3-D graphics at Microsoft before founding his own game company,
definition six. "How come I can't use one of them to prop open a door?
How come I can't do all the things that come to mind when I'm trying to
solve a puzzle?"

With real-time physics, there's no reason why not. In fact, every creature,
piece of machinery, prop, tree, and dirt clod can behave with the same
predictability - and unpredictability - as its physical counterpart. As
physics engines become more commonplace, says Will Wright, cofounder of
Maxis and designer of best-selling titles like SimCity
and The Sims, "you'll be able to interact with more and
more of the surroundings, to the point where you can pick up a crowbar
and pry a nail out of the wall."

But why stop at inanimate objects? For Skolones, the ultimate goal is to
create "lifelike characters that interact with one another and their
environments."
MathEngine's latest demo, a fistfight set on an industrial catwalk, is
an early step
in this direction. Like conventional game characters, the two boxers spar
according to prepared animation. But when one strikes the other, the physics
engine begins
to exert its influence, more or less depending on settings in the characters'
joints that determine their resistance to external forces. An especially
forceful blow sends one of the combatants sprawling down a flight of stairs,
now fully at the mercy of momentum, gravity, and the metal steps. With
the laws of nature firmly in force, life on the other side of the screen
is about to get much more interesting.

On-the-fly physics engines free every creature, prop, and dirt clod to behave with the same predictability - and unpredictability - as its real-world counterpart. Spring-mass systems can unleash gelatinous monsters capable of oozing through keyholes.

Unless you're charting the paths of atomic particles or planetary orbits,
Newton's three laws of motion are sufficient for predicting the behavior
of inanimate objects. The first law states that an object moving at a certain
speed and in a certain direction will keep going until some external force
acts upon it. The second says that an object's acceleration equals the
force applied to it divided by its mass. According to the third, every
action begets an equal and opposite reaction.

The simplest kind of simulation involves interactions between rigid bodies
- objects that can't be squashed, stretched, or otherwise deformed. The
boat and the wall
in Havok's virtual pool, for instance, have values for mass and inertia
tensor (how an object's mass is distributed in relation to its center of
gravity). Then there are surface properties (coefficients of friction and
restitution, or bounciness) and kinematic attributes (position, orientation,
acceleration, velocity, and angular velocity). Finally, values
are assigned to the forces at work, which include net force and torque.

Once the objects and forces are defined, it's just a matter of advancing
the simulation. The engine takes an inventory of the pool environment and
solves equations that describe the boat and the wall at a specific time
in the future - usually one-thirtieth of a second later (since most games
run at 30 frames per second). The result? The boat bobs on the water until
you push it, whereupon it glides smoothly into the wall and bounces off.

More-complex objects and interactions can be simulated by connecting rigid
bodies with various kinds of fasteners (hinges, springs, and joints) to
create structures known as articulated bodies. Skolones' blond victim at
MathEngine, for instance, has a skeleton of 22 interconnected bones. A
collision-detection algorithm (the same technology
that enables projectiles to destroy their targets in shoot-'em-up games)
keeps her arms from passing through her torso.

These three elements - rigid bodies, articulated bodies, and
collision detection - form the core
of MathEngine's and Havok's capabilities, sufficient to create things like
swaying bridges, lumbering robots, and interstellar dogfights. Havok's
software provides even more-sophisticated behaviors: the fluttering cloth
of the sail on Havok's boat, soft fur, undulating water, oozing slime.
These types of effects are staples of prerendered CG productions like Toy
Story 2, but they've never appeared in an interactive context.

Moving beyond rigid-body basics requires special techniques, often involving
what's known as a spring-mass system. A soft body like a quivering lump
of jelly, for instance, can be represented as a group of particles, each
with a specified mass, connected by virtual springs arranged in a geodesic
dome.
Varying the springs' stiffness and damping (friction that reduces oscillation)
makes it possible to simulate gelatinous objects of different densities
and viscosities.

At Havok, Hugh Reynolds shows me several soft-body demos. One lets me squeeze
a rubbery blob through a ring. When it comes out the other side, it falls
to the ground, undulating from the impact. It's
a nifty effect, but it barely hints at what the technology might do in
the hands of a hyperkinetic developer. For instance, Headfirst's Call
of Cthulhu, scheduled for release
by Christmas on the PC, will feature Havok-fueled gelatinous monsters capable
of pursuing players by squeezing under doors and through keyholes.

Although MathEngine and Havok make this kind of scenario a relatively simple
programming exercise, there remain "a lot of very, very,
very hard unsolved problems," as Reynolds puts it. Things
like fracturing, buckling, shattering, and bending - events that happen
as the forces acting on an object approach the limit of its tensile strength
- now are accomplished only through prerendered animation. Using current
hardware and software, these kinds of simulations run hundreds and even
thousands of times too slowly to be practical in a real-time game. Reynolds
figures the technology for creating worlds where things can be snapped,
crunched, and crushed is about two years away. And in five years, he says,
we'll start seeing human and animal characters whose senses of kinesthesia
will allow them to walk, wriggle, and gallop realistically across the
fast-expanding netherworld between dreams and reality.

Physics simulation isn't exactly new. The first accurate computational
models for physical interaction arose in the 17th century, when Galileo's
formulations of ballistics, falling objects, and inertia overthrew Aristotle's
nonempirical theories, which had held sway for more than 1,000
years. Galileo laid the groundwork for Newton's 1687 work, Philosophiae
Naturalis Principia Mathematica, which spawned the science of
classical mechanics - the study of how forces affect bodies. Engineers
soon applied this knowledge to physical systems, such as dams, buildings,
and bridges.

With the advent of computers, the military, aerospace, and manufacturing
industries began to develop algorithms for complex physical simulations.
In 1928, MIT's Vannevar Bush designed a mechanical computer called the
Differential Analyzer that could trace a missile's path based on the relative
speed
of the launcher and its target, along with wind resistance and other factors.
Early electronic analog computers were used to calculate flight paths and
analyze the flow of liquids through hydraulic systems.

Physics first found its way into a game in 1958, when two employees at
New York's Brookhaven National Laboratory devised an electronic diversion
called Tennis for Two using an analog computer wired to
an oscilloscope. The scope's 5-inch screen represented a tennis court viewed
from the sidelines, the ball leaving a comet tail as it bounced over a
vertical line, the net. The game simulated air drag on the ball, and players
could adjust the gravity to experience the thrill of playing tennis on
planets other than Earth.

But while electronic games advanced, their use of Newtonian principles
remained limited. For instance, Quake, released in 1996,
took into account the second law (acceleration equals force divided by
mass), but only in a few circumstances. Savvy players discovered that they
could fire a rocket beneath their feet at the moment they executed a jump,
and the combined forces would increase their acceleration sufficiently
to shoot them into the sky. Using a rocket launcher as
a turbocharged pogo stick, they could do things the game's designers never
anticipated, like leap directly to a level's exit, avoiding
all the pitfalls along the way.

I swing the grisly, spiked mace and can actually feel tiny collisions between chain links, as well as the centrifugal pull of the ball as it swoops around the handle. The doors to the metaverse have been thrown open.

Physical accuracy played a larger role in games that simulated jet fighters
or racing cars, such as 1997's Carmageddon. Many of the
people who designed these titles honed their skills programming simulators
for the armed services, where computer power was plentiful. Even so, the
technology was rudimentary, since the points of contact between a car or
plane
and its environment rarely change. In the event of a crash, early vehicle
simulators switched to prerendered artistry.

As Carmageddon rolled off the production line, current
Xbox project lead Seamus Blackley was masterminding the first game
to incorporate physics into almost every aspect of a virtual environment.
Published by DreamWorks Interactive in late 1998, Trespasser
was launched on a wave of hype. According to a contemporaneous press release,
"The Trespasser engine's physics system represents a generational
leap in computer simulations - it is a stunning new piece of technology
that will change the way the industry thinks about games."

It was indeed a stunning piece
of technology. Trespasser's dinosaur-infested world was
a convincing physical environment in which players could try nearly anything
to solve a puzzle or kill a reptile. Too bad the game sucked.

"Everybody was looking forward to Trespasser because of
its advanced physics engine," recalls Will Wright. "But when the game came
out, it was just horrible. The physical constraints overwhelmed everything
else. Every time you'd walk through a door with a gun, it would catch the
doorjamb and fall out of your hand."

Nonetheless, other efforts were already under way to capitalize on the
potential of computer-based physics. In 1998, Hugh Reynolds and Steven
Collins, professors at Dublin's Trinity College, decided the world was
ready for a physics-engine company. As a student of digital animation,
Reynolds had witnessed the rapid increase in computer-processing power
since he started teaching college in the early '90s. Back then, he says,
simulating something as simple as two boxes bouncing off each other required
days of number crunching on Trinity's big iron. "You'd set it up on the
mainframe on a Friday evening, head off for the weekend, and come back,
hoping to see an animation
at the end," he recalls. Soon, though, even a home computer could run circles
around that mainframe. Collins and Reynolds secured a
loan from Ireland's Business Expansion Scheme and launched Telekinesys
Research as an umbrella company for Havok, its only division. Havok's first
SDK was released in March 2000, three months before Telekinesys acquired
Ipion, a German physics-engine company that had devised fast and easy-to-use
collision-detection algorithms. A version for Macromedia Director appeared
last May, bringing the technology to a broad community
of developers and giving physics-based content an entrée to the
Web via Shockwave.

At around the same time Reynolds and Collins were unleashing Havok, Alan
Milosevic, a Welsh computer programmer and mathematician, formed MathEngine
to develop what he called "natural behavior software" for game, movie,
and engineering applications. After a successful round of venture funding,
the Oxford-based outfit joined forces with Lateral Logic (since renamed
Critical Mass Systems), a competing physics-engine
company based in Montreal that had developed a training simulator to teach
loggers how to control an especially unwieldy tree-harvesting vehicle.
MathEngine SDK 1.0 hit the market in March 1999, but the general-purpose
toolkit proved too cumbersome and inefficient. The team returned to the
woodshed and emerged with a game-centric rewrite, Karma, in March 2001.

With two ambitious companies competing neck and neck to deliver
a worthy solution, physics was ready for the game industry. But
the unhappy fate of Trespasser poses a crucial question:
Is the game industry ready for physics?

At Havok's office, I have the dizzy pleasure of speeding through the
roller-coaster
streets of San Francisco in a supercharged Austin Mini, courtesy of Top
Gear Dare Devil, a Havok-powered game developed by Papaya Studio.
The Mini responds to steering, acceleration, and braking as though it were
a real car. The way it handles - bouncing over bumps and swerving around
corners - resonates with my intuitive sense of driving, with one exception:
I can ram the curb any way I please, but the car never flips over. I ask
Havok's Hugh Reynolds why.

"They sunk the car's center of gravity about a meter underground," he replies.
"Game physics is about consistency, not realism."

Although game developers like
to boast about the realism of the experiences they create, they're actually
talking about making sure that the world within a game, which may be entirely
unlike the one we live in, is consistent and accessible. When a game's
objects, environments, and characters are imbued with physical properties,
they become extensions of, rather than stand-ins for, reality as we perceive
it. In other respects, however, correspondence between the external environment
and the one inside the box is beside the point. People play games to get
away from the real world. As Trespasser demonstrated all
too clearly, too much reality spoils the fun.

"Games are about reducing the world to a smaller but representative set
of skills," says Robert Weldon, CEO of Critical Mass. "Softball
is complex enough to be interesting, but simple enough to require only
a narrow set of skills. Computer games are just the same. When you play
Quake, you learn how to punch, shoot, and run. As you
continue, you get more weapons, but these three underlying skills remain
the same. That's what makes it fun."

Even if gameplay is brilliantly conceived, physics technology poses a further
challenge: the user interface. Joysticks and buttons are fine for piloting
spaceships and firing missiles, but it takes subtler kinds
of input devices to navigate worlds where surfaces run the gamut from bouncy
to slippery, and to manipulate objects that crumple, shatter,
or melt. At Havok, I have a hard time using a mouse to move dolls around
a simulated stage. Trying to place one doll behind another, I succeed only
in lifting it and dropping it on top of the next one.

"What am I doing wrong?" I ask.

"Ah, the classic problem of controlling a 3-D world on a 2-D screen," Reynolds
chuckles, and leaves it at that. Physics, apparently, only exacerbates
a persistent computer-graphics conundrum.

One solution might be haptics (from the Greek word meaning "to feel").
Motorized joysticks, mouses, and steering wheels that convey force and
texture - so that navigating a bumpy road, for instance, becomes a
shoulder-jolting
experience - can make the world inside the box much easier to negotiate.

I get a taste of the future when Steven Collins hands me a haptic touchpad
built by Immersion, a
San Jose-based innovator of input devices. The pad's springy, thumb-controlled
button shakes and vibrates in sync with the action onscreen. Collins loads
a demo program that displays a mace (the grisly medieval weapon, a spiked
ball on a chain). Using the touchpad, I swing the mace and can
actually feel tiny collisions between chain links, as well as the centrifugal
pull of the ball as it swoops around the handle. With my eyes closed,
I move the weapon in a circle.

After trying dozens of depressingly bad virtual reality systems over the
past decade, for once I feel truly immersed. In Havok's and MathEngine's demos,
I moved a cursor, and the cursor moved the simulation. Now I move
the simulation, with one hand submerged
in the virtual world. With equal amounts of giddiness and dread,
I realize that the doors to the metaverse have been thrown open. Reality
has a competitor.