How to create local inertia with OgreBullet?

lucky7456969

15-11-2014 10:46:10

Dear Alex,
I've been looking for some mappings for the following objects:
1) btAlignedObjectArray
2) btDefaultMotionState
3) btRigidBody::btRigidBodyConstructionInfo

I looked the header, but couldn't seem to find my way.
Thanks
Jack


void Cooperative_Pathfinding_Test::AddGround(/*ObjectBase* obj*/) {
///-----initialization_end-----

OgreBulletDynamics::RigidBody *ground = new OgreBulletDynamics::RigidBody("Ground",m_dynamicsWorld);

///create a few basic rigid bodies
//btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
OgreBulletCollisions::CollisionShape *groundShape = new OgreBulletCollisions::BoxCollisionShape(Ogre::Vector3(50., 50., 50.));

//keep track of the shapes, we release memory at exit.
//make sure to re-use collision shapes among rigid bodies whenever possible!
//btAlignedObjectArray<btCollisionShape*> collisionShapes;

//m_collisionShapes.push_back(groundShape);


btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));

#if 0

btScalar mass(0.);


bool isDynamic = (mass != 0.f);

btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);


btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
#endif


//add the body to the dynamics world
ground->setStaticShape(groundShape, 0, 1);
ground->setTransform(groundTransform);
m_dynamicsWorld->addRigidBody(ground,0,0);


}