Cannot convert TriMeshCollisionShape to CollisionShape

EricChan134

24-11-2014 23:47:20

Hi all,

I am using OgreSDK 1.81, Bullet 2.81 and the latest OgreBullet (2988).

When I try to pass the TriMeshCollisionShape to the setStacticShape(), it doesn't allow me to do so.
It throws the this exception:

error C2664: 'void OgreBulletDynamics::RigidBody::setStaticShape(Ogre::SceneNode *,OgreBulletCollisions::CollisionShape *,const float,const float,const Ogre::Vector3 &,const Ogre::Quaternion &)' : cannot convert parameter 2 from 'OgreBulletCollisions::TriangleMeshCollisionShape *' to 'OgreBulletCollisions::CollisionShape *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


It is strange as I am copying the code from the OgreBulletListener->addStaticTrimesh() but it does not have the problem.
The demo complies and runs perfectly fine. I am stuck at this problem for a long time :(

Here is my code:

Ogre::Entity* ent;
//
ent = mSceneMgr->createEntity("room", "Room.mesh");
ent->setMaterialName("Examples/BumpyMetal");
ent->setCastShadows(true);

OgreBulletCollisions::StaticMeshToShapeConverter *trimeshConverter = new OgreBulletCollisions::StaticMeshToShapeConverter(ent);
OgreBulletCollisions::TriangleMeshCollisionShape *sceneTriMeshShape = trimeshConverter->createTrimesh();
delete trimeshConverter;

OgreBulletDynamics::RigidBody *sceneRigid = new OgreBulletDynamics::RigidBody(
"RoomRigid" + Ogre::StringConverter::toString(mNumEntitiesInstanced),
mWorld);

Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(ent);

sceneRigid->setStaticShape(node, sceneTriMeshShape, 0.1f, 0.8f);


many thanks
Eric