Esempio n. 1
0
    void GetMesh()
    {
        Mesh mesh = previewMesh.meshFilter.sharedMesh;

        mesh = mesh == null ? new Mesh() : mesh;
        ChunkMesh chunkMesh = new ChunkMesh(vertexResolution, chunkSize, ref mesh);

        chunkMesh.SetNoise(noiseSettings, noiseOffset);
        if (useMarchingCubes)
        {
            noiseMap.SetOffset(noiseOffset);
            switch (previewMode)
            {
            case PreviewMode.Noise:
                chunkMesh.GenerateNoiseMesh(noiseOffset, chunkOffset);
                break;

            case PreviewMode.TransvoxelNoise:
                chunkMesh.GenerateNoiseTranxvoxelMesh(noiseOffset, chunkOffset);
                break;

            case PreviewMode.Sphere:
                chunkMesh.GenerateSphereMesh(diameter / 2, chunkOffset);
                break;

            default:
                break;
            }
        }
        else
        {
            chunkMesh.SetNoise(useNoise ? noiseSettings : NoiseMod.flat, noiseOffset);
            chunkMesh.useNoise = useNoise;
            chunkMesh.GenerateSquareMesh(chunkOffset);
            noiseMap = chunkMesh.noiseMap;
        }
    }