Exemplo n.º 1
0
        public bool Generate (IBlockManager blockMan, Random rand, int x, int y, int z)
        {
            float rpi = (float)(rand.NextDouble() * Math.PI);

            double x1 = x + 8 + MathHelper.Sin(rpi) * _size / 8.0F;
            double x2 = x + 8 - MathHelper.Sin(rpi) * _size / 8.0F;
            double z1 = z + 8 + MathHelper.Cos(rpi) * _size / 8.0F;
            double z2 = z + 8 - MathHelper.Cos(rpi) * _size / 8.0F;

            double y1 = y + rand.Next(3) + 2;
            double y2 = y + rand.Next(3) + 2;

            for (int i = 0; i <= _size; i++) {
                double xPos = x1 + (x2 - x1) * i / _size;
                double yPos = y1 + (y2 - y1) * i / _size;
                double zPos = z1 + (z2 - z1) * i / _size;

                double fuzz = rand.NextDouble() * _size / 16.0D;
                double fuzzXZ = (MathHelper.Sin((float)(i * Math.PI / _size)) + 1.0F) * fuzz + 1.0D;
                double fuzzY = (MathHelper.Sin((float)(i * Math.PI / _size)) + 1.0F) * fuzz + 1.0D;

                int xStart, yStart, zStart, xEnd, yEnd, zEnd;

                if (_mathFix) {
                    xStart = (int)Math.Floor(xPos - fuzzXZ / 2.0D);
                    yStart = (int)Math.Floor(yPos - fuzzY / 2.0D);
                    zStart = (int)Math.Floor(zPos - fuzzXZ / 2.0D);

                    xEnd = (int)Math.Floor(xPos + fuzzXZ / 2.0D);
                    yEnd = (int)Math.Floor(yPos + fuzzY / 2.0D);
                    zEnd = (int)Math.Floor(zPos + fuzzXZ / 2.0D);
                }
                else {
                    xStart = (int)(xPos - fuzzXZ / 2.0D);
                    yStart = (int)(yPos - fuzzY / 2.0D);
                    zStart = (int)(zPos - fuzzXZ / 2.0D);

                    xEnd = (int)(xPos + fuzzXZ / 2.0D);
                    yEnd = (int)(yPos + fuzzY / 2.0D);
                    zEnd = (int)(zPos + fuzzXZ / 2.0D);
                }

                for (int ix = xStart; ix <= xEnd; ix++) {
                    double xThresh = (ix + 0.5D - xPos) / (fuzzXZ / 2.0D);
                    if (xThresh * xThresh < 1.0D) {
                        for (int iy = yStart; iy <= yEnd; iy++) {
                            double yThresh = (iy + 0.5D - yPos) / (fuzzY / 2.0D);
                            if (xThresh * xThresh + yThresh * yThresh < 1.0D) {
                                for (int iz = zStart; iz <= zEnd; iz++) {
                                    double zThresh = (iz + 0.5D - zPos) / (fuzzXZ / 2.0D);
                                    if (xThresh * xThresh + yThresh * yThresh + zThresh * zThresh < 1.0D) {
                                        AlphaBlockRef block = blockMan.GetBlockRef(ix, iy, iz);
                                        if (block.IsValid) {
                                            block.ID = _blockId;
                                            block.Data = _blockData;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return true;
        }
Exemplo n.º 2
0
        public bool Generate(IBlockManager blockMan, Random rand, int x, int y, int z)
        {
            float rpi = (float)(rand.NextDouble() * Math.PI);

            double x1 = x + 8 + MathHelper.Sin(rpi) * _size / 8.0F;
            double x2 = x + 8 - MathHelper.Sin(rpi) * _size / 8.0F;
            double z1 = z + 8 + MathHelper.Cos(rpi) * _size / 8.0F;
            double z2 = z + 8 - MathHelper.Cos(rpi) * _size / 8.0F;

            double y1 = y + rand.Next(3) + 2;
            double y2 = y + rand.Next(3) + 2;

            for (int i = 0; i <= _size; i++)
            {
                double xPos = x1 + (x2 - x1) * i / _size;
                double yPos = y1 + (y2 - y1) * i / _size;
                double zPos = z1 + (z2 - z1) * i / _size;

                double fuzz   = rand.NextDouble() * _size / 16.0D;
                double fuzzXZ = (MathHelper.Sin((float)(i * Math.PI / _size)) + 1.0F) * fuzz + 1.0D;
                double fuzzY  = (MathHelper.Sin((float)(i * Math.PI / _size)) + 1.0F) * fuzz + 1.0D;

                int xStart, yStart, zStart, xEnd, yEnd, zEnd;

                if (_mathFix)
                {
                    xStart = (int)Math.Floor(xPos - fuzzXZ / 2.0D);
                    yStart = (int)Math.Floor(yPos - fuzzY / 2.0D);
                    zStart = (int)Math.Floor(zPos - fuzzXZ / 2.0D);

                    xEnd = (int)Math.Floor(xPos + fuzzXZ / 2.0D);
                    yEnd = (int)Math.Floor(yPos + fuzzY / 2.0D);
                    zEnd = (int)Math.Floor(zPos + fuzzXZ / 2.0D);
                }
                else
                {
                    xStart = (int)(xPos - fuzzXZ / 2.0D);
                    yStart = (int)(yPos - fuzzY / 2.0D);
                    zStart = (int)(zPos - fuzzXZ / 2.0D);

                    xEnd = (int)(xPos + fuzzXZ / 2.0D);
                    yEnd = (int)(yPos + fuzzY / 2.0D);
                    zEnd = (int)(zPos + fuzzXZ / 2.0D);
                }

                for (int ix = xStart; ix <= xEnd; ix++)
                {
                    double xThresh = (ix + 0.5D - xPos) / (fuzzXZ / 2.0D);
                    if (xThresh * xThresh < 1.0D)
                    {
                        for (int iy = yStart; iy <= yEnd; iy++)
                        {
                            double yThresh = (iy + 0.5D - yPos) / (fuzzY / 2.0D);
                            if (xThresh * xThresh + yThresh * yThresh < 1.0D)
                            {
                                for (int iz = zStart; iz <= zEnd; iz++)
                                {
                                    double zThresh = (iz + 0.5D - zPos) / (fuzzXZ / 2.0D);
                                    if (xThresh * xThresh + yThresh * yThresh + zThresh * zThresh < 1.0D)
                                    {
                                        AlphaBlockRef block = blockMan.GetBlockRef(ix, iy, iz);
                                        if (block.IsValid)
                                        {
                                            block.ID   = _blockId;
                                            block.Data = _blockData;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }