Exemplo n.º 1
0
        /// <summary>
        /// Run the generator against a world.
        /// </summary>
        /// <param name="world">The world to generate against.</param>
        public void RunGeneration(TWorld world)
        {
            var oceanBiaser = new OceanBiaser <TWorld, TCell>();

            oceanBiaser.CreateBiasPoints(world, 25);

            var rainfallMap = new float[world.Width, world.Height];
            var cloudMap    = new float[world.Width, world.Height];

            var iterations = world.Width;

            for (int i = 0; i < iterations; i++)
            {
                PickAndDropRain(rainfallMap, cloudMap, world);
                cloudMap = MoveClouds(cloudMap, world);
            }

            //TODO ocean adjacent bias

            rainfallMap = MapUtil.Normalize(rainfallMap);

            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    var oceanBias = oceanBiaser.OceanBiasAt(new CellAddress(x, y));
                    world.GetCell(x, y).Rainfall = 0.8f * rainfallMap[x, y] + 0.2f * oceanBias;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the generator against a world.
        /// </summary>
        /// <param name="world">The world to generate against.</param>
        public void RunGeneration(TWorld world)
        {
            var oceanBiaser = new OceanBiaser <TWorld, TCell>();

            oceanBiaser.CreateBiasPoints(world, 25);

            var noise = new SimplexNoiseGenerator(world.Seed + "temperature".GetHashCode());

            var noiseMap = new float[world.Width, world.Height];

            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    noiseMap[x, y] = noise.CoherentNoise(x, y, 0, 3, 100, 0.5f, 2, 0.4f);
                }
            }

            noiseMap = MapUtil.Normalize(noiseMap);

            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    var baseT = y / (float)world.Height * 2;

                    if (y > world.Height / 2)
                    {
                        baseT = (world.Height - y) / (float)world.Height * 2;
                    }

                    var oceanBias = 1f - 0.3f * oceanBiaser.OceanBiasAt(new CellAddress(x, y));

                    world.GetCell(x, y).Temperature = (0.8f * baseT + 0.2f * noiseMap[x, y]) * oceanBias;
                }
            }
        }
        /// <summary>
        /// Run the generator against a world.
        /// </summary>
        /// <param name="world">The world to generate against.</param>
        public void RunGeneration(TWorld world)
        {
            var oceanBiaser = new OceanBiaser <TWorld, TCell>();

            oceanBiaser.CreateBiasPoints(world, 25);

            var noise = new SimplexNoiseGenerator(world.Seed + "rain".GetHashCode());

            var rainfallMap = new float[world.Width, world.Height];

            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    var bias = (float)(-1 * Math.Cos(y / Math.PI / (world.Height / 6f)) / 2 + 0.5f);
                    bias = 0.75f * bias + 0.25f;

                    rainfallMap[x, y] = noise.CoherentNoise(x, y, 0, 3, 75, 0.5f, 2, 0.4f) * bias;
                }
            }

            rainfallMap = MapUtil.Normalize(rainfallMap);

            for (int x = 0; x < world.Width; x++)
            {
                for (int y = 0; y < world.Height; y++)
                {
                    if (!IsOcean(x, y, world))
                    {
                        var oceanBias = oceanBiaser.OceanBiasAt(new CellAddress(x, y));

                        world.GetCell(x, y).Rainfall = 0.8f * rainfallMap[x, y] + 0.2f * oceanBias;
                    }
                }
            }
        }