rogerdv
15-07-2010 22:26:29
Im trying to make a basic test based on tutorial code available in wiki. I use this code to create the shapes:
And this one to create a plane, as ground:
But, no matter how high I set the object position, it appears half buried in ground plane and quickly sinks. Any idea about what Im doing wrong?
void btPhysics::createStaticShape(Ogre::String name, Ogre::Entity *mesh, Ogre::SceneNode *node)
{
Vector3 size;
AxisAlignedBox boundingB = mesh->getBoundingBox();
size = boundingB.getSize();
size /= 2.0f; // only the half needed
size *= 0.96f;
OgreBulletCollisions::BoxCollisionShape *sceneBoxShape = new OgreBulletCollisions::BoxCollisionShape(size);
// and the Bullet rigid body
OgreBulletDynamics::RigidBody *defaultBody = new OgreBulletDynamics::RigidBody(name, mWorld);
defaultBody->setShape(node, sceneBoxShape, 0.6f, // dynamic body restitution
0.6f, // dynamic body friction
1.0f, // dynamic bodymass
node->getPosition(), // starting position of the box
Quaternion(0,0,0,1));// orientation of the box
}
And this one to create a plane, as ground:
void btPhysics::createPlane() {
OgreBulletCollisions::CollisionShape *Shape;
Shape = new OgreBulletCollisions::StaticPlaneCollisionShape(Ogre::Vector3(0,1,0), 0); // (normal vector, distance)
OgreBulletDynamics::RigidBody *defaultPlaneBody = new OgreBulletDynamics::RigidBody("BasePlane", mWorld);
defaultPlaneBody->setStaticShape(Shape, 0.1, 0.8); // (shape, restitution, friction)
// push the created objects to the deques
mShapes.push_back(Shape);
mBodies.push_back(defaultPlaneBody);
};
But, no matter how high I set the object position, it appears half buried in ground plane and quickly sinks. Any idea about what Im doing wrong?