Click or drag to resize
DigitalRuneMaterials

This section explains how to define the behavior of a rigid body using materials.

Materials

A material is a type that implements the interface IMaterial. A material can be assigned to a rigid body by setting the property RigidBodyMaterial. Materials define the behavior of the rigid body when it collides with another rigid body, especially:

  • Dry Friction: Friction resists relative lateral motion of two solid surfaces in contact. The friction properties can be changed to model slippery surface (ice) or rough surfaces (rubber).

  • Restitution (Bounciness): A rigid body colliding with another rigid body will bounce back. In a perfectly elastic collision the separation velocity after the collision is equal to the approach velocity before the collision. This is modeled with a coefficient of restitution of 1. In a perfectly inelastic collision the bodies do not separate after the collision. This is modeled with a coefficient of restitution of 0. The restitution can be varied between 0 and 1 to model the bounce behavior of different materials, like clay or elastic rubber.

  • Surface Motion: A surface velocity can be set to model bodies with moving surfaces, like conveyor belts.

Uniform, composite and custom materials

The default material classes are UniformMaterial and CompositeMaterial. A uniform material is a material that is identical on all surface points of a rigid body. This material is typically used for most bodies in a game. A composite material is a material that varies over the surface of the rigid body. This is very useful for rigid bodies where the shape is a CompositeShape or a TriangleMeshShape:

  • Composite shape example: A rigid body uses a composite shape to create a hammer. A composite material can be used to assign different materials to the metal hammer head and the wooden shaft.

  • Triangle mesh example: A single, static rigid body uses a triangle mesh shape to create the game level terrain. A composite material can be used to assign different materials to the triangles to create rough parts and slippery parts.

Custom material classes can be created by implementing the interface IMaterial. This can be used to create, for example, complex procedural, time-dependent material or optimized composite materials that use less memory and are optimized for your game.

Material property combiner
Note Note

Following information is for advanced users. In most scenarios changing material property combiners is not required.

In reality, material properties like friction and restitution depend on the two touching materials - they cannot be determined by looking at a single rigid body alone. Ice on rubber behaves different than ice on ice and rubber on rubber.

Types that implement the interface IMaterialPropertyCombiner can be used to define how two friction values or two restitution values are combined. In the standard implementation the class MaterialPropertyCombiner uses a mathematical operation (like multiplication or average) to combine the material properties. Custom material property combiners could use material tables to compute more realistic values.

The material property combiner of a simulation can be changed in the SimulationSettings. The simulation always uses the results of the material property combiner when contact between two rigid bodies needs to be simulated.

See Also