Game Development Reference
In-Depth Information
if (!pRidigBody)
return;
btVector3 const force( dir.x * newtons,
dir.y * newtons,
dir.z * newtons );
body->applyCentralImpulse( force );
}
void BulletPhysics::VApplyTorque(const Vec3 &dir, float magnitude, ActorId aid)
{
btRigidBody * pRigidBody = FindBulletRigidBody(actorId);
GCC_ASSERT(pRigidBody);
if (!pRidigBody)
return;
btVector3 const torque( dir.x * magnitude,
dir.y * magnitude,
dir.z * magnitude );
body->applyTorqueImpulse( torque );
}
These are both applied as instantaneous force impulses, essentially like smacking
something with a golf club or hitting a wrench with a hammer. Sometimes you also
might like to tell Bullet to stop an actor or move it with a specific velocity.
void BulletPhysics::VStopActor(ActorId actorId)
{
VSetVelocity(actorId, Vec3(0.f, 0.f, 0.f));
}
void BulletPhysics::VSetVelocity(ActorId actorId, const Vec3& vel)
{
btRigidBody * pRigidBody = FindBulletRigidBody(actorId);
GCC_ASSERT(pRigidBody);
if (!pRidigBody)
return;
btVector3 btVel = Vec3_to_btVector3(vel);
pRigidBody->setLinearVelocity(btVel);
}
The Physics Debug Renderer
One other important method of the IPhysics interface is VRenderDiagnostics :
void BulletPhysics::VRenderDiagnostics()
{
 
 
Search WWH ::




Custom Search