Game Development Reference
In-Depth Information
We can use the system we introduced in chapter 8 to manage the objects to be
simulated. In this case, however, they are rigid bodies rather than particles. The World
structure is modified accordingly:
Excerpt from include/cyclone/world.h
/**
* The world represents an independent simulation of physics. It
* keeps track of a set of rigid bodies, and provides the means to
* update them all.
*/
class World
{
/**
* Holds a single rigid body in a linked list of bodies.
*/
struct BodyRegistration
{
RigidBody *body;
BodyRegistration * next;
};
/**
* Holds the head of the list of registered bodies.
*/
BodyRegistration *firstBody;
};
As before, at each frame the startFrame method is first called, which sets up each
object by zeroing its force and torque accumulators and calculating its derived quan-
tities:
Excerpt from include/cyclone/world.h
/**
* The world represents an independent simulation of physics. It
* keeps track of a set of rigid bodies, and provides the means to
* update them all.
*/
class World
{
// ... other World data as before ...
/**
* Initializes the world for a simulation frame. This clears
* the force and torque accumulators for bodies in the
* world. After calling this, the bodies can have their forces
Search Nedrilad ::




Custom Search