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
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
Check if another set of Physics data is equal to this oneVector
getAcceleration()
Get the acceleration of the objectjava.util.HashSet<Side>
getCollideableSides()
Get the Sides the object can collide onjava.util.HashSet<Physics>
getCollidingObjects(Side... side)
Get all objects colliding on the specified Sides
Specify no Sides to get all objects colliding with this objectjava.util.HashSet<Side>
getCollidingSides()
Get all the Sides the object is colliding onfloat
getDrag(Side side)
Get the drag coefficient of the object for a Sidefloat
getFriction(Side side)
Get the coefficient of friction of the object for a SideVector
getGravity()
Get the gravity applied to the objectjava.util.HashSet<Axis>
getKinematicAxes()
Get the Axes the object is kinematic onfloat
getMass()
Get the mass of the objectjava.util.HashSet<Physics>
getOverlappingObjects()
Get the set of all objects overlapping this onejava.util.HashSet<Axis>
getPushableAxes()
Get the Axes the object is pushable onVector
getVelocity()
Get the velocity of the objectboolean
isCollideable(Side... side)
Check which Sides the object is collideable on
Specify no Sides to check if collideable in generalboolean
isColliding()
Check if the object is currently colliding with another objectboolean
isColliding(Physics... physics)
Check if one or more specific objects are colliding with this objectboolean
isColliding(Physics physics, Side side)
Check if a specific object collides with this one on a specific Sideboolean
isColliding(Side... side)
Check if this object is colliding on the specified Sidesboolean
isKinematic(Axis... axis)
Check which Axes the object is kinematic on
Specify no Axes to check if kinematic in generalboolean
isOverlapping(Physics... physics)
Check if this object overlaps one or more objectsboolean
isPushable(Axis... axis)
Check which Axes the object is pushable on
Specify no Axes to check if pushable in generalprotected boolean
isUpdatable()
Check if the object can update
This is only able to be called by the parent classPhysics
setAcceleration(Vector acceleration)
Set the acceleration of the objectPhysics
setCollideable(Side... side)
Set the Sides the object can collide on
Specify no Sides to make non-collideablePhysics
setDrag(float left, float right, float bottom, float top, float back, float front)
Set the drag coefficients for all SidesPhysics
setDrag(float drag, Side... side)
Set the drag coefficient for the object on specific Sides
Specify no Sides to apply to all SidesPhysics
setFriction(float left, float right, float bottom, float top, float back, float front)
Set the coefficients of friction for all SidesPhysics
setFriction(float friction, Side... side)
Set the coefficient of friction for the object on specific Sides
Specify no Sides to apply to all SidesPhysics
setGravity(Vector gravity)
Set the gravity applied to the objectPhysics
setKinematic(Axis... axis)
Set the Axes the object can move on
Specify no Axes to make non-kinematicPhysics
setMass(float mass)
Set the mass of the objectPhysics
setPushable(Axis... axis)
Set the Axes the object can be pushed on
Specify no Axes to make non-pushableprotected 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 classprotected void
setUpdatable(boolean updatable)
Set if the object can update
This is only able to be called by the parent classPhysics
setVelocity(Vector velocity)
Set the velocity of the objectvoid
tickCollisions()
Check if an object has collided with this objectvoid
tickMotion(float deltaTime)
Update the motion of the objectMethods inherited from class xyz.jeremynoesen.pseudo3d.core.util.Box
contains, contains, getDepth, getDimensions, getFaceArea, getHeight, getMaximum, getMinimum, getPosition, getSurfaceArea, getVolume, getWidth, overlaps, setDepth, setDimensions, setDimensions, setHeight, setPosition, setWidth, toString
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
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
Get the velocity of the object- Returns:
- Velocity Vector of the object
-
setVelocity
Set the velocity of the object- Parameters:
velocity
- Velocity Vector- Returns:
- This Physics object
-
getAcceleration
Get the acceleration of the object- Returns:
- Acceleration Vector of the object
-
setAcceleration
Set the acceleration of the object- Parameters:
acceleration
- Acceleration Vector- Returns:
- This Physics object
-
getGravity
Get the gravity applied to the object- Returns:
- Gravity Vector
-
setGravity
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
Set the mass of the object- Parameters:
mass
- New mass for the object- Returns:
- This Physics object
-
getDrag
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
Set the drag coefficient for the object on specific Sides
Specify no Sides to apply to all Sides- Parameters:
drag
- Drag coefficientside
- Sides to set drag for- Returns:
- This Physics object
-
setDrag
Set the drag coefficients for all Sides- Parameters:
left
- Drag coefficient for the left Sideright
- Drag coefficient for the right Sidebottom
- Drag coefficient for the bottom Sidetop
- Drag coefficient for the top Sideback
- Drag coefficient for the back Sidefront
- Drag coefficient for the front Side- Returns:
- This Physics object
-
getFriction
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
Set the coefficient of friction for the object on specific Sides
Specify no Sides to apply to all Sides- Parameters:
friction
- Coefficient of frictionside
- 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 Sideright
- Coefficient of friction for the right Sidebottom
- Coefficient of friction for the bottom Sidetop
- Coefficient of friction for the top Sideback
- Coefficient of friction for the back Sidefront
- Coefficient of friction for the front Side- Returns:
- This Physics object
-
isCollideable
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
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
Get the Sides the object can collide on- Returns:
- HashSet of Sides the Object can collide on
-
isKinematic
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
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
Get the Axes the object is kinematic on- Returns:
- HashSet of Axes the object is kinematic on
-
isPushable
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
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
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
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
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
Check if a specific object collides with this one on a specific Side- Parameters:
physics
- Object to check if colliding withside
- Side of object- Returns:
- True if the object is colliding with the other object on the specified Side
-
getCollidingObjects
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
Get all the Sides the object is colliding on- Returns:
- Set of all colliding Sides
-
isOverlapping
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
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
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
-