Collision Detection for dynamic realtime Meshes

audiorausch

12-05-2011 08:18:09

Hi,

currently we are creating meshes via manual objects based on data we are extraction from an audio file (should work kinda like audiosurf someday). In addition we are working with OgreBullet for collsion detection, however we don't know how to get the collision detection working with the mesh we created.

So my first question is, is it really a good idea to work with manual objects in order to create a mesh based on "random" data or is there a better way? And second how do we get the collision detection working for this mesh?

regards

PeterTheOne

12-05-2011 11:50:07

I'm coding on the same project with audiorausch...

I solve the problem, by using this function from the OgreBulletDemos
RigidBody *OgreBulletListener::addStaticTrimesh(const Ogre::String &instanceName,
const Ogre::String &meshName,
const Ogre::Vector3 &pos,
const Ogre::Quaternion &q,
const Ogre::Real bodyRestitution,
const Ogre::Real bodyFriction,
bool castShadow)
{
Entity *sceneEntity = mSceneMgr->createEntity(instanceName + StringConverter::toString(mNumEntitiesInstanced), meshName);
sceneEntity->setCastShadows (castShadow);

StaticMeshToShapeConverter *trimeshConverter = new StaticMeshToShapeConverter(sceneEntity);
TriangleMeshCollisionShape *sceneTriMeshShape = trimeshConverter->createTrimesh();
delete trimeshConverter;
RigidBody *sceneRigid = new RigidBody(
instanceName + "Rigid" + StringConverter::toString(mNumEntitiesInstanced),
mWorld);

SceneNode *node = mSceneMgr->getRootSceneNode ()->createChildSceneNode ();
node->attachObject (sceneEntity);

sceneRigid->setStaticShape(node, sceneTriMeshShape, bodyRestitution, bodyFriction, pos);

mEntities.push_back(sceneEntity);
mBodies.push_back(sceneRigid);
mNumEntitiesInstanced++;

return sceneRigid;
}