A* Pathfinding Project  4.0.1
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
NavMeshGraph Class Reference

Generates graphs based on navmeshes. More...

Detailed Description

Generates graphs based on navmeshes.

Navmeshes are meshes where each triangle defines a walkable area. These are great because the AI can get so much more information on how it can walk. Polygons instead of points mean that the funnel smoother can produce really nice looking paths and the graphs are also really fast to search and have a low memory footprint because fewer nodes are usually needed to describe the same area compared to grid graphs.

See Also
Pathfinding.RecastGraph

Public Member Functions

override GraphTransform CalculateTransform ()
 Returns a new transform which transforms graph space to world space.
 
GraphUpdateThreading CanUpdateAsync (GraphUpdateObject o)
 
override void DeserializeSettingsCompatibility (GraphSerializationContext ctx)
 An old format for serializing settings.
 
void ScanInternal (string objMeshPath)
 Scans the graph using the path to an .obj mesh.
 
override IEnumerable< ProgressScanInternal ()
 Internal method to scan the graph.
 
void UpdateArea (GraphUpdateObject o)
 
void UpdateAreaInit (GraphUpdateObject o)
 
void UpdateAreaPost (GraphUpdateObject o)
 
- Public Member Functions inherited from NavmeshBase
override void DeserializeExtraInfo (GraphSerializationContext ctx)
 Deserializes graph type specific node data.
 
void EndBatchTileUpdate ()
 End batch updating of tiles.
 
override NNInfoInternal GetNearest (Vector3 position, NNConstraint constraint, GraphNode hint)
 Returns the nearest node to a position using the specified NNConstraint.
 
override NNInfoInternal GetNearestForce (Vector3 position, NNConstraint constraint)
 Returns the nearest node to a position using the specified constraint .
 
override void GetNodes (System.Action< GraphNode > action)
 Calls a delegate with all nodes in the graph.
 
NavmeshTile GetTile (int x, int z)
 Tile at the specified x, z coordinate pair.
 
Bounds GetTileBounds (IntRect rect)
 Returns an XZ bounds object with the bounds of a group of tiles.
 
Bounds GetTileBounds (int x, int z, int width=1, int depth=1)
 Returns an XZ bounds object with the bounds of a group of tiles.
 
Bounds GetTileBoundsInGraphSpace (IntRect rect)
 
Bounds GetTileBoundsInGraphSpace (int x, int z, int width=1, int depth=1)
 Returns an XZ bounds object with the bounds of a group of tiles in graph space.
 
void GetTileCoordinates (int tileIndex, out int x, out int z)
 Tile coordinates from a tile index.
 
Int2 GetTileCoordinates (Vector3 p)
 Returns the tile coordinate which contains the point p.
 
NavmeshTile[] GetTiles ()
 All tiles.
 
IntRect GetTouchingTiles (Bounds bounds)
 Returns a rect containing the indices of all tiles touching the specified bounds.
 
IntRect GetTouchingTilesInGraphSpace (Rect rect)
 Returns a rect containing the indices of all tiles touching the specified bounds.
 
IntRect GetTouchingTilesRound (Bounds bounds)
 Returns a rect containing the indices of all tiles by rounding the specified bounds to tile borders.
 
Int3 GetVertex (int index)
 Vertex coordinate for the specified vertex index.
 
int GetVertexArrayIndex (int index)
 
Int3 GetVertexInGraphSpace (int index)
 Vertex coordinate in graph space for the specified vertex index.
 
bool Linecast (Vector3 origin, Vector3 end)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit, List< GraphNode > trace)
 Returns if there is an obstacle between origin and end on the graph.
 
override void OnDestroy ()
 Function for cleaning up references.
 
override void OnDrawGizmos (Pathfinding.Util.RetainedGizmos gizmos, bool drawNodes)
 
GraphNode PointOnNavmesh (Vector3 position, NNConstraint constraint)
 Finds the first node which contains position.
 
override void PostDeserialization ()
 Called after all deserialization has been done for all graphs.
 
override void RelocateNodes (Matrix4x4 deltaMatrix)
 Moves the nodes in this graph.
 
void RelocateNodes (GraphTransform newTransform)
 Moves the nodes in this graph.
 
void ReplaceTile (int x, int z, Int3[] verts, int[] tris)
 Replace tile at index with nodes created from specified navmesh.
 
void ReplaceTile (int x, int z, int w, int d, Int3[] verts, int[] tris)
 Replaces a tile with a new mesh.
 
