예제 #1
0
        public static float[,] GenerateHeightMapLookup(int width, int height)
        {
            float[,] toReturn = new float[width, height];

            const float mountainWidth  = 0.04f;
            const float continentSize  = 0.03f;
            const float hillSize       = 0.1f;
            const float smallNoiseSize = 0.15f;
            const float cliffHeight    = 0.1f;
            const float invCliffHeight = 1.0f / cliffHeight;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float mountain   = (float)Math.Pow(OverworldImageOperations.noise(heightNoise, x, y, 0, mountainWidth), 1);
                    float continent  = OverworldImageOperations.noise(heightNoise, x, y, 10, continentSize);
                    float hill       = OverworldImageOperations.noise(heightNoise, x, y, 20, hillSize) * 0.02f;
                    float smallnoise = OverworldImageOperations.noise(heightNoise, x, y, 100, smallNoiseSize) * 0.01f;
                    float cliffs     = OverworldImageOperations.noise(heightNoise, x, y, 200, continentSize) + 0.5f;
                    float h          = OverworldImageOperations.pow(OverworldImageOperations.clamp((continent * mountain) + hill, 0, 1), 1);
                    h += smallnoise;
                    h += 0.4f;
                    h  = ((int)(h * invCliffHeight)) * cliffHeight;
                    toReturn[x, y] = h;
                }
            }

            return(toReturn);
        }
예제 #2
0
 public void CreateHeightFromLookup(float[,] lookup)
 {
     for (int x = 0; x < Map.GetLength(0); x++)
     {
         for (int y = 0; y < Map.GetLength(1); y++)
         {
             Map[x, y].Height = OverworldImageOperations.clamp(lookup[x, y], 0, 1);
         }
     }
 }
예제 #3
0
 public void CreateHeightFromLookupWithErosion(float[,] lookup)
 {
     for (int x = 0; x < Map.GetLength(0); x++)
     {
         for (int y = 0; y < Map.GetLength(1); y++)
         {
             float   h   = lookup[x, y];
             Vector2 vec = new Vector2(x, y);
             h *= LinearInterpolate(vec, OverworldField.Faults);
             h += LinearInterpolate(vec, OverworldField.Weathering);
             h *= LinearInterpolate(vec, OverworldField.Erosion);
             Map[x, y].Height = OverworldImageOperations.clamp(h, 0, 1);
         }
     }
 }