Ogre and bullet bounding box mismatch

masterfalcon

08-01-2008 07:38:46

Hey everyone,

I'm just getting started with Bullet and the Ogre integration and I've run in to a peculiar situation. The debug visualization and Ogre's bounding box visualization show two totally different size boxes. Ogre's looks more accurate, while Bullet's is roughly twice the size of the object. Here's my code for creating the object.

tank1Node->showBoundingBox(true);
OgreBulletCollisions::BoxCollisionShape *tank0CubeShape = new OgreBulletCollisions::BoxCollisionShape(tank0Entity->getBoundingBox().getHalfSize());
OgreBulletDynamics::RigidBody *tank0CubeRigid = new OgreBulletDynamics::RigidBody("tank0CubeRigid", mWorld);
tank0CubeRigid->setShape(tank0Node, tank0CubeShape, 0.3, 0.8, 1.0, tank0Node->getPosition(), tank0Node->getOrientation());
tank0CubeRigid->getBulletRigidBody()->setCollisionFlags(tank0CubeRigid->getBulletRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
tank0CubeRigid->disableDeactivation();


As a side note, I have two of these tanks that are both controlled and I can't seem to get any collision response from anything but static objects. Am I missing something? Do I need to create a collision callback?

Thanks so much in advance,

Dave

Chaster

09-01-2008 06:01:00

Not sure what is going on with your bounding box (is your tank oriented along the major axes when you use the bounding box? Remember that Ogre uses AAB's, so if the tank is rotated, the bounding box will "grow"...)

As for the "non-collision", it's because you are using the CF_KINEMATIC flag. Kinematic objects don't react to collision with each other. Actually, they should not react with static objects either - only dynamic rigid bodies will react to the kinematic body (but the kinematic rigid body won't react to the collision with the dynamic rigid body)..

Chaster

masterfalcon

09-01-2008 06:23:44

Ya, they're straddling the x axis, above it just a little bit though. It's almost as if the size of the box is the maximum size that it could be but it's not aligned properly with the entity along the y axis.

That makes sense about the kinematic objects. So if I want to be able to control an object and have it react to collisions will I need to move the SceneNode that I have created for the visuals or the one that OgreBullet has created for the physics?