Game Development Reference
In-Depth Information
}
else
{
// Otherwise we need to calculate the mass.
cyclone::real volume = halfSize.magnitude() * 2.0;
cyclone::real mass = volume / invDensity;
body->setMass(mass);
// And calculate the inertia tensor from the mass and size.
mass *= 0.333f;
cyclone::Matrix3 tensor;
tensor.setInertiaTensorCoeffs(
mass * halfSize.y*halfSize.y + halfSize.z*halfSize.z,
mass * halfSize.y*halfSize.x + halfSize.z*halfSize.z,
mass * halfSize.y*halfSize.x + halfSize.z*halfSize.y
);
body->setInertiaTensor(tensor);
}
}
Creating a general-purpose fracture physics system involves more geometric
processing than physics knowledge. Some developers have gone this route, and there
are a couple of middleware vendors with similar technologies. But to trap all useful
scenarios is a moderately long task—certainly as long as the contact resolution or
rigid-body algorithms we have created.
17.2.3
E XPLOSIVE P HYSICS
Explosions have been around from the earliest days of gaming and were the appli-
cation of the first physics engines: particle engines creating smoke and debris. Explo-
sions are a whole lot more fun with proper physics; there's something gratifying about
watching debris scattered around the level.
Explosions are easy to create with a custom force generator. We could create a
force generator that simply imparts a force to objects near the blast point. This would
send objects cascading, but ultimately would be dull to look at. It has two problems.
First, the explosion effect is quite monotonous: objects just fly out. Second, applying
forces alone doesn't cause objects to spin.
A movie-quality explosion effect has three components: an initial implosion, an
all-around explosion, with an expanding concussion wave, and a convection chimney.
Each of these components has a slightly different behavior.
Search Nedrilad ::




Custom Search