Game Development Reference
In-Depth Information
F IGURE 17.6
The fractures of a concrete block.
// Find out if we're block one or two in the contact structure, and
// therefore what the contact normal is.
cyclone::Vector3 normal = contact.contactNormal;
cyclone::RigidBody *body = contact.body[0];
if (body != target->body)
{
normal.invert();
body = contact.body[1];
}
// Work out where on the body (in body coordinates) the contact is
// and its direction.
cyclone::Vector3 point =
body->getPointInLocalSpace(contact.contactPoint);
normal = body->getDirectionInLocalSpace(normal);
// Work out the center of the split: this is the point coordinates
// for each of the axes perpendicular to the normal, and 0 for the
// axis along the normal.
point = point - normal * (point * normal);
// Take a copy of the half size, so we can create the new blocks.
cyclone::Vector3 size = target->halfSize;
// Take a copy also of the body's other data.
Search Nedrilad ::




Custom Search