Game Development Reference
In-Depth Information
The two key values that we can set are the soft body's volume conservation coeffi-
cient and it's linear stiffness. Each of these values affects a specific property of the
soft body, altering how well it maintains its original shape as it moves and collides
with other objects.
// set the 'volume conservation coefficient'
pSoftBody->m_cfg.kVC = 0.5;
// set the 'linear stiffness'
pSoftBody->m_materials[0]->m_kLST = 0.5;
Tip
Note that m_materials is an array of different materials, which can be assigned
to different sections of the same soft body if desired. Make sure that you manip-
ulate it keeping this is mind.
The remaining initialization for our soft body comes through the setTotalMass()
and setPose() functions. As we might expect, setTotalMass() simply sets the
mass of the soft body, but it also has a profound effect on how the object deforms
when it collides with other objects. If we want our shootable boxes to distort the soft
body, its mass needs to be relatively low. If we want it to ignore them, then we should
set the mass very high.
Finally, setPose() is used to generate the necessary constraints of the soft body,
telling it to maintain the current pose in which its constituent vertices are positioned.
This function takes two booleans, determining if the soft body should attempt to
maintain its volume and frame, respectively; each has a significant effect on how the
soft body moves.
// set the total mass of the soft body
pSoftBody->setTotalMass(5);
// tell the soft body to initialize and
// attempt to maintain the current pose
pSoftBody->setPose(true,false);
Search WWH ::




Custom Search