NazguL86
23-04-2010 01:05:37
Hello,
I would like to add a a non-static objects loaded from a mesh (like ogrehead.mesh) and import it in my Ogrebullet application.
I tried to look online and in the forum for existing solutions but I didn't find any working one. I succeeded in loading a static mesh, using the addStaticTrimesh function; is there any other function for the non-static ones?
Basically I would like to be able to interact like in the ogrebullet demo with cylinders, cones and spheres with a non-predefined shape object loaded from a mesh file.
Thank you,
*A
Have you read through the
Bullet User Manual? Pages 17 and 38 may be of interest to you and is something you should consider before going down the road of dynamic arbitrary convex/concave collision shapes. Most anything can be simulated with the built-in primitive shapes, especially something like the Ogre Head.
- Fish
NazguL86
23-04-2010 21:12:01
I read through the manual but I didn't find out how to solve this problem.
I basically tried to mix some code from the vehicle demo and from the addStaticTrimesh function..
StaticMeshToShapeConverter *trimeshConverter = new StaticMeshToShapeConverter(entity);
TriangleMeshCollisionShape *sceneTriMeshShape = trimeshConverter->createTrimesh();
delete trimeshConverter;
RigidBody *defaultBody = new RigidBody(
"MeshDyn" + StringConverter::toString(mNumEntitiesInstanced),
mWorld);
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode ();
node->attachObject (entity);
// Scaling of the Mesh
node->scale(meshScale);
sceneTriMeshShape->getBulletShape()->setLocalScaling(bulletMeshScale);
CompoundCollisionShape *compound = new CompoundCollisionShape();
compound->addChildShape(sceneTriMeshShape);
defaultBody->setShape (node, compound, bodyRestitution, bodyFriction, bodyMass, pos, q);
The problem is that the head is simply falling through the rigid planes without interacting at all..
Page 17 talks about 'Convex Decomposition'.
From the manual:
"Ideally, concave meshes should only be used for static artwork. Otherwise its convex hull should be used by passing the mesh to btConvexHullShape. If a single convex shape is not detailed enough, multiple convex parts can be combined into a composite object called btCompoundShape. Convex decomposition can be used to decompose the concave mesh into several convex parts. See the Demos/ConvexDecompositionDemo for an automatic way of doing convex decomposition."
also:
"It is best to keep the number of vertices in a btConvexHullShape limited. It is better for performance, and too many vertices might cause instability. Use the btShapeHull utility to simplify convex hulls."
- Fish