I'm using Ogre and Bullet for a project and I currently have a first person camera set up with a Capsule Collision Shape. I've created a model of a cave (which will serve as the main part of the level) and imported it into my game. I'm now trying to create an OgreBulletCollisions::TriangleMeshCollisionShape
of the cave.
The code I've got so far is this but it isn't working. It compiles but the Capsule shape passes straight through the cave shape. Also I have debug outlines on and there are none being drawn around the cave mesh.
Entity *cave = mSceneMgr->createEntity("Cave", "pCube1.mesh");
SceneNode *caveNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
caveNode->setPosition(0, 10, 250);
caveNode->setScale(10, 10, 10);
caveNode->rotate(Quaternion(0.5, 0.5, -0.5, 0.5));
caveNode->attachObject(cave);
OgreBulletCollisions::StaticMeshToShapeConverter *smtsc = new OgreBulletCollisions::StaticMeshToShapeConverter();
smtsc->addEntity(cave);
OgreBulletCollisions::TriangleMeshCollisionShape *tri = smtsc->createTrimesh();
OgreBulletDynamics::RigidBody *caveBody = new OgreBulletDynamics::RigidBody("cave", mWorld);
caveBody->setStaticShape(tri, 0.1, 0.8);
mShapes.push_back(tri);
mBodies.push_back(caveBody);
Any suggestions are welcome.
To clarify. It compiles but the Capsule shape passes straight through the cave shape. Also I have debug outlines on and there are none being drawn around the cave mesh
In the end I had to use a btScaledBvhTriangleMeshShape
. So my code now looks like
OgreBulletCollisions::StaticMeshToShapeConverter *smtsc =
new OgreBulletCollisions::StaticMeshToShapeConverter();
smtsc->addEntity(cave);
OgreBulletCollisions::TriangleMeshCollisionShape *tri = smtsc->createTrimesh();
OgreBulletDynamics::RigidBody *caveBody = new OgreBulletDynamics::RigidBody("cave", mWorld);
btScaledBvhTriangleMeshShape *triShape = new btScaledBvhTriangleMeshShape((btBvhTriangleMeshShape*)(tri->getBulletShape()), btVector3(150, 150, 150));
caveBody->setStaticShape(triShape, 0.0, 5, Vector3::ZERO, rotationQuaternion);
caveBody->setDebugDisplayEnabled(true);