コード例 #1
0
ファイル: CaveCarver.cs プロジェクト: Czompi/Obsidian
        public CavesCarver(OverworldTerrainSettings ots) : base(ots)
        {
            var thing = new Curve
            {
                ControlPoints = new List <ControlPoint>()
                {
                    new Curve.ControlPoint(-1, -1),
                    new Curve.ControlPoint(-0.7, -0.5),
                    new Curve.ControlPoint(-0.4, -0.5),
                    new Curve.ControlPoint(1, 1),
                },
                Source0 = new Billow
                {
                    Frequency   = 18.12345,
                    Seed        = ots.Seed + 1,
                    Quality     = SharpNoise.NoiseQuality.Fast,
                    OctaveCount = 6,
                    Lacunarity  = 1.2234,
                    Persistence = 1.23
                }
            };

            this.Result = new ScalePoint
            {
                XScale  = 1 / 1024.0,
                YScale  = 1 / 384.0,
                ZScale  = 1 / 1024.0,
                Source0 = thing
            };
        }
コード例 #2
0
ファイル: OverworldTerrain.cs プロジェクト: Czompi/Obsidian
        public OverworldTerrain(OverworldTerrainSettings ots, bool isUnitTest = false)
        {
            settings = ots;

            ocean     = new OceanTerrain(ots);
            plains    = new PlainsTerrain(ots);
            hills     = new HillsTerrain(ots);
            badlands  = new BadlandsTerrain(ots);
            mountains = new MountainsTerrain(ots);
            rivers    = new RiverTerrain(ots);

            humidity    = new HumidityNoise(ots);
            temperature = new TemperatureNoise(ots);
            terrain     = new TerrainNoise(ots);

            cave = new CavesCarver(ots);

            // Scale Point multiplies input values by the scaling factors.
            // Used to stretch or shrink the terrain horizontally.
            var scaled = GetScaledModuleOutput(MergedLandOceanRivers());
            //var scaled = GetScaledModuleOutput(LandOceanSelector());
            //var scaled = GetScaledModuleOutput(temperature.RiverSelector);

            // Scale bias scales the verical output (usually -1.0 to +1.0) to
            // Minecraft values. If MinElev is 40 (leaving room for caves under oceans)
            // and MaxElev is 168, a value of -1 becomes 40, and a value of 1 becomes 168.
            var biased = new ScaleBias
            {
                Scale   = (settings.MaxElev - settings.MinElev) / 2.0,
                Bias    = settings.MinElev + ((settings.MaxElev - settings.MinElev) / 2.0) - 44,
                Source0 = scaled
            };

            Result = isUnitTest ? scaled : biased;
        }
コード例 #3
0
 protected BaseTerrain() : base(0)
 {
     this.settings = OverworldGenerator.GeneratorSettings;
     result        = new Constant {
         ConstantValue = 0
     };
 }
コード例 #4
0
ファイル: HillsTerrain.cs プロジェクト: Czompi/Obsidian
 // Generates the hilly terrain.
 //
 // -1.0 represents the lowest elevations and +1.0 represents the highest
 // elevations.
 //
 // [Hilly-terrain group]: Caches the output value from the warped-hilly-
 // terrain module.  This is the output value for the entire hilly-
 // terrain group.
 public HillsTerrain(OverworldTerrainSettings ots) : base(ots)
 {
     this.Result = new Cache
     {
         Source0 = new Clamp
         {
             UpperBound = 1.0,
             LowerBound = 0.0,
             Source0    = new ScalePoint
             {
                 XScale  = 1 / 4.20,
                 YScale  = 1 / 16.0,
                 ZScale  = 1 / 4.20,
                 Source0 = new Multiply
                 {
                     // [Positive-plains-basis-0 module]: This scale/bias module makes the
                     // output value from the plains-basis-0 module positive since this output
                     // value will be multiplied together with the positive-plains-basis-1
                     // module.
                     Source0 = new ScaleBias
                     {
                         Scale = 0.2, // Flatten -1 < y < 1 to -0.1 < y < 0.1
                         Bias  = 0.5, // move -1 < y < 1 up by 0.1
                         // [Plains-basis-0 module]: This billow-noise module, along with the
                         // plains-basis-1 module, produces the plains.
                         Source0 = new Billow
                         {
                             Seed        = settings.Seed + 79,
                             Frequency   = 23.5,
                             Persistence = 0.5,
                             Lacunarity  = settings.PlainsLacunarity,
                             OctaveCount = 3,
                             Quality     = NoiseQuality.Standard,
                         }
                     },
                     // [Positive-plains-basis-1 module]: This scale/bias module makes the
                     // output value from the plains-basis-1 module positive since this output
                     // value will be multiplied together with the positive-plains-basis-0
                     // module.
                     Source1 = new ScaleBias
                     {
                         Scale = 0.2,
                         Bias  = 0.3,
                         // [Plains-basis-1 module]: This billow-noise module, along with the
                         // plains-basis-2 module, produces the plains.
                         Source0 = new Billow
                         {
                             Seed        = settings.Seed + 78,
                             Frequency   = 13.5,
                             Persistence = 0.5,
                             Lacunarity  = settings.PlainsLacunarity,
                             OctaveCount = 8,
                             Quality     = NoiseQuality.Fast,
                         }
                     }
                 }
             }
         }
     };
 }
