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
FieldsModifier and TypeFieldDescription(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) floatprotected 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
ConstructorsConstructorDescriptionBox2dSteeringBody(com.badlogic.gdx.physics.box2d.Body body, boolean independentFacing, float boundingRadius) -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.Vector2angleToVector(com.badlogic.gdx.math.Vector2 outVector, float angle) Returns the unit vector in the direction of the specified angle expressed in radians.protected voidapplySteering(com.badlogic.gdx.ai.steer.SteeringAcceleration<com.badlogic.gdx.math.Vector2> steering, float deltaTime) floatReturns the float value indicating the the angular velocity in radians of this Steerable.com.badlogic.gdx.physics.box2d.BodygetBody()floatReturns the bounding radius of this Steerable.com.badlogic.gdx.math.Vector2Returns the vector indicating the linear velocity of this Steerable.floatReturns the maximum angular acceleration.floatReturns the maximum angular speed.floatReturns the maximum linear acceleration.floatReturns the maximum linear speed.floatReturns the float value indicating the orientation of this location.com.badlogic.gdx.math.Vector2Returns the vector indicating the position of this location.com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2>floatReturns the threshold below which the linear speed can be considered zero.booleanbooleanisTagged()Returnstrueif this Steerable is tagged;falseotherwise.com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>Creates a new location.voidsetBody(com.badlogic.gdx.physics.box2d.Body body) voidsetIndependentFacing(boolean independentFacing) voidsetMaxAngularAcceleration(float maxAngularAcceleration) Sets the maximum angular acceleration.voidsetMaxAngularSpeed(float maxAngularSpeed) Sets the maximum angular speed.voidsetMaxLinearAcceleration(float maxLinearAcceleration) Sets the maximum linear acceleration.voidsetMaxLinearSpeed(float maxLinearSpeed) Sets the maximum linear speed.voidsetOrientation(float orientation) Sets the orientation of this location, i.e.voidsetSteeringBehavior(com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> steeringBehavior) voidsetTagged(boolean tagged) Tag/untag this Steerable.voidsetZeroLinearSpeedThreshold(float value) Sets the threshold below which the linear speed can be considered zero.voidupdate(float deltaTime) floatvectorToAngle(com.badlogic.gdx.math.Vector2 vector) Returns the angle in radians pointing along the specified vector.
-
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.LocationReturns the vector indicating the position of this location.- Specified by:
getPositionin interfacecom.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
-
getOrientation
public float getOrientation()Description copied from interface:com.badlogic.gdx.ai.utils.LocationReturns 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:
getOrientationin interfacecom.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.LocationSets the orientation of this location, i.e. the angle in radians representing the direction that this location is facing.- Specified by:
setOrientationin interfacecom.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.SteerableReturns the vector indicating the linear velocity of this Steerable.- Specified by:
getLinearVelocityin interfacecom.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
-
getAngularVelocity
public float getAngularVelocity()Description copied from interface:com.badlogic.gdx.ai.steer.SteerableReturns the float value indicating the the angular velocity in radians of this Steerable.- Specified by:
getAngularVelocityin interfacecom.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
-
getBoundingRadius
public float getBoundingRadius()Description copied from interface:com.badlogic.gdx.ai.steer.SteerableReturns the bounding radius of this Steerable.- Specified by:
getBoundingRadiusin interfacecom.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
-
isTagged
public boolean isTagged()Description copied from interface:com.badlogic.gdx.ai.steer.SteerableReturnstrueif this Steerable is tagged;falseotherwise.- Specified by:
isTaggedin interfacecom.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.SteerableTag/untag this Steerable. This is a generic flag utilized in a variety of ways.- Specified by:
setTaggedin interfacecom.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.LocationCreates 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:
newLocationin interfacecom.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.LocationReturns the angle in radians pointing along the specified vector.- Specified by:
vectorToAnglein interfacecom.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.LocationReturns the unit vector in the direction of the specified angle expressed in radians.- Specified by:
angleToVectorin interfacecom.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.LimiterReturns the maximum linear speed.- Specified by:
getMaxLinearSpeedin interfacecom.badlogic.gdx.ai.steer.Limiter
-
setMaxLinearSpeed
public void setMaxLinearSpeed(float maxLinearSpeed) Description copied from interface:com.badlogic.gdx.ai.steer.LimiterSets the maximum linear speed.- Specified by:
setMaxLinearSpeedin interfacecom.badlogic.gdx.ai.steer.Limiter
-
getMaxLinearAcceleration
public float getMaxLinearAcceleration()Description copied from interface:com.badlogic.gdx.ai.steer.LimiterReturns the maximum linear acceleration.- Specified by:
getMaxLinearAccelerationin interfacecom.badlogic.gdx.ai.steer.Limiter
-
setMaxLinearAcceleration
public void setMaxLinearAcceleration(float maxLinearAcceleration) Description copied from interface:com.badlogic.gdx.ai.steer.LimiterSets the maximum linear acceleration.- Specified by:
setMaxLinearAccelerationin interfacecom.badlogic.gdx.ai.steer.Limiter
-
getMaxAngularSpeed
public float getMaxAngularSpeed()Description copied from interface:com.badlogic.gdx.ai.steer.LimiterReturns the maximum angular speed.- Specified by:
getMaxAngularSpeedin interfacecom.badlogic.gdx.ai.steer.Limiter
-
setMaxAngularSpeed
public void setMaxAngularSpeed(float maxAngularSpeed) Description copied from interface:com.badlogic.gdx.ai.steer.LimiterSets the maximum angular speed.- Specified by:
setMaxAngularSpeedin interfacecom.badlogic.gdx.ai.steer.Limiter
-
getMaxAngularAcceleration
public float getMaxAngularAcceleration()Description copied from interface:com.badlogic.gdx.ai.steer.LimiterReturns the maximum angular acceleration.- Specified by:
getMaxAngularAccelerationin interfacecom.badlogic.gdx.ai.steer.Limiter
-
setMaxAngularAcceleration
public void setMaxAngularAcceleration(float maxAngularAcceleration) Description copied from interface:com.badlogic.gdx.ai.steer.LimiterSets the maximum angular acceleration.- Specified by:
setMaxAngularAccelerationin interfacecom.badlogic.gdx.ai.steer.Limiter
-
getZeroLinearSpeedThreshold
public float getZeroLinearSpeedThreshold()Description copied from interface:com.badlogic.gdx.ai.steer.LimiterReturns 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:
getZeroLinearSpeedThresholdin interfacecom.badlogic.gdx.ai.steer.Limiter
-
setZeroLinearSpeedThreshold
public void setZeroLinearSpeedThreshold(float value) Description copied from interface:com.badlogic.gdx.ai.steer.LimiterSets 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:
setZeroLinearSpeedThresholdin interfacecom.badlogic.gdx.ai.steer.Limiter
-