Example #1
0
        private static bool[,] Convert(HeightmapLayer layer, float waterline)
        {
            var result = new bool[layer.SizeX, layer.SizeY];

            foreach (var cell in layer)
            {
                result[cell.X, cell.Y] = cell.Data < waterline;
            }

            return(result);
        }
Example #2
0
        public static float[,] NormalizeHeights(HeightmapLayer layer)
        {
            var result = new float[layer.SizeX, layer.SizeY];

            for (var x = 0; x < layer.SizeX; x++)
            {
                for (var y = 0; y < layer.SizeY; y++)
                {
                    result[x, y] = (layer.GetCell(x, y) - layer.MinHeight) / layer.OverallHeight;
                }
            }
            return(result);
        }
Example #3
0
 public static float GetWaterlineFromPercentage(HeightmapLayer layer, float hPercent)
 {
     return((layer.MaxHeight - layer.MinHeight) * hPercent + layer.MinHeight);
 }
Example #4
0
 public WaterLayer(HeightmapLayer layer, float waterline)
     : base(Convert(layer, waterline))
 {
     Waterline = waterline;
 }