Code: Select all
// Initialization
_btSoftBodyWorldInfo = ( btSoftBodyWorldInfo * )calloc( 1, sizeof( btSoftBodyWorldInfo ) );
_btSoftBodyRigidBodyCollisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
_btCollisionDispatcher = new btCollisionDispatcher( _btSoftBodyRigidBodyCollisionConfiguration );
_btBroadphaseInterface = new btDbvtBroadphase();
_btConstraintSolver= new btSequentialImpulseConstraintSolver();
_btSoftBodyWorldInfo->m_dispatcher = _btCollisionDispatcher;
_btSoftBodyWorldInfo->m_broadphase = _btBroadphaseInterface;
_btSoftRigidDynamicsWorld = new btSoftRigidDynamicsWorld( _btCollisionDispatcher, _btBroadphaseInterface, _btConstraintSolver, _btSoftBodyRigidBodyCollisionConfiguration );
// Add soft body
btTransform _btTransform;
...
...
switch( bounds )
{
case SIO2_PHYSIC_TRIANGLEMESH:
case SIO2_PHYSIC_CONVEXHULL:
{
btVector3 *buf = ( btVector3 * )malloc( GetNumVert( tmp ) * sizeof( btVector3 ) );
...
...
_btSoftBody = new btSoftBody( physic->_btSoftBodyWorldInfo,
sio2ObjectGetNumVert( tmp ),
buf,
NULL );
i = 0;
while( i != tmp->n_vgroup )
{
j = 0;
while( j != tmp->vertexgroup[ i ]->n_ind )
{
_btSoftBody->appendLink( tmp->vertexgroup[ i ]->ind[ j ], tmp->vertexgroup[ i ]->ind[ j + 1 ] );
_btSoftBody->appendLink( tmp->vertexgroup[ i ]->ind[ j + 1 ], tmp->vertexgroup[ i ]->ind[ j + 2 ] );
_btSoftBody->appendLink( tmp->vertexgroup[ i ]->ind[ j + 2 ], tmp->vertexgroup[ i ]->ind[ j ] );
_btSoftBody->appendFace( tmp->vertexgroup[ i ]->ind[ j ], tmp->vertexgroup[ i ]->ind[ j + 1 ], tmp->vertexgroup[ i ]->ind[ j + 2 ] );
j += 3;
}
++i;
}
break;
}
}
_btSoftBody->m_cfg.kDP = 0.0f;
_btSoftBody->m_cfg.kDF = 0.2f;
_btSoftBody->m_cfg.kMT = 0.02f;
_btSoftBody->m_cfg.kCHR = 1.0f;
_btSoftBody->m_cfg.kKHR = 0.8f;
_btSoftBody->m_cfg.kSHR = 1.0f;
_btSoftBody->m_cfg.piterations = 2;
_btSoftBody->m_materials[0]->m_kLST = 0.8f;
_btSoftBody->m_materials[0]->m_kAST = 0.8f;
_btSoftBody->m_materials[0]->m_kVST = 0.8f;
_btSoftBody->setPose( true, true );
_btSoftBody->generateBendingConstraints( 2 );
_btSoftBody->randomizeConstraints();
...
...
_btTransform.setFromOpenGLMatrix( ( btScalar * )m );
_btSoftBody->setWorldTransform( _btTransform );
_btSoftRigidDynamicsWorld->addSoftBody( _btSoftBody );
...
...
Take a look at the following video to see what I mean, the monkey is a softbody, the cubes are cube rigid bodies and the floor is a static triangle mesh:
http://www.youtube.com/watch?v=X4D4mCzXdhA&fmt=18
Another thing that puzzle me is how can I get the position of the object in the world, the _btSoftBody->getWorldTransform().getOpenGLMatrix( mat ); function always stay the same even if the soft body is falling down due to the gravity...
I review the soft body tutorials many times, and I can't figure out what Im doing wrong... am I missing something or?
Tks in advance,