Beispiel #1
0
 public GenerateWater(GenerateHeight heightMap)
 {
     this.HeightMap = heightMap;
     WaterHeights   = new float[CoordinateSystem.Width, CoordinateSystem.Height];
     StartingWater(20, 2);
     for (int x = 0; x < 50; x++)
     {
         IterateWater();
     }
 }
Beispiel #2
0
        private void CopyHeight(int width, int height)
        {
            GenerateHeight gh = new GenerateHeight(width + distance * 2, height + 2 * distance, false, delta, distance);

            for (int x = 0; x < HeightMap.GetLength(0); x++)
            {
                for (int y = 0; y < HeightMap.GetLength(1); y++)
                {
                    HeightMap[x, y] = gh.HeightMap[x + distance, y + distance];

                    if (x < distance)
                    {
                        float weight = (float)(x + distance) / (2 * distance);
                        HeightMap[x, y] *= weight;
                        HeightMap[x, y] += gh.HeightMap[x + distance + HeightMap.GetLength(0), y + distance] * (1 - weight);
                    }

                    if (x > HeightMap.GetLength(0) - distance)
                    {
                        float weight = (float)(HeightMap.GetLength(0) - x + distance) / (2 * distance);
                        HeightMap[x, y] *= weight;
                        HeightMap[x, y] += gh.HeightMap[x + distance - HeightMap.GetLength(0), y + distance] * (1 - weight);
                    }

                    if (y < distance)
                    {
                        float weight = (float)(y + distance) / (2 * distance);
                        HeightMap[x, y] *= weight;
                        HeightMap[x, y] += gh.HeightMap[x + distance, y + distance + HeightMap.GetLength(1)] * (1 - weight);
                    }

                    if (y > HeightMap.GetLength(1) - distance)
                    {
                        float weight = (float)(HeightMap.GetLength(1) - y + distance) / (2 * distance);
                        HeightMap[x, y] *= weight;
                        HeightMap[x, y] += gh.HeightMap[x + distance, y + distance - HeightMap.GetLength(1)] * (1 - weight);
                    }
                }
            }
        }