Example #1
0
        private void GenerateTerrain(MathUtils.NoiseFunction noise, float frequency, float amplitude, int octaveCount, float lacunarity, float gain, float offsetX, float offsetZ, float continentsFreq, AnimationCurve continentToAmpCurve)
        {
            Vector3[] verts = prepMesh.vertices;
            for (int vertIndex = 0; vertIndex < verts.Length; vertIndex++)
            {
                float mountainess = Mathf.PerlinNoise((verts[vertIndex].x + cachedPos.x) * continentsFreq + offsetX, (verts[vertIndex].z + cachedPos.z) * continentsFreq + offsetZ);
                float ampModifier = continentToAmpCurve.Evaluate(mountainess);
                verts[vertIndex].y = noise((verts[vertIndex].x + cachedPos.x) * frequency + offsetX, (verts[vertIndex].z + cachedPos.z) * frequency + offsetZ, octaveCount, lacunarity, gain) * amplitude * ampModifier;
            }

            prepMesh.vertices = verts;
            prepMesh.RecalculateNormals();
            prepMesh.RecalculateBounds();
            MeshAltered = false;
        }
Example #2
0
        private void ResetNoiseFunc()
        {
            switch (noiseType)
            {
            case NoiseType.Perlin:
                noise = MathUtils.Perlin;
                break;

            case NoiseType.PerlinAbs:
                noise = MathUtils.PerlinAbs;
                break;

            case NoiseType.PerlinOneMinusAbs:
                noise = MathUtils.PerlinOneMinusAbs;
                break;
            }
        }