Compound Bodies

The Skull as a Compound Body

The skull is an interesting shape to try to compound and you can see it in all its magnificence here: Skull As A Compound Body

It is roughly composed of a sphere for most of it with a box around the jaw area, with a bit of work involved to position the sphere and box as best as possible. The skull is compounded to these two covering meshes.

Note Center of mass is at the origin of the compound object.

Compound to Empty Mesh

  1. Create an empty mesh to be used as a parent for the compound body;
  2. Create a range of appropriately shaped standard meshes to fit over the irregular mesh;
  3. Parent the standard meshes and the irregular mesh to the empty mesh;
  4. Calculate or estimate the mass for each standard mesh;
  5. Create physics imposters for each standard mesh with zero mass;
  6. Create a physics imposter for the empty mesh, using the NoImposter property, with the total mass of all the standard meshes.

Note Step 3 MUST come before step 4 and step 5 before step 6.

Skull As A Compound Body 1

Compound Covering Meshes to The Complex Mesh

  1. Create a range of appropriately shaped standard meshes to fit over the irregular mesh;
  2. Parent the standard meshes to the irregular mesh;
  3. Calculate or estimate the mass for each standard mesh;
  4. Create physics imposters for each standard mesh with zero mass;
  5. Create a physics imposter for the irregular mesh, using the NoImposter property, with the total mass of all the standard meshes.

Note Steps 2, 4 and 5 must be in that order.

Skull As A Compound Body 2

Compound to One of the Covering Meshes

  1. Create a range of appropriately shaped standard meshes to fit over the irregular mesh;
  2. Choose one standard mesh and parent the other standard meshes and the irregular mesh to this mesh;
  3. Calculate or estimate the mass for each standard mesh;
  4. Create physics imposters for each standard mesh with the assumed mass;

Note Step 2 MUST come before step 4.

Skull As A Compound Body 3

Further reading

Using A Physics Engine
Learn how to use one of the available physics engines in Babylon.js.
Forces
Learn all about applying physical forces in Babylon.js.
Joints
Learn all about using joints in physics engines within Babylon.js.
Pivots and Axes
Learn all about physics pivots and axes in Babylon.js.
Soft Bodies
Learn all about physics soft bodies in Babylon.js.
Advanced Physics Features
Unlock the full potential of physics with advanced physics features in Babylon.js.
Add Your Own Physics Engine
Learn how to add your own physics engine to Babylon.js.