I have the following problem. I am using Bullet with Ogre in order to create a bowling game.
All the physics are perfectly fine except for one thing... When I throw the ball, it doesn't roll. In fact, it seems to slide over the bowling lane... I have tried using different method to apply impulse on the ball, fiddled with the physical properties, double checked that I am creating the correct btCollisionShape, and nothing seems to change it.

Sphere shape and SceneNode creation:
Code: Select all
// Create shape in my Physics Manager class
// ...
btCollisionShape aBall = new btSphereShape(1.5f);
createBall("ball", Ogre::Vector3(1.5f, 1.5f, 1.5f), Ogre::Vector3(0,1.5f, -1*(arena_measures.z/2)+10), 200.0, aBall);
// ...
void CriterionBowling::createBall(const char *name, const Ogre::Vector3 &size, const Ogre::Vector3 &pos, float mass, btCollisionShape &shape)
{
// Create ogre scene node
Ogre::SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode(name);
// Create our rigidboy using our Bullet Wrapper
btRigidBody &body = mPhysics.createBody(btTransform(btQuaternion::getIdentity(), btVector3(pos.x, pos.y, pos.z)), mass, shape);
// Set some physical properties
//...
// Add it to our bowling simulation
mBall = new Ball(*node1,body);
// Get its mesh
Ogre::Entity *entity = mSceneMgr->createEntity(name, "sphere.mesh");
// Give it a texture
entity->setMaterialName("BowlingBall");
node1->attachObject(entity);
}
Bowling ball throw and update:
Code: Select all
void Ball::throw(const Vector3 force)
{
// Lock the ball --> player can't control it anymore
locked = true;
this->mRigidBody.activate(true);
// Apply force to the rigidbody
this->mRigidBody.applyCentralImpulse(btVector3(force.x,force.y,force.z));
}
void Ball::update()
{
// Get Bullet transformation matrix
btTransform transform;
// Get the transformation of this rigidbody in the transformation matrix
mRigidBody.getMotionState()->getWorldTransform(transform);
// Obtain the rotation and update the graphical representation
btQuaternion rotation(transform.getRotation());
node.setOrientation(rotation.getW(), rotation.getX(), rotation.getY(), rotation.getZ());
// Update the position
const btVector3 &origin = transform.getOrigin();
node.setPosition(origin.getX(), origin.getY(), origin.getZ());
}
I have no clue of I might be doing wrong... Could it be the physical properties of the lane floor and/or ball??
Thanks in advance!
Cheers,
Joao