T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class FieldOfViewProximity<T extends com.badlogic.gdx.math.Vector<T>> extends ProximityBase<T>
FieldOfViewProximity emulates the peripheral vision of the owner as if it had eyes. Any agents contained in the
specified list that are within the field of view of the owner are considered owner's neighbors. The field of view is determined
by a radius and an angle in degrees.
Note that this implementation checks the AI time of the current frame through the GdxAI.getTimepiece().getTime() method in order to calculate neighbors only once per frame (assuming delta time is always
greater than 0, if time has changed the frame has changed too). This means that
update the timepiece on each frame the proximity instance will be
calculated only the very first time, which is not what you want of course.Proximity.findNeighbors(ProximityCallback)
method.Proximity.ProximityCallback<T extends com.badlogic.gdx.math.Vector<T>>| Modifier and Type | Field and Description |
|---|---|
protected float |
angle
The angle in radians of this proximity.
|
protected float |
radius
The radius of this proximity.
|
agents, owner| Constructor and Description |
|---|
FieldOfViewProximity(Steerable<T> owner,
java.lang.Iterable<? extends Steerable<T>> agents,
float radius,
float angle)
Creates a
FieldOfViewProximity for the specified owner, agents and cone area defined by the given radius and angle
in radians. |
| Modifier and Type | Method and Description |
|---|---|
int |
findNeighbors(Proximity.ProximityCallback<T> callback)
Finds the agents that are within the immediate area of the owner.
|
float |
getAngle()
Returns the angle of this proximity in radians.
|
float |
getRadius()
Returns the radius of this proximity.
|
void |
setAngle(float angle)
Sets the angle of this proximity in radians.
|
void |
setRadius(float radius)
Sets the radius of this proximity.
|
getAgents, getOwner, setAgents, setOwnerprotected float radius
protected float angle
public FieldOfViewProximity(Steerable<T> owner, java.lang.Iterable<? extends Steerable<T>> agents, float radius, float angle)
FieldOfViewProximity for the specified owner, agents and cone area defined by the given radius and angle
in radians.owner - the owner of this proximityagents - the agentsradius - the radius of the cone areaangle - the angle in radians of the cone areapublic float getRadius()
public void setRadius(float radius)
public float getAngle()
public void setAngle(float angle)
public int findNeighbors(Proximity.ProximityCallback<T> callback)
ProximityreportNeighbor method of the specified callback.