Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Feb 07, 2012 11:30 pm 
Offline

Joined: Tue Feb 07, 2012 11:21 pm
Posts: 2
Hi,

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:
// 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);   
}


So I guess I'm doing everything right until here... correct?

Bowling ball throw and update:
Code:
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());      


}

What about this part?

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


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 7:10 pm 
Offline

Joined: Tue Feb 07, 2012 11:21 pm
Posts: 2
It was a problem with using env_map spherical in the ball's texture_unit in the materials script...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group