예제 #1
0
        public GpGraph(GpNavMesh gpNavMesh)
        {
            Nodes = new List <GpNode>();

            var tris = gpNavMesh.GetConnectedTriangles();

            // Create our initial list of nodes
            for (var i = 0; i < tris.Count; i++)
            {
                var node = new GpNode(i, gpNavMesh.Triangles[i].Centroid());

                Nodes.Add(node);
            }

            // Now go add all neighbors
            for (var i = 0; i < tris.Count; i++)
            {
                foreach (var nodeId in tris[i])
                {
                    var neighborNode = Nodes[nodeId];
                    Nodes[i].AddNeighbor(neighborNode);
                }
            }
        }
예제 #2
0
 public void SetParentNode(GpNode node)
 {
     ParentNode = node;
 }
예제 #3
0
 public void AddNeighbor(GpNode node)
 {
     Neighbors.Add(node);
 }