on which i drop a rigid body followed by a soft body. The soft body passes through both the rigid body and the flatplane.
here is the creation of the soft body.
Code: Select all
ObjData->mObjSoftBody->create( MyEntity,
MyMeshData.vertex_count,
MyMeshData.vertices,
MyMeshData.index_count,
(unsigned int*)MyMeshData.indices);
//btVector3 vec((float)ObjData->AxisScaling[0], (float)ObjData->AxisScaling[1], (float)ObjData->AxisScaling[2]);
//ObjData->mObjSoftBody->mSoftBody->scale(vec);
btSoftBody::Material* pm = ObjData->mObjSoftBody->mSoftBody->appendMaterial();
pm->m_flags -= btSoftBody::fMaterial::DebugDraw;
pm->m_kLST = 1.0;
ObjData->mObjSoftBody->mSoftBody->generateBendingConstraints(2,pm);
ObjData->mObjSoftBody->mSoftBody->m_cfg.piterations = 2;
ObjData->mObjSoftBody->mSoftBody->m_cfg.kDF = 1.0;
ObjData->mObjSoftBody->mSoftBody->m_cfg.kSRHR_CL = 1;
ObjData->mObjSoftBody->mSoftBody->m_cfg.kSR_SPLT_CL = 0;
ObjData->mObjSoftBody->mSoftBody->m_cfg.collisions = btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS;
ObjData->mObjSoftBody->mSoftBody->randomizeConstraints();
ObjData->mObjSoftBody->mSoftBody->setTotalMass(10,true);
ObjData->mObjSoftBody->mSoftBody->generateClusters(64);
Globals::phyWorld->addSoftBody(ObjData->mObjSoftBody->mSoftBody);
Code: Select all
BtOgre::StaticMeshToShapeConverter converter(MyEntity);
if (ObjData->CollisionShape == "Box")
{
ObjData->mObjShape = converter.createBox();
} else if (ObjData->CollisionShape == "Sphere") {
ObjData->mObjShape = converter.createSphere();
}
ObjData->mObjShape->setLocalScaling(btVector3(ObjData->AxisScaling[0],ObjData->AxisScaling[1],ObjData->AxisScaling[2]));
//Calculate inertia.
btVector3 inertia(0,0,0);
btScalar mass = ObjData->DynData.Mass;
bool isDynamic = (mass != 0.f);
if (isDynamic)
ObjData->mObjShape->calculateLocalInertia(mass, inertia);
//Create BtOgre MotionState (connects Ogre and Bullet).
ObjData->mObjState = new BtOgre::RigidBodyState(ObjData->mObjNode);
//Create the Body.
ObjData->mObjBody = new btRigidBody(mass, ObjData->mObjState, ObjData->mObjShape, inertia);
Globals::phyWorld->addRigidBody(ObjData->mObjBody);
Code: Select all
//Create flat surface plane.
mGroundEntity = mSceneMgr->createEntity("groundEntity", "FlatPlane.mesh");
mSceneMgr->getRootSceneNode()->createChildSceneNode("groundNode")->attachObject(mGroundEntity);
mGroundEntity->setMaterialName("Examples/GrassFloor");
mGroundEntity->setCastShadows(false);
//Create the ground shape.
BtOgre::StaticMeshToShapeConverter converter2(mGroundEntity);
mGroundShape = converter2.createTrimesh();
//mGroundShape = converter2.createBox();
//mGroundShape->setMargin(0.5);
//Create MotionState (no need for BtOgre here, you can use it if you want to though).
btDefaultMotionState* groundState = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)));
//Create the Body.
mGroundBody = new btRigidBody(0, groundState, mGroundShape, btVector3(0,0,0));
Globals::phyWorld->addRigidBody(mGroundBody);
have this working.
Garibalde