Class Physics

java.lang.Object
xyz.jeremynoesen.pseudo3d.core.util.Box
xyz.jeremynoesen.pseudo3d.core.object.Physics
Direct Known Subclasses:
Entity

public abstract class Physics
extends Box
Axis-aligned bounding box physics object
  • Constructor Summary

    Constructors
    Constructor Description
    Physics()
    Create new default Physics object
    Physics​(Physics physics)
    Copy constructor for Physics objects
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object o)
    Check if another set of Physics data is equal to this one
    Vector getAcceleration()
    Get the acceleration of the object
    java.util.HashSet<Side> getCollideableSides()
    Get the Sides the object can collide on
    java.util.HashSet<Physics> getCollidingObjects​(Side... side)
    Get all objects colliding on the specified Sides
    Specify no Sides to get all objects colliding with this object
    java.util.HashSet<Side> getCollidingSides()
    Get all the Sides the object is colliding on
    float getDrag​(Side side)
    Get the drag coefficient of the object for a Side
    float getFriction​(Side side)
    Get the coefficient of friction of the object for a Side
    Vector getGravity()
    Get the gravity applied to the object
    java.util.HashSet<Axis> getKinematicAxes()
    Get the Axes the object is kinematic on
    float getMass()
    Get the mass of the object
    java.util.HashSet<Physics> getOverlappingObjects()
    Get the set of all objects overlapping this one
    java.util.HashSet<Axis> getPushableAxes()
    Get the Axes the object is pushable on
    Vector getVelocity()
    Get the velocity of the object
    boolean isCollideable​(Side... side)
    Check which Sides the object is collideable on
    Specify no Sides to check if collideable in general
    boolean isColliding()
    Check if the object is currently colliding with another object
    boolean isColliding​(Physics... physics)
    Check if one or more specific objects are colliding with this object
    boolean isColliding​(Physics physics, Side side)
    Check if a specific object collides with this one on a specific Side
    boolean isColliding​(Side... side)
    Check if this object is colliding on the specified Sides
    boolean isKinematic​(Axis... axis)
    Check which Axes the object is kinematic on
    Specify no Axes to check if kinematic in general
    boolean isOverlapping​(Physics... physics)
    Check if this object overlaps one or more objects
    boolean isPushable​(Axis... axis)
    Check which Axes the object is pushable on
    Specify no Axes to check if pushable in general
    protected boolean isUpdatable()
    Check if the object can update
    This is only able to be called by the parent class
    Physics setAcceleration​(Vector acceleration)
    Set the acceleration of the object
    Physics setCollideable​(Side... side)
    Set the Sides the object can collide on
    Specify no Sides to make non-collideable
    Physics setDrag​(float left, float right, float bottom, float top, float back, float front)
    Set the drag coefficients for all Sides
    Physics setDrag​(float drag, Side... side)
    Set the drag coefficient for the object on specific Sides
    Specify no Sides to apply to all Sides
    Physics setFriction​(float left, float right, float bottom, float top, float back, float front)
    Set the coefficients of friction for all Sides
    Physics setFriction​(float friction, Side... side)
    Set the coefficient of friction for the object on specific Sides
    Specify no Sides to apply to all Sides
    Physics setGravity​(Vector gravity)
    Set the gravity applied to the object
    Physics setKinematic​(Axis... axis)
    Set the Axes the object can move on
    Specify no Axes to make non-kinematic
    Physics setMass​(float mass)
    Set the mass of the object
    Physics setPushable​(Axis... axis)
    Set the Axes the object can be pushed on
    Specify no Axes to make non-pushable
    protected void setSceneObjects​(java.util.LinkedList<? extends Physics> objects)
    Set the objects this object is in a Scene with
    This is only able to be called by the parent class
    protected void setUpdatable​(boolean updatable)
    Set if the object can update
    This is only able to be called by the parent class
    Physics setVelocity​(Vector velocity)
    Set the velocity of the object
    void tickCollisions()
    Check if an object has collided with this object
    void tickMotion​(float deltaTime)
    Update the motion of the object

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Physics

      public Physics()
      Create new default Physics object
    • Physics

      public Physics​(Physics physics)
      Copy constructor for Physics objects
      Parameters:
      physics - Physics object to copy
  • Method Details

    • tickMotion

      public void tickMotion​(float deltaTime)
      Update the motion of the object
      Parameters:
      deltaTime - Time elapsed in the previous tick
    • tickCollisions

      public void tickCollisions()
      Check if an object has collided with this object
    • getVelocity

      public Vector getVelocity()
      Get the velocity of the object
      Returns:
      Velocity Vector of the object
    • setVelocity

      public Physics setVelocity​(Vector velocity)
      Set the velocity of the object
      Parameters:
      velocity - Velocity Vector
      Returns:
      This Physics object
    • getAcceleration

      public Vector getAcceleration()
      Get the acceleration of the object
      Returns:
      Acceleration Vector of the object
    • setAcceleration

      public Physics setAcceleration​(Vector acceleration)
      Set the acceleration of the object
      Parameters:
      acceleration - Acceleration Vector
      Returns:
      This Physics object
    • getGravity

      public Vector getGravity()
      Get the gravity applied to the object
      Returns:
      Gravity Vector
    • setGravity

      public Physics setGravity​(Vector gravity)
      Set the gravity applied to the object
      Parameters:
      gravity - Gravity Vector
      Returns:
      This Physics object
    • getMass

      public float getMass()
      Get the mass of the object
      Returns:
      Mass of the object
    • setMass

      public Physics setMass​(float mass)
      Set the mass of the object
      Parameters:
      mass - New mass for the object
      Returns:
      This Physics object
    • getDrag

      public float getDrag​(Side side)
      Get the drag coefficient of the object for a Side
      Parameters:
      side - Side to get drag coefficient of
      Returns:
      Drag coefficient of the object Side
    • setDrag

      public Physics setDrag​(float drag, Side... side)
      Set the drag coefficient for the object on specific Sides
      Specify no Sides to apply to all Sides
      Parameters:
      drag - Drag coefficient
      side - Sides to set drag for
      Returns:
      This Physics object
    • setDrag

      public Physics setDrag​(float left, float right, float bottom, float top, float back, float front)
      Set the drag coefficients for all Sides
      Parameters:
      left - Drag coefficient for the left Side
      right - Drag coefficient for the right Side
      bottom - Drag coefficient for the bottom Side
      top - Drag coefficient for the top Side
      back - Drag coefficient for the back Side
      front - Drag coefficient for the front Side
      Returns:
      This Physics object
    • getFriction

      public float getFriction​(Side side)
      Get the coefficient of friction of the object for a Side
      Parameters:
      side - Side to get coefficient of friction of
      Returns:
      Coefficient of friction of the object Side
    • setFriction

      public Physics setFriction​(float friction, Side... side)
      Set the coefficient of friction for the object on specific Sides
      Specify no Sides to apply to all Sides
      Parameters:
      friction - Coefficient of friction
      side - Sides to set coefficient of friction for
      Returns:
      This Physics object
    • setFriction

      public Physics setFriction​(float left, float right, float bottom, float top, float back, float front)
      Set the coefficients of friction for all Sides
      Parameters:
      left - Coefficient of friction for the left Side
      right - Coefficient of friction for the right Side
      bottom - Coefficient of friction for the bottom Side
      top - Coefficient of friction for the top Side
      back - Coefficient of friction for the back Side
      front - Coefficient of friction for the front Side
      Returns:
      This Physics object
    • isCollideable

      public boolean isCollideable​(Side... side)
      Check which Sides the object is collideable on
      Specify no Sides to check if collideable in general
      Returns:
      True if collideable on all specified Sides
    • setCollideable

      public Physics setCollideable​(Side... side)
      Set the Sides the object can collide on
      Specify no Sides to make non-collideable
      Parameters:
      side - Sides to set collidable
      Returns:
      This Physics object
    • getCollideableSides

      public java.util.HashSet<Side> getCollideableSides()
      Get the Sides the object can collide on
      Returns:
      HashSet of Sides the Object can collide on
    • isKinematic

      public boolean isKinematic​(Axis... axis)
      Check which Axes the object is kinematic on
      Specify no Axes to check if kinematic in general
      Returns:
      True if kinematic on all specified Axes
    • setKinematic

      public Physics setKinematic​(Axis... axis)
      Set the Axes the object can move on
      Specify no Axes to make non-kinematic
      Parameters:
      axis - Axes to set as kinematic
      Returns:
      This Physics object
    • getKinematicAxes

      public java.util.HashSet<Axis> getKinematicAxes()
      Get the Axes the object is kinematic on
      Returns:
      HashSet of Axes the object is kinematic on
    • isPushable

      public boolean isPushable​(Axis... axis)
      Check which Axes the object is pushable on
      Specify no Axes to check if pushable in general
      Returns:
      True if pushable on all specified Axes
    • setPushable

      public Physics setPushable​(Axis... axis)
      Set the Axes the object can be pushed on
      Specify no Axes to make non-pushable
      Parameters:
      axis - Axes to set as pushable
      Returns:
      This Physics object
    • getPushableAxes

      public java.util.HashSet<Axis> getPushableAxes()
      Get the Axes the object is pushable on
      Returns:
      HashSet of Axes the object is pushable on
    • isColliding

      public boolean isColliding()
      Check if the object is currently colliding with another object
      Returns:
      True if the object is colliding with another object
    • isColliding

      public boolean isColliding​(Physics... physics)
      Check if one or more specific objects are colliding with this object
      Parameters:
      physics - objects to check if colliding with
      Returns:
      True if this object collides with the other objects
    • isColliding

      public boolean isColliding​(Side... side)
      Check if this object is colliding on the specified Sides
      Parameters:
      side - Sides of the object
      Returns:
      True if the object is colliding on the Sides
    • isColliding

      public boolean isColliding​(Physics physics, Side side)
      Check if a specific object collides with this one on a specific Side
      Parameters:
      physics - Object to check if colliding with
      side - Side of object
      Returns:
      True if the object is colliding with the other object on the specified Side
    • getCollidingObjects

      public java.util.HashSet<Physics> getCollidingObjects​(Side... side)
      Get all objects colliding on the specified Sides
      Specify no Sides to get all objects colliding with this object
      Parameters:
      side - Sides to get colliding objects of
      Returns:
      Set of all objects colliding on the Sides
    • getCollidingSides

      public java.util.HashSet<Side> getCollidingSides()
      Get all the Sides the object is colliding on
      Returns:
      Set of all colliding Sides
    • isOverlapping

      public boolean isOverlapping​(Physics... physics)
      Check if this object overlaps one or more objects
      Parameters:
      physics - Objects to check for overlap
      Returns:
      True if this object overlaps the specified objects
    • getOverlappingObjects

      public java.util.HashSet<Physics> getOverlappingObjects()
      Get the set of all objects overlapping this one
      Returns:
      Set of overlapping objects
    • setUpdatable

      protected void setUpdatable​(boolean updatable)
      Set if the object can update
      This is only able to be called by the parent class
      Parameters:
      updatable - True to allow updating
    • isUpdatable

      protected boolean isUpdatable()
      Check if the object can update
      This is only able to be called by the parent class
      Returns:
      True if object can update
    • setSceneObjects

      protected void setSceneObjects​(java.util.LinkedList<? extends Physics> objects)
      Set the objects this object is in a Scene with
      This is only able to be called by the parent class
      Parameters:
      objects - List of Physics objects
    • equals

      public boolean equals​(java.lang.Object o)
      Check if another set of Physics data is equal to this one
      Overrides:
      equals in class Box
      Parameters:
      o - Physics to check for equality
      Returns:
      True if other Physics data is equivalent to this