override void SerializeExtraInfo (GraphSerializationContext ctx)
 Serializes Node Info.
 
void StartBatchTileUpdate ()
 Start batch updating of tiles.
 
- Public Member Functions inherited from NavGraph
virtual int CountNodes ()
 Number of nodes in the graph.
 
NNInfoInternal GetNearest (Vector3 position)
 Returns the nearest node to a position using the default NNConstraint.
 
NNInfoInternal GetNearest (Vector3 position, NNConstraint constraint)
 Returns the nearest node to a position using the specified NNConstraint.
 
void GetNodes (System.Func< GraphNode, bool > action)
 Calls a delegate with all nodes in the graph until the delegate returns false.
 
virtual void OnDrawGizmos (RetainedGizmos gizmos, bool drawNodes)
 Draw gizmos for the graph.
 
void RelocateNodes (Matrix4x4 oldMatrix, Matrix4x4 newMatrix)
 Moves nodes in this graph.
 
void Scan ()
 
void ScanGraph ()
 Partially scan the graph.
 
void SetMatrix (Matrix4x4 m)
 Use to set both matrix and inverseMatrix at the same time.
 
- Public Member Functions inherited from INavmesh
void GetNodes (System.Action< GraphNode > del)
 
- Public Member Functions inherited from INavmeshHolder
void GetTileCoordinates (int tileIndex, out int x, out int z)
 
Int3 GetVertex (int i)
 
int GetVertexArrayIndex (int index)
 
Int3 GetVertexInGraphSpace (int i)
 
- Public Member Functions inherited from IRaycastableGraph
bool Linecast (Vector3 start, Vector3 end)
 
bool Linecast (Vector3 start, Vector3 end, GraphNode hint)
 
bool Linecast (Vector3 start, Vector3 end, GraphNode hint, out GraphHitInfo hit)
 
bool Linecast (Vector3 start, Vector3 end, GraphNode hint, out GraphHitInfo hit, List< GraphNode > trace)
 
- Public Member Functions inherited from IUpdatableGraph
GraphUpdateThreading CanUpdateAsync (GraphUpdateObject o)
 
void UpdateArea (GraphUpdateObject o)
 Updates an area using the specified GraphUpdateObject.
 
void UpdateAreaInit (GraphUpdateObject o)
 May be called on the Unity thread before starting the update.
 
void UpdateAreaPost (GraphUpdateObject o)
 May be called on the Unity thread after executing the update.
 

Static Public Member Functions

static void UpdateArea (GraphUpdateObject o, INavmesh graph)
 
- Static Public Member Functions inherited from NavmeshBase
static int GetTileIndex (int index)
 Tile index from a vertex index.
 
static bool Linecast (INavmesh graph, Vector3 tmp_origin, Vector3 tmp_end, GraphNode hint, out GraphHitInfo hit)
 Returns if there is an obstacle between origin and end on the graph.
 
static bool Linecast (INavmesh graph, Vector3 tmp_origin, Vector3 tmp_end, GraphNode hint, out GraphHitInfo hit, List< GraphNode > trace)
 Returns if there is an obstacle between origin and end on the graph.
 

Public Attributes

Vector3 offset
 Offset in world space.
 
Vector3 rotation
 Rotation in degrees.
 
float scale = 1
 Scale of the graph.
 
Mesh sourceMesh
 Mesh to construct navmesh from.
 
- Public Attributes inherited from NavmeshBase
Vector3 forcedBoundsSize = new Vector3(100, 40, 100)
 Size of the bounding box.
 
bool nearestSearchOnlyXZ
 Perform nearest node searches in XZ space only.
 
System.Action< NavmeshTile[]> OnRecalculatedTiles
 Called when tiles have been completely recalculated.
 
bool showMeshOutline = true
 Show an outline of the polygons in the Unity Editor.
 
bool showMeshSurface
 Show the surface of the navmesh.
 
bool showNodeConnections
 Show the connections between the polygons in the Unity Editor.
 
const int TileIndexMask = 0x7FFFF
 
const int TileIndexOffset = 12
 
int tileXCount
 Number of tiles along the X-axis.
 
int tileZCount
 Number of tiles along the Z-axis.
 
GraphTransform transform = new GraphTransform(Matrix4x4.identity)
 Determines how the graph transforms graph space to world space.
 
const int VertexIndexMask = 0xFFF
 
- Public Attributes inherited from NavGraph
AstarPath active
 Reference to the AstarPath object in the scene.
 
