예제 #1
0
        //AStarSystem system;

        public NavigationSystem(NormalizedNavmeshAsset asset)
        {
            indices  = asset.indices;
            vertices = asset.vertices;

            /* start of calculate edge */
            var lineCount = new Dictionary <LineIndice, int>();

            VisitTriangle((a, b, c) =>
            {
                var ab = new LineIndice(a, b);
                var bc = new LineIndice(b, c);
                var ca = new LineIndice(a, c);
                if (!lineCount.ContainsKey(ab))
                {
                    lineCount[ab] = 0;
                }
                if (!lineCount.ContainsKey(bc))
                {
                    lineCount[bc] = 0;
                }
                if (!lineCount.ContainsKey(ca))
                {
                    lineCount[ca] = 0;
                }
                lineCount[ab] += 1;
                lineCount[bc] += 1;
                lineCount[ca] += 1;
            });
            var lstEdges = new List <int>();

            foreach (var item in lineCount)
            {
                if (item.Value == 1)//is edge
                {
                    lstEdges.Add(item.Key.ia);
                    lstEdges.Add(item.Key.ib);
                }
            }
            /* end of calculate edge */

            edges = lstEdges.ToArray();
            nodes = CreateAStarNodes();
            //system = new AStarSystem(nodes);
        }
예제 #2
0
 private void OnValidate()
 {
     navMesh = NormalizedNavmeshAsset.GetInstanceOfCurrentScene();
 }