Chapter 7. Real-Time Simulations

This chapter is the first in a series of chapters designed to give you a thorough introduction to the subject of real-time simulation. We say introduction because the subject is too vast and complex to adequately treat in a few chapters; however, we say thorough because we’ll do more than touch on real-time simulations. In fact, we’ll walk you through the development of two simple simulations, one in two dimensions and the other in three dimensions.

What we hope to do is give you enough of an understanding of this subject so that you can pursue it further with confidence. In other words, we want you to have a solid understanding of the fundamentals before jumping in to use someone else’s physics engine, or venturing out to write your own.

In the context of this book, a real-time simulation is a process whereby you calculate the state of the object (or objects) you’re trying to represent on the fly. You don’t rely on prescripted motion sequences to animate your object, but instead you rely on your physics model, the equations of motion, and your differential equation solver to take care of the motion of your object as the simulation progresses. This sort of simulation can be used to model rigid bodies like the airplane in our FlightSim example, or flexible bodies such as cloth and human figures. Perhaps one of the most fundamental aspects of implementing a real-time rigid-body simulator is solving the equations of motion using numerical integration ...

Get Physics for Game Developers, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.