Colliding billiard balls. Missile trajectories. Cornering dynamics in speeding cars. If these type of actions are expressed in computer software, applying physics-based models can greatly enhance the level of realism.
David Bourg has written O'Reilly's recently released Physics for Game Developers, which describes how to apply the laws of physics in games to realistically model nearly anything that isn't sitting still, to create compelling, believable content for computer games, simulations, and animation. We recently spoke to David about his background, the history of physics-based realism in computer games, and why this is important information for game developers.
Stewart: Tell us a little about your background.
Bourg: As a naval architect and marine engineer, I perform computer simulations and develop analysis tools that measure such things as hovercraft performance and the effect of waves on the motion of ships and boats. I teach at the college level in the areas of ship design, construction, and analysis. On occasion, I also lecture at high schools on topics such as naval architecture and software development.
In addition to my practical engineering background, I'm professionally involved in computer game development and consulting through my company, Crescent Vision Interactive. Our current projects include a massively multiplayer online role-playing game (Oberin, which is Macintosh only), several Java-based multiplayer games, and a couple of PC-to-Macintosh game ports (such as Breakout and Stronghold). I'm also currently working on my Ph.D. in Engineering and Applied Sciences. My research involves the simulation of water to study various phenomenon using such techniques as Smoothed Particle Hydrodynamics.
Stewart: Who is this book for primarily, and what prior knowledge is required to understand it?
Bourg: The book is targeted towards video game developers who are looking to add physics-based realism to their games, but don't yet know where or how to start. I don't expect the reader to be a physics expert as I cover all the fundamental principles in the first few chapters. However, I do assume that the reader is somewhat versed in calculus. I derive most of the important equations for the readers, but it will be helpful to readers to be familiar with concepts such as integration and differentiation.
Stewart: What motivated you to write a book for game developers?
Bourg: Ever since I started programming when I was 12 years old I've been interested in writing games. More specifically, I've always been interested in writing games that incorporated real-world behavior. At that time I didn't know that physics was what I needed to achieve such realism. However, as I progressed through school, I realized that I could apply my engineering knowledge to making games more realistic. Indeed, many of my professional engineering tasks involve writing computer simulations of real-world systems, such as speedboat performance simulations, and so forth.
Over the past several years as I became involved in game development professionally, I discovered that there was no single, comprehensive source of information that would allow game developers, who don't have a physics or classical engineering background, to get up to speed on what they need to know to add physics to their games. Thus, the motivation for the book.
Stewart: Could this material apply to programmers who work on other projects besides games? Can you give some examples?
David recently wrote Five Steps to Adding Physics-Based Realism to Your Games.
Bourg: Absolutely. The principles discussed in my book are the same principles and techniques that engineers use to write engineering analysis simulations to simulate the flight dynamics of an aircraft, or to simulate the performance of a hovercraft, for example. Thus, engineers can use the principles in my book to help them write real-time simulations of systems that they may be designing or analyzing. Granted, their focus would be more on absolute accuracy rather than on visual appeal and speed; however, the techniques are basically the same.
Also, 3-D graphics artists and programmers can use the book to help them write plug-ins, for example, that would allow them to prepare animations that were physically based.
Stewart: What tools do you recommend for game developers today? Which 3-D animation packages will most easily incorporate the physics concepts you discuss?
Bourg: Well, a C/C++ compiler is a must. I personally use Microsoft's Visual C++ and Metrowerks CodeWarrior. As for 3-D graphics APIs, I use Microsoft's Direct3D and OpenGL. Both allow you to get to a low enough level, in terms of programming, where you can easily integrate 3-D graphics with your physics engine. Regarding 3-D modeling, I've used 3D Studio, but for budget-minded developers or hobbyists, TrueSpace is a great alternative.
Stewart: Can you give us some examples of specific game elements that stand to benefit, in terms of realism, from the use of the physics concepts you explain in your book?
Bourg: Sure. Any sort of projectile can be simulated physically. For example, bullets fired from a gun, missiles, grenades, and so on. Sports games can use physics to model the ball: For example, you can use physics to model the various pitches in baseball, or the dynamics of a golf ball after it gets struck with a club. Any sort of game that uses special effects for explosions can use particle systems based on physics to model scattering debris from the explosion. Flight simulations can use physics to accurately model the flight dynamics of various aircraft. Games these days are quite dynamic; things are moving, flying, sliding, and bumping into each other. All of these actions can be modeled physically to enhance the believability and immersiveness of the game.
Stewart: Tell us a little bit about the history of using concepts from physics to make more realistic computer games. What were some of the first games that used this approach?
Bourg: In recent years attention has been focused on simulating entire game worlds using real-time physics engines. There are even complete physics SDKs, such as Havok and MathEngine, available to handle all the physics for you. However, physics has been used in games since the very early days of video games. For example, consider Atari's original Asteroids game. In that game you could increase the thrust of your ship, which would cause it to accelerate. This would in turn cause an increase in velocity and a corresponding change in position so you could fly around the screen. The principles relating applied force (thrust in this case) to acceleration, to velocity, and to change in position are principles of physics.
More specifically these are fundamental principles of the subject of kinematics and kinetics, which I go over in detail in my book. So, while many game developers may not know it, they are probably already using physics to some degree in their games.
Stewart: Is it possible to successfully simulate entire game worlds using real-time physics engines with today's PC hardware? I imagine there are always tradeoffs with how much physics can be used in a game and the processing time that it requires.
Bourg: It's theoretically possible. However, as I discuss in step 1 of my article, "Five Steps to Adding Physics Based Realism to Your Games," game developers must carefully select what elements they want to include in their physics simulation so as to not degrade performance unnecessarily. Developers must balance physical immersiveness with performance just as they do with visual immersiveness and performance.
Stewart: What level of hardware do you think it's safe to base game simulations on? Should game developers be looking for the lowest common denominator in currently deployed PC systems, or is it typical to create new games that will only function smoothly on the latest equipment?
Bourg: In my experience, that's more of a marketing decision. Publishers seem to always want to target the lowest common denominator so they can say that the game works on such a platform. This maximizes their potential market. However, this isn't necessarily the ideal set of hardware requirements and they'll often put a set of recommended requirements on the box too. When designing a physics simulation to cover a wide range of hardware configurations, developers can borrow techniques that are often employed when scaling, so to speak, visual levels of detail such that on slower systems the physics simulation may include fewer elements with fewer special effects, for example, than on higher speed systems.
Stewart: As computer hardware continues to evolve at a furious pace, do you foresee a time when these tradeoffs will no longer be an issue?
Bourg: Well, as in the case of 3-D graphics, I think that as hardware capabilities increase, game developers will push those limits too, such that there will always be some level of tradeoff. That said, I do believe that in the future we'll see special purpose hardware, analogous to 3-D accelerated video cards, that are designed specifically to handle real-time physics engines. Indeed, in the field of computational fluid dynamics, and particularly in the area of astrophysical simulations, special purpose hardware called GRAPE (GRAvity PipE) has been in use since the '80s to specifically handle numerical integration of the equations of motion for large particle-based methods (so-called N-Body simulations). I expect that such special purpose hardware will find its way to personal computers in the future.
David M. Bourg performs computer simulations and develops analysis tools that measure such things as hovercraft performance and the effect of waves on the motion of ships and boats.
O'Reilly & Associates recently released (November 2001) Physics for Game Developers.
Sample Chapter 6, Projectiles, is available in PDF free online.
For more information, or to order the book, click here.
Bruce Stewart is a freelance technology writer and editor.
Return to the O'Reilly Network.
Copyright © 2009 O'Reilly Media, Inc.