예제 #1
0
        void OutputPixels(PixelGetter pixels, DrawOpOutput output)
        {
            int width = pixels.Width, height = pixels.Height;
            int srcY = height - 1; // need to flip coords in bitmap vertically

            for (int yy = 0; yy < height; yy++, srcY--)
            {
                for (int xx = 0; xx < width; xx++)
                {
                    Pixel  P = pixels.Get(xx, srcY);
                    ushort x = (ushort)(Origin.X + dx.X * xx + dy.X * yy);
                    ushort y = (ushort)(Origin.Y + dx.Y * xx + dy.Y * yy);
                    ushort z = (ushort)(Origin.Z + dx.Z * xx + dy.Z * yy);
                    if (P.A < 20)
                    {
                        output(Place(x, y, z, Block.Air)); continue;
                    }

                    BlockID block;
                    if (!DualLayer)
                    {
                        block = selector.BestMatch(P.R, P.G, P.B);
                    }
                    else
                    {
                        bool backLayer;
                        block = selector.BestMatch(P.R, P.G, P.B, out backLayer);
                        if (backLayer)
                        {
                            x = (ushort)(x + adj.X);
                            z = (ushort)(z + adj.Z);
                        }
                    }
                    output(Place(x, y, z, block));
                }
            }
        }
예제 #2
0
        void OutputPixels(PixelGetter pixels, DrawOpOutput output)
        {
            int width = pixels.Width, height = pixels.Height;

            for (int yy = 0; yy < height; yy++)
            {
                for (int xx = 0; xx < width; xx++)
                {
                    Pixel  P = pixels.Get(xx, yy);
                    ushort x = (ushort)(Origin.X + dx.X * xx + dy.X * yy);
                    ushort y = (ushort)(Origin.Y + dx.Y * xx + dy.Y * yy);
                    ushort z = (ushort)(Origin.Z + dx.Z * xx + dy.Z * yy);
                    if (P.A < 20)
                    {
                        output(Place(x, y, z, ExtBlock.Air)); continue;
                    }

                    byte raw = 0;
                    if (!DualLayer)
                    {
                        raw = selector.BestMatch(P.R, P.G, P.B);
                    }
                    else
                    {
                        bool backLayer;
                        raw = selector.BestMatch(P.R, P.G, P.B, out backLayer);
                        if (backLayer)
                        {
                            x = (ushort)(x + adj.X);
                            z = (ushort)(z + adj.Z);
                        }
                    }
                    output(Place(x, y, z, ExtBlock.FromRaw(raw)));
                }
            }
        }