Example #1
0
        /***
         *   OctaveCount   八度数
         *   Frequency     频率
         *   Persistence   连续性
         *   Lacunarity    空隙度
         * **/
        protected override void InitWormsGenerator()
        {
            var perlin = new MTBPerlin(_seed);

            perlin.OctaveCount = 40;
            perlin.Frequency   = 10;
            perlin.Persistence = 0.2;
            perlin.Lacunarity  = 0.4;
            var hightline = new ScaleBias(perlin.ModuleBase);

            hightline.Bias   = BlockHeightToFloat(1);
            _heightGenerator = hightline;

            var perlin2 = new MTBPerlin(_seed + 1);

            perlin2.OctaveCount = 80;
            perlin2.Frequency   = 50;
            perlin2.Persistence = 0.1;
            perlin2.Lacunarity  = 0.1;
            var scetion = new ScaleBias(perlin2.ModuleBase);

            scetion.Bias      = BlockHeightToFloat(1);
            _sectionGenerator = scetion;

            _lenght = 80;
            _thresholdOffsetFront = 1.0f;
            _limitWidth           = 1;
            _limitHeight          = 0;
            _radiusHeight         = 1;
            _radiusWidth          = 2;
            _upMixValue           = 1;
            _downMixValue         = 2;
            _emptyRateOffset      = 0.01f;
        }
Example #2
0
        protected virtual void initDirectionDenerator()
        {
            var perlin2 = new MTBPerlin(_seed);

            perlin2.OctaveCount = 80;
            perlin2.Frequency   = 50;
            perlin2.Persistence = 0.1;
            perlin2.Lacunarity  = 0.1;
            var direction = new ScaleBias(perlin2.ModuleBase);

            direction.Bias   = BlockHeightToFloat(1);
            _directGenerator = direction;
        }
        public TerrainControlGenerator()
        {
            _biomeGenerator = new LayeredBiomeGenerator();

            this.maxSmoothDiameter = WorldConfig.Instance.GetMaxSmoothRadius() * 2 + 1;
            this.maxSmoothRadius   = WorldConfig.Instance.GetMaxSmoothRadius();

            this.nearBiomeWeightArray = new float[maxSmoothDiameter * maxSmoothDiameter];

            for (int x = -maxSmoothRadius; x <= maxSmoothRadius; x++)
            {
                for (int z = -maxSmoothRadius; z <= maxSmoothRadius; z++)
                {
                    float f1 = (float)(10.0f / Math.Sqrt(x * x + z * z + 0.2f));
                    this.nearBiomeWeightArray[(x + maxSmoothRadius) + maxSmoothDiameter * (z + maxSmoothRadius)] = f1;
                }
            }

            float xzScale = WorldConfig.Instance.fractureHorizontal;
            float yScale  = WorldConfig.Instance.fractureVertical;

            var perlinHeight = new MTBPerlin(WorldConfig.Instance.seed);

            perlinHeight.Frequency   = 0.1f;
            perlinHeight.OctaveCount = 10;
            var heightScale     = new MTBScale(perlinHeight, 0.1f, 0.1f);
            var heightScaleBias = new MTBScaleBias(heightScale, 0, 0.5f);

            _heightTerrainNoiseGen = heightScaleBias;

            var perlinFracture1 = new MTBPerlin(WorldConfig.Instance.seed + 100);

            perlinFracture1.OctaveCount = 10;
            perlinFracture1.Frequency   = 0.02f;
            var fracture1Scale = new MTBScale(perlinFracture1, xzScale, yScale, xzScale);

            _fractureNoiseGen1 = fracture1Scale;

            var perlinFracture2 = new MTBPerlin(WorldConfig.Instance.seed + 200);

            perlinFracture2.OctaveCount = 10;
            perlinFracture2.Frequency   = 0.03f;
            var fracture2Scale = new MTBScale(perlinFracture2, xzScale, yScale, xzScale);

            _fractureNoiseGen2 = fracture2Scale;

            var perlinFractureSelect = new MTBPerlin(WorldConfig.Instance.seed + 301);

            perlinFractureSelect.OctaveCount = 3;
            var fractureSelectScale = new MTBScale(perlinFractureSelect, xzScale, yScale, xzScale);

            _fractureNoiseSelect = fractureSelectScale;

            var perlinSurface = new MTBPerlin(WorldConfig.Instance.seed + 200);

            perlinSurface.OctaveCount = 6;
            var surfaceScale     = new MTBScale(perlinSurface, 0.02f, 0.02f);
            var surfaceScaleBias = new MTBScaleBias(surfaceScale, 2, 4);

            _surfaceNoiseGen = surfaceScaleBias;

            waterLevelRaw = new byte[NOISE_MAX_X * NOISE_MAX_Z];
            waterLevel    = new byte[Chunk.chunkWidth * Chunk.chunkDepth];

            heightCap = WorldConfig.Instance.heightCap;
            terrain   = new float[Chunk.chunkWidth * heightCap * Chunk.chunkDepth];
        }