private void Generate()
    {
        isosurface.SurfaceLevel = surfaceLevel;
        IsosurfaceMeshResult isosurfaceMesh = isosurface.Generate(voxels, size);

        meshInstance.FromSurfaceResult(isosurfaceMesh);
    }
示例#2
0
    public void FromSurfaceResult(IsosurfaceMeshResult surfaceResult)
    {
        MeshFilter.sharedMesh = new Mesh();
        Mesh.SetVertices(surfaceResult.Vertices);
        Mesh.SetTriangles(surfaceResult.Indices, 0);

        if (surfaceResult.Normals != null && surfaceResult.Normals.Count > 0)
        {
            Mesh.SetNormals(surfaceResult.Normals);
        }
        else
        {
            Mesh.RecalculateNormals();
        }

        Mesh.RecalculateBounds();
    }