Class Collider

java.lang.Object
rosequartz.coll.Collider
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AxisAlignedBoxCollider, SphereCollider

public abstract class Collider extends Object implements Serializable
Represents any collider, a shape that can be tested against other colliders to see if they touch or overlap (collide). This can be used for testing if something runs into a wall or the player enters a certain area.
See Also:
Serialized Form
  • Constructor Details

    • Collider

      public Collider()
  • Method Details

    • getCenter

      public Vec3 getCenter()
      Gets the average position of all vertices of the shape.
      Returns:
      center position
    • acceptColliderType

      protected <C extends Collider> void acceptColliderType(Class<C> colliderClass, Function<C,​Boolean> action)
      Registers a function for calculating collision between this collider and the given collider class. The function is then called every time this collider is checked against that collider.
      Type Parameters:
      C - the type of the collider that the function calculates
      Parameters:
      colliderClass - the class of the collider that the function calculates
      action - the calculating function
    • getColliding

      public <C extends Collider> boolean getColliding(C collider)
      Gets if this collider collides with the given collider.
      Type Parameters:
      C - the type of the checked collider
      Parameters:
      collider - the collider to check against this one
      Returns:
      collision found
    • getPointInside

      public boolean getPointInside(float x, float y, float z)
      Gets if the given positions are inside this collider.
      Parameters:
      x - the position of the point to check on the x-axis
      y - the position of the point to check on the y-axis
      z - the position of the point to check on the z-axis
      Returns:
      point inside this collider
    • getPointInside

      public boolean getPointInside(Vec3 xyz)
      Gets if the given positions are inside this collider.
      Parameters:
      xyz - the position of the point to check
      Returns:
      point inside this collider