Hi, thanks for replying.
I've got something compiling and executing now. I already have a working graphics engine and I simply want to use BULLET to add physics to the game. Here is the initialization code I'm currently using, taken from the basicdemo and compacted:
Code: Select all
//configure bullet
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
//create algorithm classes
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dispatcher = new btCollisionDispatcher(collisionConfiguration);
m_overlappingPairCache = new btAxisSweep3(
btVector3(-10000,-10000,-10000),
btVector3(10000,10000,10000
);
//create BulletDynamicsWorld
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver);
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
//create ground shape
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-56,0));
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
//create ball
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);
btTransform startTransform;
startTransform.setIdentity();
localCreateRigidBody(1, startTransform,colShape);
Questions:
Did I do everything properly? I've compacted the basicDemo classes into a single class because I found the large number of preprocessor directives confusing and didn't like looking back and forth between 4 code files.
How do I plug my renderer in? I believe this involves a btDebugDraw object.
How do I clean up properly? Do I have to scan through the btAlignedObjectArray container and delete each object that way?
How do I simplify this further? I just want to have a ball bouncing off of a box.