public class Autopilot
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private boolean |
adaptForceToMass
if the force used should be adapted to the body mass
|
private float |
angle
the desired angle to
destination |
static net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> |
defaultPositionAccessor
returns
Body.getPosition() |
com.badlogic.gdx.math.Vector2 |
destination
the point to move and rotate to
|
private float |
distanceScalar
the distance at which the force should be fully applied
|
private com.badlogic.gdx.math.Interpolation |
interpolation
the interpolation to apply to the force based on the
distanceScalar |
private com.badlogic.gdx.math.Vector2 |
movementForce
the force used for movement
|
private boolean |
moveRelative
if the
destination is relative to the body |
private net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> |
positionAccessor
used to determine a bodies position
|
private boolean |
rotateRelative
if the
destination is relative to the body |
private float |
rotationForce
the force used for rotation
|
private static com.badlogic.gdx.math.Vector2 |
vec2_0
for internal, temporary usage
|
private static com.badlogic.gdx.math.Vector2 |
vec2_1
for internal, temporary usage
|
| Constructor and Description |
|---|
Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
float forces)
|
Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce) |
Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce,
boolean adaptForceToMass)
The given
destination will not be used directly. |
| Modifier and Type | Method and Description |
|---|---|
static com.badlogic.gdx.math.Vector2 |
calculateForce(com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force)
calculates the force to continuously
apply to reach the given destination |
static com.badlogic.gdx.math.Vector2 |
calculateForce(com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
float distanceScalar,
com.badlogic.gdx.math.Interpolation interpolation)
calculates the force to continuously
apply to reach the given destination and interpolates it based on distance |
static float |
calculateTorque(com.badlogic.gdx.math.Vector2 target,
float rotation,
float angularVelocity,
float inertia,
float force,
float delta)
calculates the torque needed to repeatedly
apply to a body to make it rotate to a given point |
float |
getAngle() |
com.badlogic.gdx.math.Vector2 |
getDestination() |
float |
getDistanceScalar() |
com.badlogic.gdx.math.Interpolation |
getInterpolation() |
com.badlogic.gdx.math.Vector2 |
getMovementForce() |
net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> |
getPositionAccessor() |
float |
getRotationForce() |
boolean |
isAdaptForceToMass() |
boolean |
isMoveRelative() |
boolean |
isRotateRelative() |
void |
move(com.badlogic.gdx.physics.box2d.Body body,
boolean interpolate,
boolean wake)
|
void |
move(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
boolean wake)
applies the force from
calculateForce(Vector2, Vector2) |
void |
move(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
com.badlogic.gdx.math.Interpolation interpolation,
float distanceScalar,
boolean wake)
applies the force of
calculateForce(Vector2, Vector2, float, Interpolation) |
void |
navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta) |
void |
navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean wake) |
void |
navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean interpolate,
boolean wake)
|
void |
rotate(com.badlogic.gdx.physics.box2d.Body body,
float delta)
rotates the body waking it up if it sleeps |
void |
rotate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean wake)
rotates the given body |
void |
rotate(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 target,
float angle,
float force,
float delta,
boolean wake) |
void |
setAdaptForceToMass(boolean adaptForceToMass) |
void |
setAngle(float angle) |
void |
setDestination(float x,
float y) |
void |
setDestination(com.badlogic.gdx.math.Vector2 destination) |
void |
setDistanceScalar(float distanceScalar) |
void |
setForces(float movementForceX,
float movementForceY,
float rotationForce) |
void |
setForces(com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce) |
void |
setInterpolation(com.badlogic.gdx.math.Interpolation interpolation) |
void |
setMovementForce(float x,
float y) |
void |
setMovementForce(com.badlogic.gdx.math.Vector2 movementForce) |
void |
setMoveRelative(boolean moveRelative) |
void |
setPositionAccessor(net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> positionAccessor) |
void |
setRelative(boolean relative) |
void |
setRelative(boolean moveRelative,
boolean rotateRelative) |
void |
setRotateRelative(boolean rotateRelative) |
void |
setRotationForce(float rotationForce) |
private static final com.badlogic.gdx.math.Vector2 vec2_0
private static final com.badlogic.gdx.math.Vector2 vec2_1
public final com.badlogic.gdx.math.Vector2 destination
private float angle
destinationprivate boolean moveRelative
destination is relative to the bodyprivate boolean rotateRelative
destination is relative to the bodyprivate final com.badlogic.gdx.math.Vector2 movementForce
private float rotationForce
private boolean adaptForceToMass
private float distanceScalar
private com.badlogic.gdx.math.Interpolation interpolation
distanceScalarpublic static final net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> defaultPositionAccessor
Body.getPosition()private net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> positionAccessor
public Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
float forces)
Autopilot(Vector2, float, float)public Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce)
public Autopilot(com.badlogic.gdx.math.Vector2 destination,
float angle,
com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce,
boolean adaptForceToMass)
destination will not be used directly. Instead destination will be set to it.public static com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force)
apply to reach the given destinationdestination - the relative position of the destinationforce - the force to applyapply to navigate to the given destinationpublic static com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
float distanceScalar,
com.badlogic.gdx.math.Interpolation interpolation)
apply to reach the given destination and interpolates it based on distancedestination - the destination to go toforce - the force to applydistanceScalar - the distance at which the given force should be fully appliedinterpolation - the interpolation used to interpolate the given force based on the distanceScalarapply to navigate to the given destinationcalculateForce(Vector2, Vector2)public static float calculateTorque(com.badlogic.gdx.math.Vector2 target,
float rotation,
float angularVelocity,
float inertia,
float force,
float delta)
apply to a body to make it rotate to a given pointtarget - the point to rotate the body torotation - the current rotation of the bodyangularVelocity - the current angular velocity of the bodyinertia - the current rotational inertia of the bodyforce - the force to usedelta - the time that passed since the last world updatetargetpublic void move(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
boolean wake)
calculateForce(Vector2, Vector2)public void move(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 destination,
com.badlogic.gdx.math.Vector2 force,
com.badlogic.gdx.math.Interpolation interpolation,
float distanceScalar,
boolean wake)
calculateForce(Vector2, Vector2, float, Interpolation)body - the body to movedestination - the destination of the bodyforce - the force used to move the bodyinterpolation - the interpolation used to interpolate the given force based on the distanceScalardistanceScalar - the distance at which the force should be fully appliedwake - if the body should be woken up in case it is sleepingmove(Body, Vector2, Vector2, boolean),
calculateForce(Vector2, Vector2, float, Interpolation)public void move(com.badlogic.gdx.physics.box2d.Body body,
boolean interpolate,
boolean wake)
public void rotate(com.badlogic.gdx.physics.box2d.Body body,
com.badlogic.gdx.math.Vector2 target,
float angle,
float force,
float delta,
boolean wake)
wake - if the body should be woken up if its sleepingcalculateTorque(Vector2, float, float, float, float, float)public void rotate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean wake)
rotates the given bodypublic void rotate(com.badlogic.gdx.physics.box2d.Body body,
float delta)
rotates the body waking it up if it sleepspublic void navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean interpolate,
boolean wake)
public void navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta,
boolean wake)
navigate(Body, float, boolean, boolean)public void navigate(com.badlogic.gdx.physics.box2d.Body body,
float delta)
navigate(Body, float, boolean)public void setDestination(float x,
float y)
x - the x coordinate to set destination toy - the y coordinate to set destination topublic void setDestination(com.badlogic.gdx.math.Vector2 destination)
destination - the destination to set destination topublic com.badlogic.gdx.math.Vector2 getDestination()
destinationpublic float getAngle()
anglepublic void setAngle(float angle)
angle - the angle to setpublic void setRelative(boolean relative)
relative - the moveRelative and rotateRelativepublic void setRelative(boolean moveRelative,
boolean rotateRelative)
moveRelative - the moveRelativerotateRelative - the rotateRelativepublic boolean isMoveRelative()
moveRelativepublic void setMoveRelative(boolean moveRelative)
moveRelative - the moveRelative to setpublic boolean isRotateRelative()
rotateRelativepublic void setRotateRelative(boolean rotateRelative)
rotateRelative - the rotateRelative to setpublic void setForces(float movementForceX,
float movementForceY,
float rotationForce)
movementForceX - the x value of movementForcemovementForceY - the y value of movementForcerotationForce - the rotationForcepublic void setForces(com.badlogic.gdx.math.Vector2 movementForce,
float rotationForce)
movementForce - the movementForcerotationForce - the rotationForcepublic com.badlogic.gdx.math.Vector2 getMovementForce()
movementForcepublic void setMovementForce(float x,
float y)
x - the x to set movementForce toy - the y to set movementForce topublic void setMovementForce(com.badlogic.gdx.math.Vector2 movementForce)
movementForce - the movementForce to setpublic float getRotationForce()
rotationForcepublic void setRotationForce(float rotationForce)
rotationForce - the rotationForce to setpublic boolean isAdaptForceToMass()
adaptForceToMasspublic void setAdaptForceToMass(boolean adaptForceToMass)
adaptForceToMass - the adaptForceToMass to setpublic float getDistanceScalar()
distanceScalarpublic void setDistanceScalar(float distanceScalar)
distanceScalar - the distanceScalar to setpublic com.badlogic.gdx.math.Interpolation getInterpolation()
interpolationpublic void setInterpolation(com.badlogic.gdx.math.Interpolation interpolation)
interpolation - the interpolation to setpublic net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> getPositionAccessor()
positionAccessorpublic void setPositionAccessor(net.dermetfan.utils.Accessor<com.badlogic.gdx.math.Vector2,com.badlogic.gdx.physics.box2d.Body> positionAccessor)
positionAccessor - the positionAccessor to set