Material

class Material(val friction: Float = 0.4f, val staticFriction: Float = 0.6f, val restitution: Float = 0.0f)(source)

What a surface is like to touch: how much it grips and how much it bounces. Solids and particles each have one, and a contact mixes the two: grip by the geometric mean, so ice on anything slides, and bounce by the larger, so a rubber ball bounces on a stone floor. Pass the values by name.

Two materials are equal when every value is. toString gives every value, as Material(friction=0.4, staticFriction=0.6, restitution=0.0).

Throws

if friction or staticFriction is negative, or restitution is outside 0..1.

Samples

val bouncy = Material(friction = 0.2f, restitution = 0.8f)
val world = PhysicsWorld()
val ball = world.rigidBody(Shape.circle(8f), x = 0f, y = 0f, material = bouncy)
world.rigidBodies.setMaterial(ball, Material.ICE)
assertPrints(bouncy, "Material(friction=0.2, staticFriction=0.6, restitution=0.8)")

Constructors

Link copied to clipboard
constructor(friction: Float = 0.4f, staticFriction: Float = 0.6f, restitution: Float = 0.0f)

Types

Link copied to clipboard
object Companion

Holds materials many things are made of.

Properties

Link copied to clipboard

Grip while sliding, the Coulomb coefficient: a sliding thing loses this times the push holding it on the surface. 0 is ice.

Link copied to clipboard

How much of its speed into the surface a thing keeps, bouncing back out: 0 stops dead, 1 bounces forever.

Link copied to clipboard

Grip at rest: a thing stays put while the force along the surface is under this times the push holding it on. Something rests on a slope while this is over the slope's tangent: 0.58 for 30°.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String