public class FourWayGridMesh extends java.lang.Object implements NavigationMesh
| Constructor and Description |
|---|
FourWayGridMesh(LineMap map,
float gridSpace,
float clearance)
Instantiates a grid mesh of nodes which won't interconnect between any map geometry.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addNode(Node node,
int neighbors)
Adds a node to this set and connects it with a number of neighboring nodes.
|
boolean |
connect(Node node1,
Node node2)
Attempts to connect two nodes together by adding them as neighbors.
|
boolean |
disconnect(Node node1,
Node node2)
Disconnects two nodes by removing them as neighbors.
|
java.util.Collection<Node> |
getMesh()
Returns a collection of all nodes within this navigation mesh.
|
void |
regenerate()
Throws away the previous set of nodes and recalculates them all.
|
boolean |
removeNode(Node node)
Removes a node from the set and removes any existing connections with its neighbors.
|
void |
setClearance(float clearance)
Changes the safety zone between all nodes/connections and map geometry.
|
void |
setGridSpacing(float gridSpace)
Change the size of each grid square.
|
void |
setMap(LineMap map)
Feeds this class a new map.
|
public FourWayGridMesh(LineMap map, float gridSpace, float clearance)
map - The map containing geometry.gridSpace - The size of each grid square.clearance - The safety zone between all nodes/connections and the map geometry.public java.util.Collection<Node> getMesh()
NavigationMeshgetMesh in interface NavigationMeshpublic void setGridSpacing(float gridSpace)
gridSpace - The unit size of each grid square.public void setClearance(float clearance)
clearance - The safety clearance between nodes/connections and map geometry.public void setMap(LineMap map)
map - The new map data.public void regenerate()
NavigationMeshregenerate in interface NavigationMeshpublic boolean connect(Node node1, Node node2)
NavigationMeshconnect in interface NavigationMeshpublic boolean disconnect(Node node1, Node node2)
NavigationMeshdisconnect in interface NavigationMeshpublic int addNode(Node node, int neighbors)
addNode in interface NavigationMeshnode - The unconnected node to add to this mesh. Will be connected with others in the set.neighbors - The maximum number of neighbors to attempt to connect with.public boolean removeNode(Node node)
NavigationMeshremoveNode in interface NavigationMeshnode - The node to remove.