not understanding how to make a Entity Faces collide

kulebril

03-03-2011 16:57:15

Hi:

I have a model I wish to be afected by physics.
I made:


OgreBulletCollisions::CollisionShape *CharShape;
OgreBulletCollisions::AnimatedMeshToShapeConverter * Converter=
new OgreBulletCollisions::AnimatedMeshToShapeConverter(mBodyEnt);
CharShape=Converter->createTrimesh();

OgreBulletDynamics::RigidBody *CharBody =
new OgreBulletDynamics::RigidBody(
"CharRigid",
mPhysicsFrameListener->mWorld);

pos=mBodyNode->getPosition();
CharBody->setShape(
mBodyNode,
CharShape,
0.01f, // dynamic body restitution
0.6f, // dynamic body friction
500.0f,
pos, // starting position
Quaternion(0,1,0,0)// orientation
);
mPhysicsFrameListener->mShapes.push_back(CharShape);
mPhysicsFrameListener->mBodies.push_back(CharBody);


but my model falls through the ground (while the other Bodies don't).

If I apply a Box Shape, it collides correctly, but when using Trimesh don't.

What do I have to do? What I am missing here?

jonathanblacknight

04-03-2011 13:41:13

Turn On the the Debug Drawer, something like that:


debugDrawer = new OgreBulletCollisions::DebugDrawer();
debugDrawer->setDrawWireframe(true); // we want to see the Bullet containers
mWorld->setDebugDrawer(debugDrawer);
mWorld->setShowDebugShapes(true); // enable it if you want to see the Bullet containers
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("debugDrawer", Ogre::Vector3::ZERO);
node->attachObject(static_cast <SimpleRenderable *> (debugDrawer));


and check if the shape position is correct.

kulebril

05-03-2011 15:31:33

Thanks for the reply.

I was debbuging from the start.
The shape is correct (I see the wireframe right like the model mesh).
I looked on the manual, and I believe the Trimesh is not able to be a Collider, just a Collided.
Is there a way for it?

Also, how do you guys do the face level collision?
I wish to be capable to detect wich face of the model is hit by a ray.
How do we do that?