Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting Up Bullet
#3
If anyone needs to know how to create a physics object that connects to your game objects this might help


PhysicsObj* Game::CreatePhysicsObj(btCollisionShape* pShape,
const float &mass,
const btVector3 &aPosition,
const btQuaternion &aRotation,
int mask) // mask defaults to 1
{
// create a new game object
PhysicsObj* pPhysicsObject = new PhysicsObj(pShape, mass, aPosition, aRotation);
float currentm = pShape->getMargin();

pShape->setMargin(0.09f); // I make it a tiny bit smaller

if (DynamicPhysicsWorld)
{
DynamicPhysicsWorld->addRigidBody(pPhysicsObject->GetRigidBody(), 1, 1); // group 1, mask 1;
// the group and mask are accessable using these functions but don't need them till you do collision responses
// pPhysicsObject->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup;
// pPhysicsObject->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask;

} else {
printf("Attempting to add to a Dynamic world that does not exist\n"); }
ListOfPObjects.push_back(pPhysicsObject); // need this to clear the world at times does physics not have this?0

return pPhysicsObject; // return to place in the objects data or in another list
}
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply


Messages In This Thread
Setting Up Bullet - by Brian Beuken - 02-26-2018, 02:42 PM
RE: Setting Up Bullet - by Brian Beuken - 03-01-2018, 08:44 AM
RE: Setting Up Bullet - by Brian Beuken - 10-12-2022, 11:21 AM
RE: Setting Up Bullet - by Brian Beuken - 10-12-2022, 11:36 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)