Hi all!
I’d be interested in compound physical bodies and wonder how the rotational inertia tensor is actually determined. I was in hope that composing basic meshes (with child-parent relationship) giving each a mass would lead to an approximated inertia tensor. But obviously it isn’t.
Either do I get a runtime warning and strange physical behaviour or I need to have all children have mass=0
and only the top-level parent gets the overall mass (see below). This way I cannot model a compound e.g. of one heavy and one light sphere. The documentation about compounds is a bit contradictory as cited below.
So how to?
What comes to my mind is having multiple components connected by LockJoints (Cannon.js only)?
Hope for help,
. J
From https://doc.babylonjs.com/how_to/using_advanced_physics_features :
sphere2.physicsImpostor = new BABYLON.PhysicsImpostor(sphere2, BABYLON.PhysicsImpostor.SphereImpostor, {mass: 2, restitution: 0.8});
sphere.physicsImpostor = new BABYLON.PhysicsImpostor(sphere, BABYLON.PhysicsImpostor.SphereImpostor, {mass: 2, restitution: 0.8});
The mass will be accumulated. So this single physics body’s mass will be 4.
sphere2
's physics impostor will be “disabled” and will be joined tosphere
‘s impostor, which is the main impostor. To apply impulses, set the liner velocity etc’, usesphere.physicsImpostor
.
This might be true, but issues a warning at runtime:
A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.
In fact, the resp. samples don’t show the expected physical behavior (at least the child object has no mass or so).
Another place in the documentation (https://doc.babylonjs.com/how_to/compounds) states:
- Create an empty mesh to be used as a parent for the compound body;
- Create a range of appropriately shaped standard meshes to fit over the irregular mesh;
- Parent the standard meshes and the irregular mesh to the empty mesh;
- Calculate or estimate the mass for each standard mesh;
- Create physics imposters for each standard mesh with zero mass;
- Create a physics imposter for the empty mesh, using the NoImposter property, with the total mass of all the standard meshes.
This does not give me any control about mass distribution in the ensemble.