Here the bullet code I use to create a world, static plane and a ball :
Code: Select all
broadphase = new btDbvtBroadphase();
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
solver = new btSequentialImpulseConstraintSolver;
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
dynamicsWorld->setGravity(btVector3(0.0f,-9.81f,0.0f));
plane_shape = new btStaticPlaneShape( btVector3( 0.0f, 1.0f, 0.0f ), 0.0f );
plane_body = new btRigidBody( 0.0, new btDefaultMotionState, plane_shape, btVector3( 0.0f, 0.0f, 0.0f ) );
dynamicsWorld->addRigidBody( plane_body );
ball_shape = new btSphereShape(1.0);
ball_body = new btRigidBody( 10.0f, new btDefaultMotionState, ball_shape, btVector3( 5.0f, 5.0f, 5.0f ) );
ball_body->translate( btVector3( 0.0f, 10.0f, 0.0f ) );
dynamicsWorld->addRigidBody( ball_body );
Here the code I use to Update the simulation and translate the sphere :
Code: Select all
if( IsKeyDown( Key::F ) )
ball_body->translate( btVector3( 0.0f, 5.0f, 0.0f ) );
dynamicsWorld->stepSimulation( Elapsed, 10 );
Problem : The ball translate "Y += 5.0f", but don't update its position with gravity, it stay static.
Goal : I would manage all movement by bullet : translation, rotation, force ... Is it possible ?
Thanks for the help
EDIT :
The ball update with gravity using :
Code: Select all
dynamicsWorld->stepSimulation( 1.0f / 60.0f, 10 );
But I've got some case when the ball stay static and never update its position again with gravity.
Is it normal I must use 1/60 to get it to work ?
Using this code the ball doesn't move :
Code: Select all
ball_body->applyForce( btVector3( 10.0f, 0.0f, 0.0f ), btVector3( 0.0f, 0.0f, 0.0f ) );
Maybe i don't set correctly the force ?