コード例 #5
0
ファイル: BaseBiomeNoise.cs プロジェクト: ObsidianMC/Obsidian
    protected BaseBiomeNoise(OverworldTerrainSettings ots, int seedOffset, double curveOffset)
    {
        settings    = ots;
        SeedOffset  = seedOffset;
        CurveOffset = curveOffset;

        BiomeSelector = BiomeSelectorNoise();
        RiverSelector = Rivers();
    }
コード例 #6
0
ファイル: OceanTerrain.cs プロジェクト: Czompi/Obsidian
 // Generates the Ocean terrain.
 // Outputs will be between -0.02 and -0.5
 public OceanTerrain(OverworldTerrainSettings ots) : base(ots)
 {
     this.Result = new Cache
     {
         Source0 = new Clamp
         {
             UpperBound = 0.0,
             LowerBound = -1.0,
             Source0    = new ScalePoint
             {
                 XScale  = 1 / 12.20,
                 YScale  = 1 / 1.0,
                 ZScale  = 1 / 12.20,
                 Source0 = new Turbulence
                 {
                     Frequency = 39.4578,
                     Power     = 0.078,
                     Roughness = 3,
                     Seed      = ots.Seed + 72,
                     Source0   = new Multiply
                     {
                         Source0 = new ScaleBias
                         {
                             Scale   = 0.005, // Flatten
                             Bias    = -0.4,  // move elevation
                             Source0 = new Billow
                             {
                                 Seed        = settings.Seed + 70,
                                 Frequency   = 18.5,
                                 Persistence = 0.5,
                                 Lacunarity  = settings.PlainsLacunarity,
                                 OctaveCount = 3,
                                 Quality     = NoiseQuality.Standard,
                             }
                         },
                         Source1 = new ScaleBias
                         {
                             Scale   = 0.2,
                             Bias    = 0.5,
                             Source0 = new Billow
                             {
                                 Seed        = settings.Seed + 71,
                                 Frequency   = 3.5,
                                 Persistence = 0.5,
                                 Lacunarity  = settings.PlainsLacunarity,
                                 OctaveCount = 8,
                                 Quality     = NoiseQuality.Fast,
                             }
                         }
                     }
                 }
             }
         }
     };
 }
コード例 #7
0
ファイル: OverworldGenerator.cs プロジェクト: Czompi/Obsidian
        public OverworldGenerator(string seed) : base("overworld")
        {
            // If the seed provided is numeric, just use it.
            // Naam asked me to do this a long time ago and I
            // bet he thought that I forgot - Jonpro03
            if (!int.TryParse(seed, out int seedHash))
            {
                seedHash = BitConverter.ToInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(seed)));
            }
            OverworldTerrainSettings generatorSettings = new OverworldTerrainSettings();

            generatorSettings.Seed = seedHash;
            terrainGen             = new OverworldTerrain(generatorSettings);
        }
コード例 #8
0
    public OverworldTerrain(bool isUnitTest = false) : base(0)
    {
        settings  = OverworldGenerator.GeneratorSettings;
        ocean     = new OceanTerrain();
        deepocean = new DeepOceanTerrain();
        plains    = new PlainsTerrain();
        hills     = new HillsTerrain();
        badlands  = new BadlandsTerrain();
        mountains = new MountainsTerrain();
        rivers    = new RiverTerrain();
        caves     = new CavesCarver();
        tunnels   = new VoronoiTunnels()
        {
            Frequency = 0.0123456,
            Seed      = settings.Seed
        };

        Dictionary <Biomes, Module> biomesTerrainMap = new()
        {
            { Biomes.Badlands, badlands },
            { Biomes.BambooJungle, plains },
コード例 #9
0
ファイル: MountainsTerrain.cs プロジェクト: Czompi/Obsidian
 // Generates the hilly terrain.
 //
 // -1.0 represents the lowest elevations and +1.0 represents the highest
 // elevations.
 //
 // [Hilly-terrain group]: Caches the output value from the warped-hilly-
 // terrain module.  This is the output value for the entire hilly-
 // terrain group.
 public MountainsTerrain(OverworldTerrainSettings ots) : base(ots)
 {
     this.Result = new Cache
     {
         // Sanity check to force results b/w -1.0<y<1.0
         Source0 = new ScalePoint
         {
             XScale  = 1 / 0.9,
             YScale  = 1 / 16.0,
             ZScale  = 1 / 0.9,
             Source0 = new Clamp
             {
                 Source0 = new ScaleBias
                 {
                     Scale   = 0.25, // Amplification of terrain
                     Bias    = 0.33, // lowest level is above sea level (0)
                     Source0 = MountainsBase()
                 }
             }
         }
     };
 }
コード例 #10
0
 // Generates the hilly terrain.
 //
 // -1.0 represents the lowest elevations and +1.0 represents the highest
 // elevations.
 //
 // [Hilly-terrain group]: Caches the output value from the warped-hilly-
 // terrain module.  This is the output value for the entire hilly-
 // terrain group.
 public BadlandsTerrain(OverworldTerrainSettings ots) : base(ots)
 {
     this.Result = new Cache
     {
         // Sanity check to force results b/w -1.0<y<1.0
         Source0 = new Clamp
         {
             Source0 = new Max
             {
                 Source0 = BadlandsCliffs(),
                 // [Scaled-sand-dunes module]: This scale/bias module considerably
                 // flattens the output value from the badlands-sands subgroup and lowers
                 // this value to near -1.0.
                 Source1 = new ScaleBias
                 {
                     Scale   = 0.01,
                     Bias    = 0,
                     Source0 = BadlandsSands(),
                 },
             }
         }
     };
 }
コード例 #11
0
ファイル: Noise.cs プロジェクト: Czompi/Obsidian
        public async void SameAsync()
        {
            OverworldTerrainSettings generatorSettings = new OverworldTerrainSettings();

            generatorSettings.Seed = 137;
            OverworldTerrain noiseGen = new OverworldTerrain(generatorSettings, true);

            var map = new NoiseMap();

            PlaneNoiseMapBuilder builder = new PlaneNoiseMapBuilder()
            {
                DestNoiseMap = map,
                SourceModule = noiseGen.Result
            };

            var image    = new SharpNoise.Utilities.Imaging.Image();
            var renderer = new ImageRenderer()
            {
                SourceNoiseMap   = map,
                DestinationImage = image
            };

            //renderer.BuildGrayscaleGradient();
            renderer.BuildTerrainGradient();

            builder.SetBounds(-2024, 2024, -2024, 2024);
            builder.SetDestSize(1024, 1024);
            builder.Build();

            renderer.Render();

            var bmp = renderer.DestinationImage.ToGdiBitmap();

            bmp.Save("terrain.bmp");

            Assert.Equal(0, 0);
        }
コード例 #12
0
ファイル: TerrainNoise.cs プロジェクト: Czompi/Obsidian
 public TerrainNoise(OverworldTerrainSettings ots) : base(ots, 240, ots.BiomeTerrainRatio)
 {
 }
コード例 #13
0
ファイル: TemperatureNoise.cs プロジェクト: Czompi/Obsidian
 public TemperatureNoise(OverworldTerrainSettings ots) : base(ots, 220, ots.BiomeTemperatureRatio)
 {
 }
コード例 #14
0
ファイル: HumidityNoise.cs プロジェクト: Czompi/Obsidian
 public HumidityNoise(OverworldTerrainSettings ots) : base(ots, 200, ots.BiomeHumidityRatio)
 {
 }
コード例 #15
0
 protected BaseTerrain(OverworldTerrainSettings ots)
 {
     this.settings = ots;
 }