Game Development Reference
In-Depth Information
The first method, VInitialize() , initializes the physics system. VOnUpdate()
starts the physics simulation, which recalculates new positions and orientations for
moving objects and queues physics event callbacks like collision or trigger events.
The next method, VSyncVisibleScene() , is responsible for iterating through all
of the physics objects and updating the visible geometry with new locations and
orientations.
The methods responsible for adding objects to the physics simulation come next. Each
takes parameters that describe the geometry of the object, a weak pointer to the actor,
the actor ' s initial position, and of what density and material the object is made.
The VRenderDiagnostics() method is a special routine that draws physics debug
data to the renderer. It is a critical tool for you to debug physics problems. The
remaining interface methods create different physics objects and attach them to the
simulation, such as a sphere. It is through methods like VCreateSphere() that you
add physical presence to your game objects so they can move just like they would in
the real world.
Here
ll see
the term rigid body in the code, which is how Bullet refers to solid objects in the
physics simulation.
'
s the implementation of that interface using the Bullet Physics SDK. You
'
class BulletPhysics : public IGamePhysics, GCC_noncopyable
{
// these are all of the objects that Bullet uses to do its work.
// see BulletPhysics::VInitialize() for some more info.
btDynamicsWorld* m_dynamicsWorld;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
BulletDebugDrawer*
m_debugDrawer;
// tables read from the XML
typedef std::map<std::string, float> DensityTable;
typedef std::map<std::string, MaterialData> MaterialTable;
DensityTable m_densityTable;
MaterialTable m_materialTable;
void LoadXml();
float LookupSpecificGravity(const std::string& densityStr);
MaterialData LookupMaterialData(const std::string& materialStr);
// keep track of the existing rigid bodies: To check them for updates
// to the actors
'
positions, and to remove them when their lives are over.
Search WWH ::




Custom Search