bool drawGizmos = true
 Enable to draw gizmos in the Unity scene view.
 
uint graphIndex
 Index of the graph, used for identification purposes.
 
Guid guid
 Used as an ID of the graph, considered to be unique.
 
bool infoScreenOpen
 Used in the editor to check if the info screen is open.
 
uint initialPenalty
 Default penalty to apply to all nodes.
 
Matrix4x4 inverseMatrix = Matrix4x4.identity
 Inverse of matrix.
 
Matrix4x4 matrix = Matrix4x4.identity
 A matrix for translating/rotating/scaling the graph.
 
string name
 Name of the graph.
 
bool open
 Is the graph open in the editor.
 

Properties

override float MaxTileConnectionEdgeDistance [get]
 
override float TileWorldSizeX [get]
 
override float TileWorldSizeZ [get]
 
- Properties inherited from NavmeshBase
abstract float MaxTileConnectionEdgeDistance [get]
 Maximum (vertical) distance between the sides of two nodes for them to be connected across a tile edge.
 
abstract float TileWorldSizeX [get]
 Size of a tile in world units along the X axis.
 
abstract float TileWorldSizeZ [get]
 Size of a tile in world units along the Z axis.
 
GraphTransform ITransformedGraph. transform [get]
 
- Properties inherited from ITransformedGraph
GraphTransform transform [get]
 

Additional Inherited Members

- Protected Member Functions inherited from NavmeshBase
void ClearTiles (int x, int z, int w, int d)
 Clear all tiles within the rectangle with one corner at (x,z), width w and depth d.
 
void ConnectTiles (NavmeshTile tile1, NavmeshTile tile2)
 Generate connections between the two tiles.
 
void ConnectTileWithNeighbours (NavmeshTile tile, bool onlyUnflagged=false)
 
TriangleMeshNode[] CreateNodes (int[] tris, int tileIndex, uint graphIndex)
 
void FillWithEmptyTiles ()
 Fills graph with tiles created by NewEmptyTile.
 
void RemoveConnectionsFromTile (NavmeshTile tile)
 
void RemoveConnectionsFromTo (NavmeshTile a, NavmeshTile b)
 
- Static Protected Member Functions inherited from NavmeshBase
static void CreateNodeConnections (TriangleMeshNode[] nodes)
 Create connections between all nodes.
 
static NavmeshTile NewEmptyTile (int x, int z)
 Creates a single new empty tile.
 
- Protected Attributes inherited from NavmeshBase
NavmeshTile[] tiles
 All tiles.
 
- Package Functions inherited from NavGraph
virtual void DestroyAllNodesInternal ()
 Destroys all nodes in the graph.
 
virtual void UnloadGizmoMeshes ()
 Called when temporary meshes used in OnDrawGizmos need to be unloaded to prevent memory leaks.
 

Member Function Documentation

override GraphTransform CalculateTransform ( )
virtual

Returns a new transform which transforms graph space to world space.

Does not update the transform field.

See Also
RelocateNodes(GraphTransform)

Implements NavmeshBase.

GraphUpdateThreading CanUpdateAsync ( GraphUpdateObject  o)
override void DeserializeSettingsCompatibility ( GraphSerializationContext  ctx)
virtual

An old format for serializing settings.

Deprecated:
This is deprecated now, but the deserialization code is kept to avoid loosing data when upgrading from older versions.

Reimplemented from NavGraph.

void ScanInternal ( string  objMeshPath)

Scans the graph using the path to an .obj mesh.

override IEnumerable<Progress> ScanInternal ( )
virtual

Internal method to scan the graph.

Called from AstarPath.ScanAsync. Override this function to implement custom scanning logic. Progress objects can be yielded to show progress info in the editor and to split up processing over several frames when using async scanning.

Implements NavGraph.

void UpdateArea ( GraphUpdateObject  o)
static void UpdateArea ( GraphUpdateObject  o,
INavmesh  graph 
)
static
void UpdateAreaInit ( GraphUpdateObject  o)
void UpdateAreaPost ( GraphUpdateObject  o)

Member Data Documentation

Vector3 offset

Offset in world space.

Vector3 rotation

Rotation in degrees.

float scale = 1

Scale of the graph.

Mesh sourceMesh

Mesh to construct navmesh from.

Property Documentation

override float MaxTileConnectionEdgeDistance
getprotected
override float TileWorldSizeX
get
override float TileWorldSizeZ
get

The documentation for this class was generated from the following file: