I want to create the simple deformation object. It will look like the wall which is deformed by shells.
Thus, it must be static soft body object.
Here is I'm creating Soft Body:
Code: Select all
- (id) initMeshToSoftBodyConverter:(BOOL)_static World:(ibWorld*)_world Name:(NSString*)_name SceneNode:(iSceneNode*)_node Entity:(iEntity*)_entity {
self = [super init];
world = _world;
m_softBodyWorldInfo.air_density = (btScalar)1.2;
m_softBodyWorldInfo.m_gravity = btVector3(0, 0, 0); //_world.world->getGravity();
m_softBodyWorldInfo.m_dispatcher = _world.dispatcher;
m_softBodyWorldInfo.m_sparsesdf.Reset();
m_softBodyWorldInfo.m_broadphase = _world.broadPhase;
m_softBodyWorldInfo.m_sparsesdf.Initialize();
staticSoftBoby = nil; dynamicSoftBody = nil;
if (_static) {
staticSoftBoby = new StaticMeshToSoftBodyConverter(&m_softBodyWorldInfo);
staticSoftBoby->addEntity(_entity.ent);
psb = staticSoftBoby->createSoftBodyFromTrimesh();
} else {
dynamicSoftBody = new AnimatedMeshToSoftBodyConverter(&m_softBodyWorldInfo);
dynamicSoftBody->addEntity(_entity.ent);
psb = dynamicSoftBody->createSoftBodyFromTrimesh();
}
btSoftBody::Material *pm=psb->appendMaterial();
pm->m_kLST = 0.1;
psb->m_cfg.piterations = 2;
psb->m_cfg.kDF = 0.5;
psb->m_cfg.collisions |= btSoftBody::fCollision::VF_SS;
psb->generateClusters(0);
psb->randomizeConstraints();
psb->setTotalMass(100,true);
psb->setUserPointer((__bridge void *)_name);
btSoftRigidDynamicsWorld *softWorld = (btSoftRigidDynamicsWorld *)_world.world;
softWorld->addSoftBody(psb);
return self;
}
BodyA - static ground floor;
Code: Select all
btSoftBody::LJoint::Specs ls;
ls.cfm = 1;
ls.erp = 1;
ls.position = btVector3(1, 0, 1);
softbody->appendLinearJoint(ls,BodyA);
Code: Select all
btSoftBody::AJoint::Specs aspecs;
aspecs.cfm = 1;
aspecs.erp = 1;
aspecs.axis = btVector3(0,1,0);
softbody->appendAngularJoint(aspecs,BodyA);
Maybe I'm doing something wrong. Please, help.
P.S. Using of Soft Body is decreasing very much FPS. Also if there is another way to create deformation wall.
Thanks.