示例#1
0
        public static Module CreateNoiseTree()
        {
            var mountainTerrain = new RidgedMulti()
            {

            };

            var baseFlatTerrain = new Billow()
            {
                Frequency = 2,
            };

            var flatTerrain = new ScaleBias()
            {
                Source0 = baseFlatTerrain,
                Scale = 0.125,
                Bias = -0.75,
            };

            var terrainType = new Perlin()
            {
                Frequency = 0.5,
                Persistence = 0.25,
            };

            var terrainSelector = new Select()
            {
                Source0 = flatTerrain,
                Source1 = mountainTerrain,
                Control = terrainType,
                LowerBound = 0,
                UpperBound = 1000,
                EdgeFalloff = 0.125,
            };

            var finalTerrain = new Turbulence()
            {
                Source0 = terrainSelector,
                Frequency = 4,
                Power = 0.125,
            };

            return finalTerrain;
        }
示例#2
0
    public async void TerrainBlendAsync()
    {
        OverworldGenerator og       = new OverworldGenerator();
        OverworldTerrain   noiseGen = new OverworldTerrain(true);
        await Task.Run(() =>
        {
            var noise = new SharpNoise.Modules.ScaleBias()
            {
                Scale   = 4,
                Source0 = noiseGen.selectiveBlend
            };

            var map = new NoiseMap();
            PlaneNoiseMapBuilder builder =
                new PlaneNoiseMapBuilder()
            {
                DestNoiseMap = map, SourceModule = noise
            };

            var image = new Image();
            var transitionsRenderer = new ImageRenderer()
            {
                SourceNoiseMap = map, DestinationImage = image
            };
            transitionsRenderer.BuildTerrainGradient();
            builder.SetBounds(-400, 400, -300, 300);
            builder.SetDestSize(800, 600);
            builder.Build();
            transitionsRenderer.Render();

            var bmp = transitionsRenderer.DestinationImage.ToGdiBitmap();
            bmp.Save("_blendedterrain.bmp");

            Assert.Equal(0, 0);
        });
    }