T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class LinePath<T extends com.badlogic.gdx.math.Vector<T>> extends java.lang.Object implements Path<T,LinePath.LinePathParam>
LinePath is a path for path following behaviors that is made up of a series of waypoints. Each waypoint is connected
to the successor with a LinePath.Segment.| Modifier and Type | Class and Description |
|---|---|
static class |
LinePath.LinePathParam
A
LinePathParam contains the status of a LinePath. |
static class |
LinePath.Segment<T extends com.badlogic.gdx.math.Vector<T>>
A
Segment connects two consecutive waypoints of a LinePath. |
Path.PathParam| Constructor and Description |
|---|
LinePath(com.badlogic.gdx.utils.Array<T> waypoints)
Creates a closed
LinePath for the specified waypoints. |
LinePath(com.badlogic.gdx.utils.Array<T> waypoints,
boolean isOpen)
Creates a
LinePath for the specified waypoints. |
| Modifier and Type | Method and Description |
|---|---|
float |
calculateDistance(T agentCurrPos,
LinePath.LinePathParam parameter)
Maps the given position to the nearest point along the path using the path parameter to ensure coherence and returns the
distance of that nearest point from the start of the path.
|
float |
calculatePointSegmentSquareDistance(T out,
T a,
T b,
T c)
Returns the square distance of the nearest point on line segment
a-b, from point c. |
void |
calculateTargetPosition(T out,
LinePath.LinePathParam param,
float targetDistance)
Calculates the target position on the path based on its distance from the start and the path parameter.
|
LinePath.LinePathParam |
createParam()
Returns a new instance of the path parameter.
|
void |
createPath(com.badlogic.gdx.utils.Array<T> waypoints)
Sets up this
Path using the given way points. |
T |
getEndPoint()
Returns the last point of this path.
|
float |
getLength()
Returns the length of this path.
|
com.badlogic.gdx.utils.Array<LinePath.Segment<T>> |
getSegments() |
T |
getStartPoint()
Returns the first point of this path.
|
boolean |
isOpen()
Returns
true if this path is open; false otherwise. |
public LinePath(com.badlogic.gdx.utils.Array<T> waypoints)
LinePath for the specified waypoints.waypoints - the points making up the pathjava.lang.IllegalArgumentException - if waypoints is null or has less than two (2) waypoints.public LinePath(com.badlogic.gdx.utils.Array<T> waypoints, boolean isOpen)
LinePath for the specified waypoints.waypoints - the points making up the pathisOpen - a flag indicating whether the path is open or notjava.lang.IllegalArgumentException - if waypoints is null or has less than two (2) waypoints.public boolean isOpen()
Pathtrue if this path is open; false otherwise.isOpen in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>public float getLength()
PathgetLength in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>public T getStartPoint()
PathgetStartPoint in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>public T getEndPoint()
PathgetEndPoint in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>public float calculatePointSegmentSquareDistance(T out, T a, T b, T c)
a-b, from point c. Also, the out
vector is assigned to the nearest point.out - the output vector that contains the nearest point on returna - the start point of the line segmentb - the end point of the line segmentc - the point to calculate the distance frompublic LinePath.LinePathParam createParam()
PathcreateParam in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>public float calculateDistance(T agentCurrPos, LinePath.LinePathParam parameter)
PathcalculateDistance in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>agentCurrPos - a location in game spaceparameter - the path parameterpublic void calculateTargetPosition(T out, LinePath.LinePathParam param, float targetDistance)
PathcalculateTargetPosition in interface Path<T extends com.badlogic.gdx.math.Vector<T>,LinePath.LinePathParam>out - the target position to calculateparam - the path parametertargetDistance - the distance of the target position from the start of the pathpublic void createPath(com.badlogic.gdx.utils.Array<T> waypoints)
Path using the given way points.waypoints - The way points of this path.java.lang.IllegalArgumentException - if waypoints is null or empty.public com.badlogic.gdx.utils.Array<LinePath.Segment<T>> getSegments()