nikki
01-01-2009 10:06:00
Ok, I know this is the OgreBullet forum, but I thought I'd mention my little 'BtOgre' wrapper I created this saturday for a 'thin' Bullet-Ogre connection. This wrapper does not try to provide its own RigidBody or CollisionShape classes. Instead, you talk directly with Bullet. The only thing it does is connect the btRigidBodies (only rigid bodies for now, I'm still not good with soft bodies) to their SceneNodes, convert Ogre meshes to Bullet convex hulls and triangle meshes etc., provide a debug drawing mechanism (only basic drawing for now, there's no per-object drawing yet), and a Bullet-Ogre vector/quaternion conversion utility.
You can get it here:-
BtOgre 09.01.01
Just include the needed header files, and compile and link BtOgre.cpp with your project.
For a quick test, just follow this tutorial, but instead of the default motion state, use BtOgre::RigidBodyState(pos, rot, node). For example, here's some rigid body creation code from one of my own test apps:-
Here's an example of triangle-mesh-making (the shape converters are adapted from tuan's code, thanks tuan!
):-
Here's how you can use the debug-drawer:-
BtOgre encourages raw Bullet usage.
You can get it here:-
BtOgre 09.01.01
Just include the needed header files, and compile and link BtOgre.cpp with your project.
For a quick test, just follow this tutorial, but instead of the default motion state, use BtOgre::RigidBodyState(pos, rot, node). For example, here's some rigid body creation code from one of my own test apps:-
//Create Ogre stuff.
mEntity = mSceneManager->createEntity(idStr + "sphereEntity", "Sphere.mesh");
mNode = mSceneManager->getRootSceneNode()->createChildSceneNode(idStr + "sphereSceneNode", pos, rot);
mNode->attachObject(mEntity);
//Create shape.
BtOgre::StaticMeshToShapeConverter converter(mEntity);
mShape = converter.createSphere(); //You can also just use btSphereShape(5) or something.
//Calculate inertia.
btScalar mass = 5;
btVector3 inertia;
mShape->calculateLocalInertia(mass, inertia);
//Create BtOgre MotionState (connects Ogre and Bullet).
BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(btTransform(BtOgre::Convert::toBullet(rot), BtOgre::Convert::toBullet(pos)), mNode);
//Create the Body.
mBody = new btRigidBody(mass, state, mShape, inertia);
/*btDynamicsWorld*/ mDynWorld->addRigidBody(mBody);Here's an example of triangle-mesh-making (the shape converters are adapted from tuan's code, thanks tuan!
BtOgre::StaticMeshToShapeConverter converter(mEntity);
/*btBvhTriangleMeshShape*/ mShape = converter.createTrimesh();Here's how you can use the debug-drawer:-
/*BtOgre::DebugDrawer*/ mDebugDrawer = new BtOgre::DebugDrawer(mSceneMgr->getRootSceneNode());
/*btDynamicsWorld*/ mDynWorld->setDebugDrawer(Globals::dbgdraw);BtOgre encourages raw Bullet usage.