Ejemplo n.º 1
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            /* Courtesy of fCraft's awesome Open-Source'ness :D */
            double cx = (Min.X + Max.X) / 2.0, cy = (Min.Y + Max.Y) / 2.0, cz = (Min.Z + Max.Z) / 2.0;
            double rx = (Max.X - Min.X) / 2.0 + 0.25, ry = (Max.Y - Min.Y) / 2.0 + 0.25, rz = (Max.Z - Min.Z) / 2.0 + 0.25;
            double rx2 = 1 / (rx * rx), ry2 = 1 / (ry * ry), rz2 = 1 / (rz * rz);

            double  smallrx2 = 1 / ((rx - 1) * (rx - 1));
            double  smallry2 = 1 / ((ry - 1) * (ry - 1));
            double  smallrz2 = 1 / ((rz - 1) * (rz - 1));
            Vec3U16 min = Clamp(Min), max = Clamp(Max);

            for (ushort yy = min.Y; yy <= max.Y; yy++)
            {
                for (ushort zz = min.Z; zz <= max.Z; zz++)
                {
                    for (ushort xx = min.X; xx <= max.X; xx++)
                    {
                        double dx = xx - cx, dy = yy - cy, dz = zz - cz;
                        dx *= dx; dy *= dy; dz *= dz;
                        bool inRange = dx * rx2 + dy * ry2 + dz * rz2 <= 1;
                        if (inRange && (dx * smallrx2 + dy * smallry2 + dz * smallrz2 > 1))
                        {
                            output(Place(xx, yy, zz, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        bool outline = false;
                        outline |= Layer && Level.GetBlock((ushort)(x - 1), y, z) == Target;
                        outline |= Layer && Level.GetBlock((ushort)(x + 1), y, z) == Target;
                        outline |= Layer && Level.GetBlock(x, y, (ushort)(z - 1)) == Target;
                        outline |= Layer && Level.GetBlock(x, y, (ushort)(z + 1)) == Target;
                        outline |= Below && Level.GetBlock(x, (ushort)(y - 1), z) == Target;
                        outline |= Above && Level.GetBlock(x, (ushort)(y + 1), z) == Target;

                        if (outline && Level.GetBlock(x, y, z) != Target)
                        {
                            output(Place(x, y, z, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Height;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int dy         = Invert ? y - Min.Y : Max.Y - y;
                int curRadius  = Radius * (dy + 1) / height;
                int curRadius2 = Radius * (dy) / height;

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int xx = Math.Abs(C.X - x), zz = Math.Abs(C.Z - z);
                        if (xx > curRadius || zz > curRadius)
                        {
                            continue;
                        }

                        if (xx <= (curRadius - 1) && zz <= (curRadius - 1) &&
                            xx <= (curRadius2) && zz <= (curRadius2))
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Max.Y - Min.Y;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int xx = C.X - x, yy = y - Min.Y, zz = C.Z - z;
                        int curHeight = Invert ? yy : height - yy;
                        if (curHeight == 0)
                        {
                            continue;
                        }

                        double curRadius = Radius * ((double)curHeight / (double)height);
                        int    absx = Math.Abs(xx), absz = Math.Abs(zz);
                        if (absx > curRadius || absz > curRadius)
                        {
                            continue;
                        }
                        if (absx < (curRadius - 1) && absz < (curRadius - 1))
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 P   = Clamp(marks[0]);
            Level   lvl = Level;

            // Need to make a list of leave coordinates, because otherwise
            // drawing tree with /scale won't work properly
            List <Vec3U16> leaves = new List <Vec3U16>();

            Tree.Generate(P.X, P.Y, P.Z, (xT, yT, zT, bT) =>
            {
                if (bT != Block.Leaves)
                {
                    output(Place(xT, yT, zT, bT));
                }
                else if (lvl.IsAirAt(xT, yT, zT))
                {
                    leaves.Add(new Vec3U16(xT, yT, zT));
                }
            });

            foreach (Vec3U16 pos in leaves)
            {
                output(Place(pos.X, pos.Y, pos.Z, brush));
            }
        }
Ejemplo n.º 6
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            double  cx = XCentre, cz = ZCentre;
            int     height = Height;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int    dy = Invert ? y - Min.Y : Max.Y - y;
                double T  = (double)(dy + 1) / height;

                double rx = ((Max.X - Min.X) / 2.0) * T + 0.25;
                double rz = ((Max.Z - Min.Z) / 2.0) * T + 0.25;
                double rx2 = 1 / (rx * rx), rz2 = 1 / (rz * rz);

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        double dx = x - cx, dz = z - cz;

                        if ((dx * dx) * rx2 + (dz * dz) * rz2 <= 1)
                        {
                            output(Place(x, y, z, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            /* Courtesy of fCraft's awesome Open-Source'ness :D */
            double  cx = XCentre, cz = ZCentre;
            double  rx = XRadius, rz = ZRadius;
            double  outer_rx2 = 1 / (rx * rx);
            double  outer_rz2 = 1 / (rz * rz);
            double  inner_rx2 = 1 / ((rx - 1) * (rx - 1));
            double  inner_rz2 = 1 / ((rz - 1) * (rz - 1));
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        double dx = x - cx, dz = z - cz;
                        dx *= dx; dz *= dz;

                        if (dx * outer_rx2 + dz * outer_rz2 > 1)
                        {
                            continue; // outside cylinder radius
                        }
                        if (dx * inner_rx2 + dz * inner_rz2 > 1)
                        {
                            output(Place(x, y, z, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                output(Place(p1.X, y, p1.Z, brush));
                output(Place(p2.X, y, p1.Z, brush));
                output(Place(p1.X, y, p2.Z, brush));
                output(Place(p2.X, y, p2.Z, brush));
            }

            for (ushort z = p1.Z; z <= p2.Z; z++)
            {
                output(Place(p1.X, p1.Y, z, brush));
                output(Place(p2.X, p1.Y, z, brush));
                output(Place(p1.X, p2.Y, z, brush));
                output(Place(p2.X, p2.Y, z, brush));
            }

            for (ushort x = p1.X; x <= p2.X; x++)
            {
                output(Place(x, p1.Y, p1.Z, brush));
                output(Place(x, p1.Y, p2.Z, brush));
                output(Place(x, p2.Y, p1.Z, brush));
                output(Place(x, p2.Y, p2.Z, brush));
            }
        }
Ejemplo n.º 9
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Max.X = Math.Min(Max.X, Source.Width - 1);
            Max.Y = Math.Min(Max.Y, Source.Height - 1);
            Max.Z = Math.Min(Max.Z, Source.Length - 1);

            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            int     width = Source.Width, length = Source.Length;

            byte[]   blocks = Source.blocks;
            ExtBlock block;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        block.BlockID = blocks[x + width * (z + y * length)];
                        block.ExtID   = 0;
                        if (block.BlockID == Block.custom_block)
                        {
                            block.ExtID = Source.GetExtTileNoCheck(x, y, z);
                        }
                        output(Place(x, y, z, block));
                    }
                }
            }

            Source.Dispose();
        }
Ejemplo n.º 10
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            selector = new RgbPaletteMatcher();
            CalcLayerColors();

            using (PixelGetter getter = new PixelGetter(Source)) {
                getter.Init();
                OutputPixels(getter, output);
            }
            selector = null;

            // Put all the blocks in shadow
            if (DualLayer)
            {
                ushort y = (ushort)(Origin.Y + Source.Height);
                for (int i = 0; i < Source.Width; i++)
                {
                    ushort x = (ushort)(Origin.X + dx.X * i);
                    ushort z = (ushort)(Origin.Z + dx.Z * i);
                    output(Place(x, y, z, Block.Stone));

                    x = (ushort)(x + adj.X); z = (ushort)(z + adj.Z);
                    output(Place(x, y, z, Block.Stone));
                }
            }

            Source.Dispose();
            Source = null;
            Player.Message("Finished printing image using {0} palette.", Palette.Name);
        }
Ejemplo n.º 11
0
        void OutputBlock(DrawOpBlock b, DrawOpOutput output)
        {
            int dx = (b.X - P.X) * signX, dy = (b.Y - P.Y) * signY, dz = (b.Z - P.Z) * signZ;

            int begX = P.X + dx * XMul / XDiv, endX = P.X + (dx + dirX) * XMul / XDiv;
            int begY = P.Y + dy * YMul / YDiv, endY = P.Y + (dy + dirY) * YMul / YDiv;
            int begZ = P.Z + dz * ZMul / ZDiv, endZ = P.Z + (dz + dirZ) * ZMul / ZDiv;

            // Scale out until we hit the next block
            for (int y = begY; y != endY; y += dirY)
            {
                for (int z = begZ; z != endZ; z += dirZ)
                {
                    for (int x = begX; x != endX; x += dirX)
                    {
                        if (x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= length)
                        {
                            continue;
                        }
                        b.X = (ushort)x; b.Y = (ushort)y; b.Z = (ushort)z;
                        output(b);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Max.Y - Min.Y;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int xx = C.X - x, yy = y - Min.Y, zz = C.Z - z;
                        int curHeight = Invert ? yy : height - yy;
                        if (curHeight == 0)
                        {
                            continue;
                        }

                        double curRadius = Radius * ((double)curHeight / (double)height);
                        int    dist      = xx * xx + zz * zz;
                        if (dist > curRadius * curRadius || dist < (curRadius - 1) * (curRadius - 1))
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Max.Y - Min.Y;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int dy        = y - Min.Y;
                int curHeight = Invert ? dy : height - dy;
                if (curHeight == 0)
                {
                    continue;
                }
                int curRadius = Radius * curHeight / height;

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int dx = C.X - x, dz = C.Z - z;
                        int dist = dx * dx + dz * dz;
                        if (dist > curRadius * curRadius)
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            double  cx = XCentre, cy = YCentre, cz = ZCentre;
            double  rx = XRadius, ry = YRadius, rz = ZRadius;
            double  rTube = ry, rCentre = Math.Min(rx, rz) - rTube;
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort yy = p1.Y; yy <= p2.Y; yy++)
            {
                for (ushort zz = p1.Z; zz <= p2.Z; zz++)
                {
                    for (ushort xx = p1.X; xx <= p2.X; xx++)
                    {
                        double dx = xx - cx, dy = yy - cy, dz = zz - cz;
                        dx *= dx; dy *= dy; dz *= dz;
                        double dInner = rCentre - Math.Sqrt(dx + dz);

                        if (dInner * dInner + dy <= rTube * rTube * 0.5 + 0.25)
                        {
                            output(Place(xx, yy, zz, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        void OutputBlock(DrawOpBlock b, DrawOpOutput output)
        {
            double dx = b.X - P.X, dy = b.Y - P.Y, dz = b.Z - P.Z;
            double rotX = 0, rotY = 0, rotZ = 0;

            // Rotate X
            rotY = cosX * dy - sinX * dz;
            rotZ = sinX * dy + cosX * dz;
            dy   = rotY; dz = rotZ;

            // Rotate Y
            rotX = cosY * dx + sinY * dz;
            rotZ = -sinY * dx + cosY * dz;
            dx   = rotX; dz = rotZ;

            // Rotate Z
            rotX = cosZ * dx - sinZ * dy;
            rotY = sinZ * dx + cosZ * dy;
            dx   = rotX; dy = rotY;

            b.X = (ushort)(dx + P.X + ((dx % 1) >= 0.5 ? 1 : 0));
            b.Y = (ushort)(dy + P.Y + ((dy % 1) >= 0.5 ? 1 : 0));
            b.Z = (ushort)(dz + P.Z + ((dz % 1) >= 0.5 ? 1 : 0));
            output(b);
        }
Ejemplo n.º 16
0
 void DrawLetter(Player p, char c, Brush brush, DrawOpOutput output) {
     if ((int)c >= 256 || letters[c] == 0) {
         if (c != ' ') Player.Message(p, "\"{0}\" is not currently supported, replacing with space.", c);
         pos.X = (ushort)(pos.X + dirX * 4 * Scale);
         pos.Z = (ushort)(pos.Z + dirZ * 4 * Scale);
     } else {
         ulong flags = letters[c]; int shift = 56;
         while (flags != 0) {
             byte yUsed = (byte)(flags >> shift);  
             flags &= (1UL << shift) - 1; shift -= 8;
             
             for (int j = 0; j < 8; j++) {
                 if ((yUsed & (1 << j)) == 0) continue;
                 
                 for (int ver = 0; ver < Scale; ver++)
                     for (int hor = 0; hor < Scale; hor++) 
                 {
                     int x = pos.X + dirX * hor, y = pos.Y + j * Scale + ver, z = pos.Z + dirZ * hor;
                     output(Place((ushort)x, (ushort)y, (ushort)z, brush));
                 }
             }
             pos.X = (ushort)(pos.X + dirX * Scale);
             pos.Z = (ushort)(pos.Z + dirZ * Scale);
         }
     }
     pos.X = (ushort)(pos.X + dirX * Spacing);
     pos.Z = (ushort)(pos.Z + dirZ * Spacing);
 }
Ejemplo n.º 17
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            /* Courtesy of fCraft's awesome Open-Source'ness :D */
            double  cx = XCentre, cy = YCentre, cz = ZCentre;
            double  rx = XRadius, ry = YRadius, rz = ZRadius;
            double  outer_rx2 = 1 / (rx * rx);
            double  outer_ry2 = 1 / (ry * ry);
            double  outer_rz2 = 1 / (rz * rz);
            double  inner_rx2 = 1 / ((rx - 1) * (rx - 1));
            double  inner_ry2 = 1 / ((ry - 1) * (ry - 1));
            double  inner_rz2 = 1 / ((rz - 1) * (rz - 1));
            Vec3U16 min = Clamp(Min), max = Clamp(Max);

            for (ushort y = min.Y; y <= max.Y; y++)
            {
                for (ushort z = min.Z; z <= max.Z; z++)
                {
                    for (ushort x = min.X; x <= max.X; x++)
                    {
                        double dx = x - cx, dy = y - cy, dz = z - cz;
                        dx *= dx; dy *= dy; dz *= dz;

                        if (dx * outer_rx2 + dy * outer_ry2 + dz * outer_rz2 > 1)
                        {
                            continue; // outside ellipsoid radius
                        }
                        if (dx * inner_rx2 + dy * inner_ry2 + dz * inner_rz2 > 1)
                        {
                            output(Place(x, y, z, brush));
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            wallOp.Min = Min; wallOp.Max = Max;
            baseOp.Min = Min; baseOp.Max = Max;
            wallOp.SetLevel(Level); baseOp.SetLevel(Level);
            wallOp.Player = Player; baseOp.Player = Player;

            while (true)
            {
                wallOp.Perform(marks, brush, output);
                if (p1.Y >= Level.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)
                {
                    return;
                }

                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;

                baseOp.Perform(marks, airBrush, output);
                p1.Y       = (ushort)(p1.Y + yDir); p2.Y = p1.Y;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;
            }
        }
Ejemplo n.º 19
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        bool    hollow = true;
                        BlockID block  = Level.GetBlock(x, y, z);
                        if (!CanHollow(block, true) && block != Skip)
                        {
                            CheckTile(x - 1, y, z, ref hollow);
                            CheckTile(x + 1, y, z, ref hollow);
                            CheckTile(x, y - 1, z, ref hollow);
                            CheckTile(x, y + 1, z, ref hollow);
                            CheckTile(x, y, z - 1, ref hollow);
                            CheckTile(x, y, z + 1, ref hollow);
                        }
                        else
                        {
                            hollow = false;
                        }

                        if (hollow)
                        {
                            output(Place(x, y, z, Block.Air));
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Height;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int dy        = Invert ? y - Min.Y : Max.Y - y;
                int curRadius = Radius * (dy + 1) / height;

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int dx = C.X - x, dz = C.Z - z;
                        if (Math.Abs(dx) > curRadius || Math.Abs(dz) > curRadius)
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Height;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int dy         = Max.Y - y;
                int curRadius  = Radius * (dy + 1) / height;
                int curRadius2 = Radius * (dy) / height;

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int dx = C.X - x, dz = C.Z - z;
                        int dist = dx * dx + dz * dz;
                        if (dist > curRadius * curRadius)
                        {
                            continue;
                        }

                        bool layer = curRadius == 0 ||
                                     !(dist <= (curRadius - 1) * (curRadius - 1) &&
                                       dist <= (curRadius2) * (curRadius2));

                        BlockID block = layer ? Block.Grass : Block.StillLava;
                        output(Place(x, y, z, block));
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Height;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                int dy         = Invert ? y - Min.Y : Max.Y - y;
                int curRadius  = Radius * (dy + 1) / height;
                int curRadius2 = Radius * (dy) / height;

                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int dx = C.X - x, dz = C.Z - z;
                        int dist = dx * dx + dz * dz;
                        if (dist > curRadius * curRadius)
                        {
                            continue;
                        }

                        if (dist <= (curRadius - 1) * (curRadius - 1) &&
                            dist <= (curRadius2) * (curRadius2))
                        {
                            continue;
                        }
                        output(Place(x, y, z, brush));
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16        p1 = Clamp(marks[0]), p2 = Clamp(marks[1]);
            List <Vec3S32> buffer = new List <Vec3S32>();

            DrawLine(p1.X, p1.Y, p1.Z, MaxLength, p2.X, p2.Y, p2.Z, buffer);
            if (WallsMode)
            {
                ushort yy1 = p1.Y, yy2 = p2.Y;
                p1.Y = Math.Min(yy1, yy2); p2.Y = Math.Max(yy1, yy2);
            }

            for (int i = 0; i < buffer.Count; i++)
            {
                Vec3U16 pos = (Vec3U16)buffer[i];
                if (WallsMode)
                {
                    for (ushort yy = p1.Y; yy <= p2.Y; yy++)
                    {
                        output(Place(pos.X, yy, pos.Z, brush));
                    }
                }
                else
                {
                    output(Place(pos.X, pos.Y, pos.Z, brush));
                }
            }
        }
Ejemplo n.º 24
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);
            Vec3S32 C      = (Min + Max) / 2;
            int     height = Max.Y - Min.Y;

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        int xx = C.X - x, yy = y - Min.Y, zz = C.Z - z;
                        int curHeight = height - yy;
                        if (curHeight == 0)
                        {
                            continue;
                        }

                        double curRadius = Radius * ((double)curHeight / (double)height);
                        int    dist      = xx * xx + zz * zz;
                        if (dist > curRadius * curRadius)
                        {
                            continue;
                        }

                        bool    layer = dist >= (curRadius - 1) * (curRadius - 1);
                        BlockID block = layer ? Block.Grass : Block.StillLava;
                        output(Place(x, y, z, block));
                    }
                }
            }
        }
Ejemplo n.º 25
0
        void FixLight(DrawOpOutput output)
        {
            Level   lvl = Level;
            int     oneY = lvl.Width * lvl.Length;
            int     index, width = lvl.Width, length = lvl.Length;
            BlockID above, block;

            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            for (ushort y = p1.Y; y <= p2.Y; y++)
            {
                for (ushort z = p1.Z; z <= p2.Z; z++)
                {
                    for (ushort x = p1.X; x <= p2.X; x++)
                    {
                        index = x + width * (z + y * length);
                        block = lvl.FastGetBlock(index);
                        bool inShadow = false;

                        if (lvl.Props[block].GrassBlock != Block.Invalid)
                        {
                            for (int i = 1; i < (lvl.Height - y); i++)
                            {
                                above = lvl.FastGetBlock(index + oneY * i);
                                if (!lvl.LightPasses(above))
                                {
                                    inShadow = true; break;
                                }
                            }

                            BlockID grass = lvl.Props[block].GrassBlock;
                            if (!inShadow)
                            {
                                output(Place(x, y, z, grass));
                            }
                        }
                        else if (lvl.Props[block].DirtBlock != Block.Invalid)
                        {
                            for (int i = 1; i < (lvl.Height - y); i++)
                            {
                                above = lvl.FastGetBlock(index + oneY * i);
                                if (!lvl.LightPasses(above))
                                {
                                    inShadow = true; break;
                                }
                            }

                            BlockID dirt = lvl.Props[block].DirtBlock;
                            if (inShadow)
                            {
                                output(Place(x, y, z, dirt));
                            }
                        }
                        index++;
                    }
                }
            }
        }
Ejemplo n.º 26
0
 public override void Perform(Vec3S32[] marks, DrawOp op, Brush brush, DrawOpOutput output)
 {
     P = (op.Min + op.Max) / 2;
     if (!CentreOrigin)
     {
         P = op.Origin;
     }
     op.Perform(marks, brush, b => OutputBlock(b, output));
 }
Ejemplo n.º 27
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            width = Max.X - Min.X;
            if (width % 2 != 0)
            {
                width++; Min.X--;
            }
            width -= 2;
            length = Max.Z - Min.Z;
            if (length % 2 != 0)
            {
                length++; Min.Z--;
            }
            length -= 2;

            if (width <= 0 || length <= 0)
            {
                Player.Message(Player, "The corners of the maze need to be further apart."); return;
            }
            Player.Message(Player, "Generating maze... this could take a while");
            GenerateMaze();
            Player.Message(Player, "Generated maze, now drawing.");

            Vec3U16  min = Clamp(Min), max = Clamp(Max);
            ushort   y = min.Y;
            ExtBlock doubleSlab = (ExtBlock)Block.DoubleSlab, leaf = (ExtBlock)Block.Leaves;

            for (ushort x = 0; x <= width; x++)
            {
                for (ushort z = 0; z <= length; z++)
                {
                    if (wall[x, z])
                    {
                        output(Place((ushort)(min.X + x + 1), y, (ushort)(min.Z + z + 1), doubleSlab));
                        output(Place((ushort)(min.X + x + 1), (ushort)(y + 1), (ushort)(min.Z + z + 1), leaf));
                        output(Place((ushort)(min.X + x + 1), (ushort)(y + 2), (ushort)(min.Z + z + 1), leaf));
                    }
                }
            }

            brush = new SolidBrush(doubleSlab);
            QuadX(min.X, y, min.Z, y, max.Z, brush, output);
            QuadX(max.X, y, min.Z, y, max.Z, brush, output);
            QuadZ(min.Z, y, min.X, y, max.X, brush, output);
            QuadZ(max.Z, y, min.X, y, max.X, brush, output);

            brush = new SolidBrush(leaf);
            QuadX(min.X, (ushort)(y + 1), min.Z, (ushort)(y + 2), max.Z, brush, output);
            QuadX(max.X, (ushort)(y + 1), min.Z, (ushort)(y + 2), max.Z, brush, output);
            QuadZ(min.Z, (ushort)(y + 1), min.X, (ushort)(y + 2), max.X, brush, output);
            QuadZ(max.Z, (ushort)(y + 1), min.X, (ushort)(y + 2), max.X, brush, output);

            Player.Message(Player, "Maze painted. Build the entrance and exit yourself");
            randomizer = 0;
        }
Ejemplo n.º 28
0
 protected void QuadX(ushort x, ushort y1, ushort z1, ushort y2, ushort z2,
                      Brush brush, DrawOpOutput output)
 {
     for (ushort y = y1; y <= y2; y++)
     {
         for (ushort z = z1; z <= z2; z++)
         {
             output(Place(x, y, z, brush));
         }
     }
 }
Ejemplo n.º 29
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            ushort x, y, z;

            for (int i = 0; i < Positions.Count; i++)
            {
                int pos = Positions[i];
                Level.IntToPos(pos, out x, out y, out z);
                output(Place(x, y, z, brush));
            }
        }
Ejemplo n.º 30
0
 protected void QuadZ(ushort z, ushort y1, ushort x1, ushort y2, ushort x2,
                      Brush brush, DrawOpOutput output)
 {
     for (ushort y = y1; y <= y2; y++)
     {
         for (ushort x = x1; x <= x2; x++)
         {
             output(Place(x, y, z, brush));
         }
     }
 }