Game Development Reference
// Then integrate the objects
BodyRegistration *reg = firstBody;
// Remove all forces from the accumulator
// Get the next registration
reg = reg->next;
It no longer calls the collision detection system.
The calls to startFrame and runPhysics can occur in the same place in the game
Notice that I've made an additional call to the updateTransform methodofeach
object. It may have moved during the update (and in later sections during collision
resolution), so its transform matrix needs updating before it is rendered. Each object
is then rendered in turn using the rigid body's transform.
U SING THE P HYSICS E NGINE
Both sample programs for this physics engine use aerodynamics. We will create a new
force generator that can fake some important features of flight aerodynamics, enough
to produce a basic flight simulator suitable for use in a flight action game. We will use
the same generator to drive a sail model for a sailing simulator.
AF LIGHT S IMULATOR
There is no need for contact physics in a flight simulator, except with the ground, of
course. Many flight simulators assume that if you hit something in an airplane, then
it's all over: a crash animation plays and the player starts again. This makes it a perfect
exercise ground for our current engine.
The dynamics of an aircraft are generated by the way air flows over its surfaces.
(This includes the surfaces that don't move relative to the center of mass, such as the
fuselage, and control surfaces that can be made to move or change shape, such as the
wings and rudder.) The flow of air causes forces to be generated. Some, like drag, act
in the same direction that the aircraft is moving in. The most important force, lift,
acts at right angles to the flow of air. As the aircraft's surfaces move at different angles
through the air, the proportion of each kind of force can change dramatically. If the
wing is slicing through the air, it generates lift; but if it is moving vertically through