Deformable objects are basically cloth objects skinned to a skeleton. Unlike cloth, they are not constantly moving, but instead "freeze" in their deformed position, so they can be used to create deformable metal or other bending materials. To set up a deformable object, first make sure it is sufficiently tessellated, so the deformation looks convincing. A deformable object consists of two nodes: The render mesh, physics mesh, and the skeleton. The skeleton is the actual deforming object, the rendermesh and physics mesh are following its deformations in a similar fashion similarly to how a skinned character mesh is following bones.
The skeleton is not an actual bone setup in a DCC package, but simply a normal geometry mesh. Its shape has to be similar to the rendermesh. The way the mesh is following the deformation of the skeleton is controlled through the position of the skeleton mesh vertices. If the skeleton vertices are outside of the render mesh, they are considered attached to the object and won't be deformed. If they are inside of the rendermesh, the mesh will be "skinned" to them and follow their deformation. This can be used to control the degree of bending (i.e. with a deformable box, pulling the skeleton vertices at the edge of the box outside of the rendermesh will make this edge "stiff" or fixed, while the rest of the mesh is following the deformation completely).
There are several parameters for controlling the skeleton behavior. They have to be entered into the skeleton node's user defined properties (in 3dsmax).
Property | Description |
---|---|
stiffness=VALUE | Resilience to bending and shearing (default 10) |
hardness=VALUE | Resilience to stretching (default 10) |
max_stretch=VALUE | If any edge is stretched more than that, its length is re-enforced. max_stretch = 0.3 means stretched to 130% of its original length (or by 30% wrt to its original length). default 0.01 |
max_impulse=VALUE | Upper limit on all applied impulses. default skeleton's mass*100 |
skin_dist=VALUE | Sphere radius in skinning assignment. Default is the minimum of the main mesh's bounding box's dimensions (see below) |
thickness=VALUE | Sets the collision thickness for the skeleton. The skeleton collides as a cloth object, i.e. it has virtual spheres with this radius around each vertex, and it has less priority than the geometries it collides with (it will un-project itself unconditionally from them). It collides with static and rigid body objects only. It will collide with parts of the same entity it belongs to, except the one it skins (this way it's possible to set up safety shells inside the object to prevent excessive deformations). Setting thickness to 0 disables all collisions. |
notaprim=VALUE | A general physics proxy parameter, it keeps the physics mesh from being turned into a primitive (box, cylinder). This is especially important for deformable objects - the skeleton being a primitive will cause a crash! |
explosion_scale=VALUE | Used to scale down the effect of explosions on the deformable. This lets you have visible deformations from bullet impacts, but without vastly distorting the object too far with explosions. |
For each main mesh's vertex (both physics and render independently, if they are different) a sphere with a fixed radius is created around it and is checked for collisions with the skeleton mesh. Based on the collision region, the average collision normal is computed and the sphere is 'moved' along it until it finds the touch point. This point is then considered the main mesh vertex's projection on the skeleton, and it's later tied to it. If the first sphere test finds no collisions, the code does a second check, with a sphere 3 times larger. The radius of this sphere can be adjusted with skin_dist.