public void GetTileGeometry(AiNativeList <float3> vertices, AiNativeList <int> indices) { AiNativeList <float3> tileVerts = new AiNativeList <float3>(2); AiNativeList <int> tileIndices = new AiNativeList <int>(2); foreach (byte[] data in Tiles) { NavMeshTile tile = new NavMeshTile(); tile.Data = data; tile.GetTileVertices(tileVerts, tileIndices); // Copy vertices int vbase = vertices.Length; for (int i = 0; i < tileVerts.Length; i++) { vertices.Add(tileVerts[i]); } // Copy indices with offset applied for (int i = 0; i < tileIndices.Length; i++) { indices.Add(tileIndices[i] + vbase); } tileVerts.Clear(); tileIndices.Clear(); } tileVerts.Dispose(); tileIndices.Dispose(); }
public Mesh ToMesh() { AiNativeList <float3> vertices = new AiNativeList <float3>(2); AiNativeList <int> indices = new AiNativeList <int>(2); GetTileGeometry(vertices, indices); Vector3[] unityVerts = new Vector3[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { unityVerts[i] = new Vector3(vertices[i].x, vertices[i].y, vertices[i].z); } Mesh mesh = new Mesh(); mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; mesh.vertices = unityVerts; mesh.uv = new Vector2[unityVerts.Length]; mesh.triangles = indices.ToArray(); mesh.RecalculateBounds(); mesh.RecalculateNormals(); vertices.Dispose(); indices.Dispose(); return(mesh); }
public void Dispose() { Vertices.Dispose(); Indices.Dispose(); Areas.Dispose(); }