예제 #1
0
        public void GenerateChunk(int chunkX, int chunkZ)
        {
            chunkSeed = (chunkX * chunkXMul) ^ (chunkZ * chunkZMul) ^ Seed;
            CombinedNoise n1 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            CombinedNoise n2 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            OctaveNoise n3 = new OctaveNoise(6, rnd);

            if (heightmap == null)
            {
                heightmap = new short[Width * Length];
            }

            CreateChunkHeightmap(chunkX, chunkZ, n1, n2, n3);

            OctaveNoise n4 = new OctaveNoise(8, rnd);

            CreateChunkStrata(chunkX, chunkZ, n4);

            OctaveNoise n5 = new OctaveNoise(8, rnd);
            OctaveNoise n6 = new OctaveNoise(8, rnd);

            CreateChunkSurfaceLayer(chunkX, chunkZ, n5, n6);
        }
예제 #2
0
        void CreateHeightmap()
        {
            Noise n1 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            Noise n2 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            Noise n3    = new OctaveNoise(6, rnd);
            int   index = 0;

            short[] hMap = new short[width * length];
            CurrentState = "Building heightmap";

            for (int z = 0; z < length; z++)
            {
                CurrentProgress = (float)z / length;
                for (int x = 0; x < width; x++)
                {
                    double hLow  = n1.Compute(x * 1.3f, z * 1.3f) / 6 - 4;
                    double hHigh = n2.Compute(x * 1.3f, z * 1.3f) / 5 + 6;

                    double height = n3.Compute(x, z) > 0 ? hLow : Math.Max(hLow, hHigh);
                    height *= 0.5;
                    if (height < 0)
                    {
                        height *= 0.8f;
                    }
                    hMap[index++] = (short)(height + waterLevel);
                }
            }
            heightmap = hMap;
        }
예제 #3
0
        /* ========================= */
        /* ===== OLD FUNCTIONS ===== */
        /* ========================= */

        void CreateHeightmap()
        {
            CombinedNoise n1 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            CombinedNoise n2 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            OctaveNoise n3    = new OctaveNoise(6, rnd);
            int         index = 0;

            short[] hMap = new short[Width * Length];
            CurrentState = "Building heightmap";

            for (int z = 0; z < Length; z++)
            {
                CurrentProgress = (float)z / Length;
                for (int x = 0; x < Width; x++)
                {
                    double hLow = n1.Compute(x * 1.3f, z * 1.3f) / 6 - 4, height = hLow;
                    double hHigh = n2.Compute(x * 1.3f, z * 1.3f) / 5 + 6;

                    if (n3.Compute(x, z) <= 0)
                    {
                        height = Math.Max(hLow, hHigh);
                    }

                    /*if (x == 135 && z == 138) {
                     *      double nose = n3.Compute(x, z) / 8;
                     *      Console.WriteLine(nose.ToString());
                     * }*/

                    height *= 0.5;
                    if (height < 0)
                    {
                        height *= 0.8f;
                    }

                    double erode = n3.Compute(x, z);

                    //if (n3.Compute(x, z) > 3.0 && hHigh < hLow) {
                    if (erode / 8 <= hLow && Closer(hLow, hHigh, erode / 4) == hLow && erode >= 0)
                    {
                        //if (n3.Compute(x * 1.3, z * 1.3) / 6 < -0.5 || n3.Compute(x * 1.3, z * 1.3) / 6 > 1.5) {
                        if ((short)height % 2 != 0 && (short)height > 0)
                        {
                            height -= 1;
                        }
                    }

                    short adjHeight = (short)(height + waterLevel);
                    minHeight     = adjHeight < minHeight ? adjHeight : minHeight;
                    hMap[index++] = adjHeight;
                }
            }
            heightmap = hMap;
        }
        public override BlockRaw[] Generate()
        {
            game.World.seed = this.Seed;
            oneY            = Width * Length;
            waterLevel      = Height / 2;
            blocks          = new BlockRaw[Width * Height * Length];
            rnd             = new JavaRandom(Seed);
            rnd2            = new JavaRandom(Seed);
            chunkXMul       = rnd2.nextLong();
            chunkZMul       = rnd2.nextLong();
            minHeight       = Height;

            n1 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            n2 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            n3 = new OctaveNoise(6, rnd);

            n4 = new OctaveNoise(8, rnd);

            n5 = new OctaveNoise(8, rnd);
            n6 = new OctaveNoise(8, rnd);

            for (int z = 0; z < Length / 16; z++)
            {
                for (int x = 0; x < Width / 16; x++)
                {
                    GenerateChunk(x, z);
                }
            }

            /*for (int z = 0; z < (Length + Length % 16) / 16; z++)
             *      for (int x = 0; x < (Width + Width % 16) / 16; x++) {
             *      chunkSeed = Seed + (x * chunkXMul) + (z * chunkZMul);
             *      if (heightmap == null) heightmap = new short[Width * Length];
             *      CreateChunkHeightmap(x, z, n1, n2, n3);
             * }
             *
             * CreateHeightmap();
             * CreateStrata();
             * CarveCaves();
             * CarveOreVeins(0.9f, "coal ore", Block.CoalOre);
             * CarveOreVeins(0.7f, "iron ore", Block.IronOre);
             * CarveOreVeins(0.5f, "gold ore", Block.GoldOre);
             *
             * FloodFillWaterBorders();
             * FloodFillWater();
             * FloodFillLava();
             *
             * CreateSurfaceLayer();
             * PlantFlowers();
             * PlantMushrooms();
             * PlantTrees();*/
            return(blocks);
        }
