Class Box2dSteeringBody

java.lang.Object
com.devcharles.piazzapanic.utility.box2d.Box2dSteeringBody
All Implemented Interfaces:
com.badlogic.gdx.ai.steer.Limiter, com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>, com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>

public class Box2dSteeringBody extends Object implements com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
Box2D Body and logic for AI agents, the Box2dSteeringBody responds to inputs from a SteeringBehavior. If no behaviour is set, the body will not move.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) com.badlogic.gdx.physics.box2d.Body
     
    (package private) float
     
    (package private) boolean
     
    (package private) float
     
    (package private) float
     
    (package private) float
     
    (package private) float
     
    protected com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2>
     
    private static final com.badlogic.gdx.ai.steer.SteeringAcceleration<com.badlogic.gdx.math.Vector2>
     
    (package private) boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Box2dSteeringBody(com.badlogic.gdx.physics.box2d.Body body, boolean independentFacing, float boundingRadius)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.badlogic.gdx.math.Vector2
    angleToVector(com.badlogic.gdx.math.Vector2 outVector, float angle)
    Returns the unit vector in the direction of the specified angle expressed in radians.
    protected void
    applySteering(com.badlogic.gdx.ai.steer.SteeringAcceleration<com.badlogic.gdx.math.Vector2> steering, float deltaTime)
     
    float
    Returns the float value indicating the the angular velocity in radians of this Steerable.
    com.badlogic.gdx.physics.box2d.Body
     
    float
    Returns the bounding radius of this Steerable.
    com.badlogic.gdx.math.Vector2
    Returns the vector indicating the linear velocity of this Steerable.
    float
    Returns the maximum angular acceleration.
    float
    Returns the maximum angular speed.
    float
    Returns the maximum linear acceleration.
    float
    Returns the maximum linear speed.
    float
    Returns the float value indicating the orientation of this location.
    com.badlogic.gdx.math.Vector2
    Returns the vector indicating the position of this location.
    com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2>
     
    float
    Returns the threshold below which the linear speed can be considered zero.
    boolean
     
    boolean
    Returns true if this Steerable is tagged; false otherwise.
    com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
    Creates a new location.
    void
    setBody(com.badlogic.gdx.physics.box2d.Body body)
     
    void
    setIndependentFacing(boolean independentFacing)
     
    void
    setMaxAngularAcceleration(float maxAngularAcceleration)
    Sets the maximum angular acceleration.
    void
    setMaxAngularSpeed(float maxAngularSpeed)
    Sets the maximum angular speed.
    void
    setMaxLinearAcceleration(float maxLinearAcceleration)
    Sets the maximum linear acceleration.
    void
    setMaxLinearSpeed(float maxLinearSpeed)
    Sets the maximum linear speed.
    void
    setOrientation(float orientation)
    Sets the orientation of this location, i.e.
    void
    setSteeringBehavior(com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> steeringBehavior)
     
    void
    setTagged(boolean tagged)
    Tag/untag this Steerable.
    void
    Sets the threshold below which the linear speed can be considered zero.
    void
    update(float deltaTime)
     
    float
    vectorToAngle(com.badlogic.gdx.math.Vector2 vector)
    Returns the angle in radians pointing along the specified vector.

    Methods inherited from class java.lang.Object

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

    • body

      com.badlogic.gdx.physics.box2d.Body body
    • boundingRadius

      float boundingRadius
    • tagged

      boolean tagged
    • maxLinearSpeed

      float maxLinearSpeed
    • maxLinearAcceleration

      float maxLinearAcceleration
    • maxAngularSpeed

      float maxAngularSpeed
    • maxAngularAcceleration

      float maxAngularAcceleration
    • independentFacing

      boolean independentFacing
    • steeringBehavior

      protected com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> steeringBehavior
    • steeringOutput

      private static final com.badlogic.gdx.ai.steer.SteeringAcceleration<com.badlogic.gdx.math.Vector2> steeringOutput
  • Constructor Details

    • Box2dSteeringBody

      public Box2dSteeringBody(com.badlogic.gdx.physics.box2d.Body body, boolean independentFacing, float boundingRadius)
  • Method Details

    • getBody

      public com.badlogic.gdx.physics.box2d.Body getBody()
    • setBody

      public void setBody(com.badlogic.gdx.physics.box2d.Body body)
    • isIndependentFacing

      public boolean isIndependentFacing()
    • setIndependentFacing

      public void setIndependentFacing(boolean independentFacing)
    • getPosition

      public com.badlogic.gdx.math.Vector2 getPosition()
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Returns the vector indicating the position of this location.
      Specified by:
      getPosition in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
    • getOrientation

      public float getOrientation()
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Returns the float value indicating the orientation of this location. The orientation is the angle in radians representing the direction that this location is facing.
      Specified by:
      getOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
    • setOrientation

      public void setOrientation(float orientation)
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Sets the orientation of this location, i.e. the angle in radians representing the direction that this location is facing.
      Specified by:
      setOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      Parameters:
      orientation - the orientation in radians
    • getLinearVelocity

      public com.badlogic.gdx.math.Vector2 getLinearVelocity()
      Description copied from interface: com.badlogic.gdx.ai.steer.Steerable
      Returns the vector indicating the linear velocity of this Steerable.
      Specified by:
      getLinearVelocity in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
    • getAngularVelocity

      public float getAngularVelocity()
      Description copied from interface: com.badlogic.gdx.ai.steer.Steerable
      Returns the float value indicating the the angular velocity in radians of this Steerable.
      Specified by:
      getAngularVelocity in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
    • getBoundingRadius

      public float getBoundingRadius()
      Description copied from interface: com.badlogic.gdx.ai.steer.Steerable
      Returns the bounding radius of this Steerable.
      Specified by:
      getBoundingRadius in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
    • isTagged

      public boolean isTagged()
      Description copied from interface: com.badlogic.gdx.ai.steer.Steerable
      Returns true if this Steerable is tagged; false otherwise.
      Specified by:
      isTagged in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
    • setTagged

      public void setTagged(boolean tagged)
      Description copied from interface: com.badlogic.gdx.ai.steer.Steerable
      Tag/untag this Steerable. This is a generic flag utilized in a variety of ways.
      Specified by:
      setTagged in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
      Parameters:
      tagged - the boolean value to set
    • newLocation

      public com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2> newLocation()
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Creates a new location.

      This method is used internally to instantiate locations of the correct type parameter T. This technique keeps the API simple and makes the API easier to use with the GWT backend because avoids the use of reflection.

      Specified by:
      newLocation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      Returns:
      the newly created location.
    • vectorToAngle

      public float vectorToAngle(com.badlogic.gdx.math.Vector2 vector)
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Returns the angle in radians pointing along the specified vector.
      Specified by:
      vectorToAngle in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      Parameters:
      vector - the vector
    • angleToVector

      public com.badlogic.gdx.math.Vector2 angleToVector(com.badlogic.gdx.math.Vector2 outVector, float angle)
      Description copied from interface: com.badlogic.gdx.ai.utils.Location
      Returns the unit vector in the direction of the specified angle expressed in radians.
      Specified by:
      angleToVector in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      Parameters:
      outVector - the output vector.
      angle - the angle in radians.
      Returns:
      the output vector for chaining.
    • getSteeringBehavior

      public com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> getSteeringBehavior()
    • setSteeringBehavior

      public void setSteeringBehavior(com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> steeringBehavior)
    • update

      public void update(float deltaTime)
    • applySteering

      protected void applySteering(com.badlogic.gdx.ai.steer.SteeringAcceleration<com.badlogic.gdx.math.Vector2> steering, float deltaTime)
    • getMaxLinearSpeed

      public float getMaxLinearSpeed()
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Returns the maximum linear speed.
      Specified by:
      getMaxLinearSpeed in interface com.badlogic.gdx.ai.steer.Limiter
    • setMaxLinearSpeed

      public void setMaxLinearSpeed(float maxLinearSpeed)
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Sets the maximum linear speed.
      Specified by:
      setMaxLinearSpeed in interface com.badlogic.gdx.ai.steer.Limiter
    • getMaxLinearAcceleration

      public float getMaxLinearAcceleration()
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Returns the maximum linear acceleration.
      Specified by:
      getMaxLinearAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
    • setMaxLinearAcceleration

      public void setMaxLinearAcceleration(float maxLinearAcceleration)
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Sets the maximum linear acceleration.
      Specified by:
      setMaxLinearAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
    • getMaxAngularSpeed

      public float getMaxAngularSpeed()
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Returns the maximum angular speed.
      Specified by:
      getMaxAngularSpeed in interface com.badlogic.gdx.ai.steer.Limiter
    • setMaxAngularSpeed

      public void setMaxAngularSpeed(float maxAngularSpeed)
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Sets the maximum angular speed.
      Specified by:
      setMaxAngularSpeed in interface com.badlogic.gdx.ai.steer.Limiter
    • getMaxAngularAcceleration

      public float getMaxAngularAcceleration()
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Returns the maximum angular acceleration.
      Specified by:
      getMaxAngularAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
    • setMaxAngularAcceleration

      public void setMaxAngularAcceleration(float maxAngularAcceleration)
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Sets the maximum angular acceleration.
      Specified by:
      setMaxAngularAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
    • getZeroLinearSpeedThreshold

      public float getZeroLinearSpeedThreshold()
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Returns the threshold below which the linear speed can be considered zero. It must be a small positive value near to zero. Usually it is used to avoid updating the orientation when the velocity vector has a negligible length.
      Specified by:
      getZeroLinearSpeedThreshold in interface com.badlogic.gdx.ai.steer.Limiter
    • setZeroLinearSpeedThreshold

      public void setZeroLinearSpeedThreshold(float value)
      Description copied from interface: com.badlogic.gdx.ai.steer.Limiter
      Sets the threshold below which the linear speed can be considered zero. It must be a small positive value near to zero. Usually it is used to avoid updating the orientation when the velocity vector has a negligible length.
      Specified by:
      setZeroLinearSpeedThreshold in interface com.badlogic.gdx.ai.steer.Limiter