T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class Interpose<T extends com.badlogic.gdx.math.Vector<T>> extends Arrive<T>
Interpose behavior produces a steering force that moves the owner to a point along the imaginary line connecting two
other agents. A bodyguard taking a bullet for his employer or a soccer player intercepting a pass are examples of this type of
behavior. Like Pursue, the owner must estimate where the two agents are going to be located at a time t in the
future. It can then steer toward that position using the Arrive behavior. But how do we know what the best value of
t is to use? The answer is, we don't, so we make a calculated guess instead.
The first step is to determine a point along the imaginary line connecting the positions of the agents at the current time
step. This point is found taking into account the interpositionRatio, a number between 0 and 1 where 0 is the position
of the first agent (agentA) and 1 is the position of the second agent (agentB). Values in between are interpolated intermediate
locations.
Then the distance from this point is computed and the value divided by the owner's maximum speed to give the time t
required to travel the distance.
Using the time t, the agents' positions are extrapolated into the future. The target position in between of these
predicted positions is determined and finally the owner uses the Arrive behavior to steer toward that point.
| Modifier and Type | Field and Description |
|---|---|
protected Steerable<T> |
agentA |
protected Steerable<T> |
agentB |
protected float |
interpositionRatio |
arrivalTolerance, decelerationRadius, target, timeToTargetenabled, limiter, owner| Constructor and Description |
|---|
Interpose(Steerable<T> owner,
Steerable<T> agentA,
Steerable<T> agentB)
Creates an
Interpose behavior for the specified owner and agents using the midpoint between agents as the target. |
Interpose(Steerable<T> owner,
Steerable<T> agentA,
Steerable<T> agentB,
float interpositionRatio)
Creates an
Interpose behavior for the specified owner and agents using the the given interposing ratio. |
| Modifier and Type | Method and Description |
|---|---|
protected SteeringAcceleration<T> |
calculateRealSteering(SteeringAcceleration<T> steering)
Calculates the steering acceleration produced by this behavior and writes it to the given steering output.
|
Steerable<T> |
getAgentA()
Returns the first agent.
|
Steerable<T> |
getAgentB()
Returns the second agent.
|
T |
getInternalTargetPosition()
Returns the current position of the internal target.
|
float |
getInterpositionRatio()
Returns the interposition ratio.
|
Interpose<T> |
setAgentA(Steerable<T> agentA)
Sets the first agent.
|
Interpose<T> |
setAgentB(Steerable<T> agentB)
Sets the second agent.
|
Interpose<T> |
setArrivalTolerance(float arrivalTolerance)
Sets the tolerance for arriving at the target.
|
Interpose<T> |
setDecelerationRadius(float decelerationRadius)
Sets the radius for beginning to slow down.
|
Interpose<T> |
setEnabled(boolean enabled)
Sets this steering behavior on/off.
|
Interpose<T> |
setInterpositionRatio(float interpositionRatio)
Sets the interposition ratio.
|
Interpose<T> |
setLimiter(Limiter limiter)
Sets the limiter of this steering behavior.
|
Interpose<T> |
setOwner(Steerable<T> owner)
Sets the owner of this steering behavior.
|
Interpose<T> |
setTarget(Location<T> target)
Sets the target to arrive to.
|
Interpose<T> |
setTimeToTarget(float timeToTarget)
Sets the time over which to achieve target speed.
|
arrive, getArrivalTolerance, getDecelerationRadius, getTarget, getTimeToTargetcalculateSteering, getActualLimiter, getLimiter, getOwner, isEnabled, newVectorpublic Interpose(Steerable<T> owner, Steerable<T> agentA, Steerable<T> agentB)
Interpose behavior for the specified owner and agents using the midpoint between agents as the target.owner - the owner of this behavioragentA - the first agentagentB - the other agentpublic Interpose(Steerable<T> owner, Steerable<T> agentA, Steerable<T> agentB, float interpositionRatio)
Interpose behavior for the specified owner and agents using the the given interposing ratio.owner - the owner of this behavioragentA - the first agentagentB - the other agentinterpositionRatio - a number between 0 and 1 indicating the percentage of the distance between the 2 agents that the
owner should reach, where 0 is agentA position and 1 is agentB position.public Interpose<T> setAgentA(Steerable<T> agentA)
public Interpose<T> setAgentB(Steerable<T> agentB)
public float getInterpositionRatio()
public Interpose<T> setInterpositionRatio(float interpositionRatio)
interpositionRatio - a number between 0 and 1 indicating the percentage of the distance between the 2 agents that the
owner should reach. Especially, 0 is the position of agentA and 1 is the position of agentB.protected SteeringAcceleration<T> calculateRealSteering(SteeringAcceleration<T> steering)
SteeringBehavior
This method is called by SteeringBehavior.calculateSteering(SteeringAcceleration) when this steering behavior is enabled.
calculateRealSteering in class Arrive<T extends com.badlogic.gdx.math.Vector<T>>steering - the steering acceleration to be calculated.public T getInternalTargetPosition()
public Interpose<T> setOwner(Steerable<T> owner)
SteeringBehaviorpublic Interpose<T> setEnabled(boolean enabled)
SteeringBehaviorsetEnabled in class Arrive<T extends com.badlogic.gdx.math.Vector<T>>public Interpose<T> setLimiter(Limiter limiter)
ArrivesetLimiter in class Arrive<T extends com.badlogic.gdx.math.Vector<T>>public Interpose<T> setTarget(Location<T> target)
Arrivepublic Interpose<T> setArrivalTolerance(float arrivalTolerance)
ArrivesetArrivalTolerance in class Arrive<T extends com.badlogic.gdx.math.Vector<T>>public Interpose<T> setDecelerationRadius(float decelerationRadius)
ArrivesetDecelerationRadius in class Arrive<T extends com.badlogic.gdx.math.Vector<T>>