Class Material

java.lang.Object
technology.sola.engine.physics.Material

@NullMarked public class Material extends Object
Material represents a physical material for physics simulations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Material
    Material with mass set to 1, restitution set to 0.01 and friction set to 0.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Material(float mass)
    Creates a material with custom mass.
    Material(float mass, float restitution)
    Creates a material with custom mass and restitution.
    Material(float mass, float restitution, float friction)
    Creates a material with custom mass, restitution and friction.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    float
    Gets the friction of the material.
    float
    Gets the inverse mass (1 / mass).
    float
    Gets the mass of the material.
    float
    Gets the restitution (bounciness) of the material.
    int
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNIT_MASS_MATERIAL

      public static final Material UNIT_MASS_MATERIAL
      Material with mass set to 1, restitution set to 0.01 and friction set to 0.
  • Constructor Details

    • Material

      public Material(float mass)
      Creates a material with custom mass. Restitution is set to a low value of 0.01 and friction is set to 0.
      Parameters:
      mass - the mass of the material, must be greater than or equal to 0
    • Material

      public Material(float mass, float restitution)
      Creates a material with custom mass and restitution. Friction is set to 0.
      Parameters:
      mass - the mass of the material, must be greater than or equal to 0
      restitution - the restitution (bounciness) of the material, must be greater than or equal to 0
    • Material

      public Material(float mass, float restitution, float friction)
      Creates a material with custom mass, restitution and friction.
      Parameters:
      mass - the mass of the material, must be greater than or equal to 0
      restitution - the restitution (bounciness) of the material, must be greater than or equal to 0
      friction - the friction from this material, must be greater than or equal to 0
  • Method Details

    • getMass

      public float getMass()
      Gets the mass of the material.
      Returns:
      the mass of the material
    • getInverseMass

      public float getInverseMass()
      Gets the inverse mass (1 / mass). This value is pre-calculated since it is used often.
      Returns:
      the inverse mass
    • getRestitution

      public float getRestitution()
      Gets the restitution (bounciness) of the material.
      Returns:
      the restitution of the material
    • getFriction

      public float getFriction()
      Gets the friction of the material.
      Returns:
      the friction of the material
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object