T
- Type of vector, either 2D or 3D, implementing the Vector
interfaceP
- Type of path parameter implementing the Path.PathParam
interfacepublic interface Path<T extends com.badlogic.gdx.math.Vector<T>,P extends Path.PathParam>
Path
for an agent having path following behavior. A path can be shared by multiple path following behaviors because
its status is maintained in a Path.PathParam
local to each behavior.
The most common type of path is made up of straight line segments, which usually gives reasonably good results while keeping the math simple. However, some driving games use splines to get smoother curved paths, which makes the math more complex.
Modifier and Type | Interface and Description |
---|---|
static interface |
Path.PathParam
A path parameter used by path following behaviors to keep the path status.
|
Modifier and Type | Method and Description |
---|---|
float |
calculateDistance(T position,
P param)
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.
|
void |
calculateTargetPosition(T out,
P param,
float targetDistance)
Calculates the target position on the path based on its distance from the start and the path parameter.
|
P |
createParam()
Returns a new instance of the path parameter.
|
T |
getEndPoint()
Returns the last point of this path.
|
float |
getLength()
Returns the length of this path.
|
T |
getStartPoint()
Returns the first point of this path.
|
boolean |
isOpen()
Returns
true if this path is open; false otherwise. |
P createParam()
boolean isOpen()
true
if this path is open; false
otherwise.float getLength()
T getStartPoint()
T getEndPoint()
float calculateDistance(T position, P param)
position
- a location in game spaceparam
- the path parametervoid calculateTargetPosition(T out, P param, float targetDistance)
out
- the target position to calculateparam
- the path parametertargetDistance
- the distance of the target position from the start of the path