Exemplo n.º 1
0
        public float rNoise(RTGWorld rtgWorld, int x, int y, float border, float river)
        {
            // we now have both lakes and rivers lowering land
            if (noWaterFeatures)
            {
                float borderForRiver = border * 2;
                if (borderForRiver > 1f)
                {
                    borderForRiver = 1;
                }
                river = 1f - (1f - borderForRiver) * (1f - river);
                return(terrain.generateNoise(rtgWorld, x, y, border, river));
            }
            float lakeStrength    = lakePressure(rtgWorld, x, y, border);
            float _lakeFlattening = lakeFlattening(lakeStrength, lakeShoreLevel, lakeDepressionLevel);
            // we add some flattening to the rivers. The lakes are pre-flattened.
            float riverFlattening = river * 1.25f - 0.25f;

            if (riverFlattening < 0)
            {
                riverFlattening = 0;
            }
            if ((river < 1) && (_lakeFlattening < 1))
            {
                riverFlattening = (1f - riverFlattening) / riverFlattening + (1f - _lakeFlattening) / _lakeFlattening;
                riverFlattening = (1f / (riverFlattening + 1f));
            }
            else if (_lakeFlattening < riverFlattening)
            {
                riverFlattening = _lakeFlattening;
            }
            // the lakes have to have a little less flattening to avoid the rocky edges
            _lakeFlattening = lakeFlattening(lakeStrength, lakeWaterLevel, lakeDepressionLevel);

            if ((river < 1) && (_lakeFlattening < 1))
            {
                river = (1f - river) / river + (1f - _lakeFlattening) / _lakeFlattening;
                river = (1f / (river + 1f));
            }
            else if (_lakeFlattening < river)
            {
                river = _lakeFlattening;
            }
            // flatten terrain to set up for the water features
            float terrainNoise = terrain.generateNoise(rtgWorld, x, y, border, riverFlattening);

            // place water features
            return(this.erodedNoise(rtgWorld, x, y, river, border, terrainNoise, _lakeFlattening));
        }
Exemplo n.º 2
0
        public bool compareTerrain(RTGWorld rtgWorld, TerrainBase oldTerrain)
        {
            OpenSimplexNoise     simplex = new OpenSimplexNoise(4444);
            SimplexCellularNoise cell    = new SimplexCellularNoise(4444);
            Random rand = new Random(4444);

            float oldNoise;

            TerrainBase newTerrain = this.initTerrain();
            float       newNoise;

            for (int x = -64; x <= 64; x++)
            {
                for (int z = -64; z <= 64; z++)
                {
                    oldNoise = oldTerrain.generateNoise(rtgWorld, x, z, 0.5f, 0.5f);
                    newNoise = newTerrain.generateNoise(rtgWorld, x, z, 0.5f, 0.5f);

                    //Logger.info("%s (%d) = oldNoise = %f | newNoise = %f", this.baseBiome.getBiomeName(), Biome.getIdForBiome(this.baseBiome), oldNoise, newNoise);

                    if (oldNoise != newNoise)
                    {
                        throw new Exception(
                                  "Terrains do not match in biome ID " + this.baseBiome.getBiomeID() + " (" + this.baseBiome.ToString() + ")."
                                  );
                    }
                }
            }

            return(true);
        }