Exemple #1
0
    public static void CreateMeshData(float[,,] map, NativeList <int3> usedIndices, float scaleFactor, ref Mesh mesh)
    {
        if (!MarchingCubeTables.IsInitialized)
        {
            MarchingCubeTables.Initialize();
        }


        Profiler.BeginSample("MarchingCube");

        triangles.Clear();
        vertices.Clear();

        for (int i = 0; i < usedIndices.Length; i++)
        {
            MarchCube(usedIndices[i], map, scaleFactor, triangles, vertices);
        }

        mesh.Clear();
        mesh.SetVertices(vertices);
        mesh.SetTriangles(triangles, 0);

        //might want to calculate the normal on the spot
        mesh.RecalculateNormals();
        Profiler.EndSample();
    }
Exemple #2
0
 private void OnDestroy()
 {
     MarchingCubeTables.Dispose();
 }
Exemple #3
0
 private void Start()
 {
     mesh = new Mesh();
     MarchingCubeTables.Initialize();
 }