[SOLVED] StaticMeshToShapeConverter missing

AE86takumi

27-11-2013 06:04:34

Hi,

I'm trying to convert load in a race track into my game and use OgreBulletCollisions::StaticMeshToShapeConverter to make the collision mesh. But for some reason my OgreBulletCollisions is missing the StaticMeshToShapeConverter member. Is there something extra i need to download other than OgreBullet?

I believe I'm using Ogre version 1.9 and used the latest OgreBullet build as of August 06, 2013.

Any info on the matter would be appreciated.
Thanks.

AE86takumi

27-11-2013 06:42:52

So it seems I forgot to #include "Utils/OgreBulletCollisionsMeshToShapeConverter.h"

However, now i'm having an issue with the following:

mTrack = mSceneMgr->createEntity("track" + StringConverter::toString(mNumEntitiesInstanced++), "Racetrack01.mesh");
mTrackNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("TrackNode");
mTrackNode->attachObject(mTrack);

OgreBulletCollisions::StaticMeshToShapeConverter *meshCnvrt = new OgreBulletCollisions::StaticMeshToShapeConverter(mTrack);
OgreBulletCollisions::TriangleMeshCollisionShape *trackTriMesh = meshCnvrt->createTrimesh();
OgreBulletDynamics::RigidBody *trackBody = new OgreBulletDynamics::RigidBody("RaceTrackBody", mWorld);
trackBody->setShape(mTrackNode, trackTriMesh, 0.0f, 0.0f, 0.8f, Vector3::ZERO, Quaternion::IDENTITY);
delete meshCnvrt;


It cannot convert trackTriMesh from OgreBulletCollisions::TriangleMeshCollisionShape* to OgreBulletCollisions::CollisionShape*.

I've also tried:

trackBody->setStaticShape(trackTriMesh, 0.1, 0.8);


But that also cannot convert from OgreBulletCollisions::TriangleMeshCollisionShape* to btScaledBvhTriangleMeshShape*.

Wondering if there's more includes missing...

AE86takumi

27-11-2013 09:47:00

Update #3

So I'm now using a slightly different method:
#include "Ogre.h"
#include "OgreStringConverter.h"
#include "OgreException.h"
#include "OgreBulletCollisions.h"
#include "OgreBulletDynamics.h"
#include "Shapes/OgreBulletCollisionsStaticPlaneShape.h" // for static planes
#include "Shapes/OgreBulletCollisionsBoxShape.h" // for Boxes
#include "Shapes/OgreBulletCollisionsTrimeshShape.h"
#include "Utils/OgreBulletCollisionsMeshToShapeConverter.h"


mTrack = mSceneMgr->createEntity("track" + StringConverter::toString(mNumEntitiesInstanced++), "Racetrack01.mesh");
mTrackNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("TrackNode");
mTrackNode->attachObject(mTrack);

OgreBulletDynamics::RigidBody *trackBody = new OgreBulletDynamics::RigidBody("TrackBody", mWorld);
OgreBulletCollisions::StaticMeshToShapeConverter *trimeshConverter = new OgreBulletCollisions::StaticMeshToShapeConverter(mTrack);
OgreBulletCollisions::TriangleMeshCollisionShape *trackTriMeshShape = trimeshConverter->createTrimesh();
delete trimeshConverter;
btScaledBvhTriangleMeshShape *collisionShape = new btScaledBvhTriangleMeshShape((btBvhTriangleMeshShape*)(trackTriMeshShape->getBulletShape()),btVector3(1,1,1));
trackBody->setStaticShape(collisionShape, 0.1, 0.8, Vector3::ZERO, Quaternion::IDENTITY);

The issue is that for some reason when I #include "Shapes/OgreBulletCollisionsTrimeshShape.h" I get several errors like:
Error 8 error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in ConvexDecomposition_Debug.lib(vlookup.obj) C:\asdf\asdf\asdf\msvcprtd.lib(MSVCP100D.dll)

But if I dont #include "Shapes/OgreBulletCollisionsTrimeshShape.h" then it complains that OgreBulletCollisions::TriangleMeshCollisionShape is undefined even though it should be defined in OgreBulletCollisions.h.

Sigh... it's almost 2am so I guess I'll keep drilling into this tomorrow. I hope someone sees this thread soon and laughs at me while pointing out something very simple that I've missed :)

AlexeyKnyshev

27-11-2013 12:35:56

It cannot convert trackTriMesh from OgreBulletCollisions::TriangleMeshCollisionShape* to OgreBulletCollisions::CollisionShape*.


It seems that compiler don't know in this process unit (your problematic cpp file) that OgreBulletCollisions::TriangleMeshCollisionShape is subclass of OgreBulletCollisions::CollisionShape, so u should include OgreBulletCollisionsTrimeshShape.h.
Seems that u solved this.

The issue is that for some reason when I #include "Shapes/OgreBulletCollisionsTrimeshShape.h" I get several errors like:
Error 8 error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in ConvexDecomposition_Debug.lib(vlookup.obj) C:\asdf\asdf\asdf\msvcprtd.lib(MSVCP100D.dll)

Your errors suggest your project is trying to link with the dynamic CRT lib, i.e. using /MD and /MDd. While OgreBullet has been built with static runtime. I'm not msvc guru, because I use Linux. But maybe it would help you

AE86takumi

27-11-2013 15:08:55

My project is in fact using Multi-threaded Debug DLL (/MDd). I'll double-check that my Bullet libs are not compiled using /MDd also.

Thanks for the response.

AlexeyKnyshev

27-11-2013 19:08:32

How you compiled Bullet? Which runtime has been used while compilation?

AE86takumi

28-11-2013 03:00:21

My project and OgreBullet were built using /MD and /MDd, but the Bullet dlls were built using /MT and /MTd. I've rebuilt the ConvexDecomposition libs using /MD, then I re-built OgreBulletCollisions and OgreBulletDynamics also using /MD. Finally my project remains in /MD and now the link errors are gone.

Seems to be working now. Thank you for all the help! :)