Problem to adjust collision behaviour
Posted: Tue May 08, 2012 3:04 pm
Hi everybody,
i don't find a concrete answer in this forum, so i ask my question here.
I have a sphere and a shape body. only the sphere is dynamic (i.e. mass !=0)
i initialize my physic word with :
and initialize my object with :
my scene is one ball in center of 4 box which build borders like in a pool.
My problem is when ball collide with borders : the ball stick on the box. I don't success to adjust the collision to have a "classic" bounce, like in pool but with a total restitution of the velocity after the collision
I follow many pist :
* the margin of the body ( if too higher, the ball go through the border)
* to add "myWorld->getSolverInfo().m_splitImpulse = true;" : nothing change
* adjust contact threshold : nothing change
* i read somewhere to switch continous detection to off, but i've don't find something like that in the API
If someone has some advices or ways of reflexion,
feel free to share it.
Thanks in advance
PS : sorry for my english
i don't find a concrete answer in this forum, so i ask my question here.
I have a sphere and a shape body. only the sphere is dynamic (i.e. mass !=0)
i initialize my physic word with :
Code: Select all
myCollisionConfiguration = new btDefaultCollisionConfiguration();
myDispatcher = new btCollisionDispatcher(myCollisionConfiguration);
myBroadphase = new btDbvtBroadphase();
mySequentialImpulseConstraintSolver = new btSequentialImpulseConstraintSolver();
myWorld = new btDiscreteDynamicsWorld(myDispatcher,myBroadphase,mySequentialImpulseConstraintSolver,myCollisionConfiguration);
myWorld->getSolverInfo().m_splitImpulse = true;
myWorld->setGravity( btVector3(0.0,0.0,0.0) );
Code: Select all
btCollisionShape* shape;
if (m_shape=="sphere")
{
shape = new btSphereShape(btVector3(m_size.x,m_size.y,m_size.z).length()/3.0);
}
else
{
shape = new btBoxShape(btVector3(m_size.x,m_size.y,m_size.z));
}
//shape->setMargin(0.3f);
m_transform.setIdentity();
//get the intial position of the object
FCgetPosition f; /* ... */
m_transform.setOrigin( btVector3(f.position.x,f.position.y,f.position.z) );
//On calcule l'inertie suivant le poids.
btVector3 localInertia(m_localInertia.x,m_localInertia.y,m_localInertia.z);
if (m_mass)
shape->calculateLocalInertia( m_mass, localInertia );
m_motionState = new btDefaultMotionState(m_transform);
btRigidBody::btRigidBodyConstructionInfo myBoxRigidBodyConstructionInfo( m_mass, m_motionState, shape, localInertia );
myBoxRigidBodyConstructionInfo.m_friction=0.0f;
myBoxRigidBodyConstructionInfo.m_restitution=0.9f;
m_body = new btRigidBody(myBoxRigidBodyConstructionInfo);
m_body->setLinearFactor(btVector3(1.0,1.0,0.0));
m_body->setAngularFactor(btVector3(0.0,0.0,0.0));
//reference to the physic bullet world
PHYSIC->getWorld()->addRigidBody(m_body);
m_body->setLinearVelocity(btVector3(5,15,0));
My problem is when ball collide with borders : the ball stick on the box. I don't success to adjust the collision to have a "classic" bounce, like in pool but with a total restitution of the velocity after the collision
I follow many pist :
* the margin of the body ( if too higher, the ball go through the border)
* to add "myWorld->getSolverInfo().m_splitImpulse = true;" : nothing change
* adjust contact threshold : nothing change
* i read somewhere to switch continous detection to off, but i've don't find something like that in the API
If someone has some advices or ways of reflexion,
feel free to share it.
Thanks in advance
PS : sorry for my english