예제 #5
0
        void CreateChunkHeightmap(int chunkX, int chunkZ, CombinedNoise n1, CombinedNoise n2, OctaveNoise n3)
        {
            /*CombinedNoise n1 = new CombinedNoise(
             *      new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
             * CombinedNoise n2 = new CombinedNoise(
             *      new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
             * OctaveNoise n3 = new OctaveNoise(6, rnd);*/
            int index = 0;
            //short[] hMap = new short[16 * 16];
            int offsetX = (chunkX * 16);
            int offsetZ = (chunkZ * 16);

            CurrentState = "Building heightmap";

            for (int z = 0; z < 16; z++)
            {
                int zCur = z + offsetZ;
                CurrentProgress = (float)z / Length;
                for (int x = 0; x < 16; x++)
                {
                    int xCur = x + offsetX;
                    if (xCur >= Width || zCur >= Length)
                    {
                        break;
                    }
                    double hLow = n1.Compute(xCur * 1.3f, zCur * 1.3f) / 6 - 4, height = hLow;

                    if (n3.Compute(xCur, zCur) <= 0)
                    {
                        double hHigh = n2.Compute(xCur * 1.3f, zCur * 1.3f) / 5 + 6;
                        height = Math.Max(hLow, hHigh);
                    }

                    height *= 0.5;
                    if (height < 0)
                    {
                        height *= 0.8f;
                    }

                    short adjHeight = (short)(height + waterLevel);
                    minHeight        = adjHeight < minHeight ? adjHeight : minHeight;
                    index            = zCur * Width + xCur;
                    heightmap[index] = adjHeight;
                }
            }
            //heightmap = hMap;
        }
        void CreateHeightmap()
        {
            CombinedNoise n1 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            CombinedNoise n2 = new CombinedNoise(
                new OctaveNoise(8, rnd), new OctaveNoise(8, rnd));
            OctaveNoise n3    = new OctaveNoise(6, rnd);
            int         index = 0;

            short[] hMap = new short[Width * Length];
            CurrentState = "Building heightmap";

            for (int z = 0; z < Length; z++)
            {
                CurrentProgress = (float)z / Length;
                for (int x = 0; x < Width; x++)
                {
                    double hLow = n1.Compute(x * 1.3f, z * 1.3f) / 6 - 4, height = hLow;

                    if (n3.Compute(x, z) <= 0)
                    {
                        double hHigh = n2.Compute(x * 1.3f, z * 1.3f) / 5 + 6;
                        height = Math.Max(hLow, hHigh);
                    }

                    height *= 0.5;
                    if (height < 0)
                    {
                        height *= 0.8f;
                    }

                    short adjHeight = (short)(height + waterLevel);
                    minHeight     = adjHeight < minHeight ? adjHeight : minHeight;
                    hMap[index++] = adjHeight;
                }
            }
            heightmap = hMap;
        }
        void CreateHeightmap()
        {
            Noise n1 = new CombinedNoise(
                new OctaveNoise( 8, rnd ), new OctaveNoise( 8, rnd ) );
            Noise n2 = new CombinedNoise(
                new OctaveNoise( 8, rnd ), new OctaveNoise( 8, rnd ) );
            Noise n3 = new OctaveNoise( 6, rnd );
            int index = 0;
            short[] hMap = new short[width * length];
            CurrentState = "Building heightmap";

            for( int z = 0; z < length; z++ ) {
                CurrentProgress = (float)z / length;
                for( int x = 0; x < width; x++ ) {
                    double hLow = n1.Compute( x * 1.3f, z * 1.3f ) / 6 - 4;
                    double hHigh = n2.Compute( x * 1.3f, z * 1.3f ) / 5 + 6;

                    double height = n3.Compute( x, z ) > 0 ? hLow : Math.Max( hLow, hHigh );
                    height *= 0.5;
                    if( height < 0 ) height *= 0.8f;
                    hMap[index++] = (short)(height + waterLevel);
                }
            }
            heightmap = hMap;
        }