コード例 #1
0
 // Use this for initialization
 void Start()
 {
     System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
     watch.Start();
     itm = NavMeshBuilder.BuildTerrainNavmesh(GameObject.FindObjectOfType <Terrain>());
     Debug.Log("Terrain built in " + watch.Elapsed);
     watch.Reset(); watch.Start();
     StartCoroutine(itm.OptimizeMesh());
     StartCoroutine(Draw());
 }
コード例 #2
0
    public void TestOptimize()
    {
        IndexedTriangleMesh itm = new IndexedTriangleMesh();

        Vector3[] vectors = new Vector3[] { new Vector3(1, 0, 1), new Vector3(1, 0, -1), new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), new Vector3(0, 0, 0) };
        IndexedTriangleMesh.Triangle[] trg = new IndexedTriangleMesh.Triangle[] { new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[0], vectors[1], vectors[4] }),
                                                                                  new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[1], vectors[2], vectors[4] }),
                                                                                  new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[2], vectors[3], vectors[4] }),
                                                                                  new IndexedTriangleMesh.Triangle(new Vector3[] { vectors[3], vectors[0], vectors[4] }) };

        foreach (IndexedTriangleMesh.Triangle trig in trg)
        {
            itm.AddTriangleByReference(trig);
        }
        //Act
        itm.OptimizeMesh();

        //Assert
        //The object has a new name
        Mesh testM = itm.ExtractMeshes().First();

        NUnit.Framework.Assert.AreEqual(4, testM.vertexCount, "Mesh was not optimized");
    }