示例#1
0
        private Schematic Convert(List <VoxelDTO> voxels)
        {
            int minX = voxels.Min(x => x.X);
            int minY = voxels.Min(x => x.Y);
            int minZ = voxels.Min(x => x.Z);

            Schematic schematic = new Schematic();

            Console.WriteLine("[LOG] Started to write schematic from qb...");
            Console.WriteLine("[INFO] Qb Width: " + schematic.Width);
            Console.WriteLine("[INFO] Qb Length: " + schematic.Length);
            Console.WriteLine("[INFO] Qb Height: " + schematic.Height);
            using (ProgressBar progressbar = new ProgressBar())
            {
                for (var index = 0; index < voxels.Count; index++)
                {
                    VoxelDTO voxel = voxels[index];
                    voxel.X -= minX;
                    voxel.Y -= minY;
                    voxel.Z -= minZ;
                    ushort x = (ushort)voxel.X;
                    ushort y = (ushort)voxel.Y;
                    ushort z = (ushort)voxel.Z;

                    schematic.Blocks.Add(new Voxel(x, y, z, FctExtensions.ByteArrayToUInt(voxel.R, voxel.G, voxel.B, 1)));
                    progressbar.Report((index / (float)voxels.Count));
                }
            }
            Console.WriteLine("[LOG] Done.");

            return(schematic);
        }
示例#2
0
        private Schematic Convert(List <VoxelDTO> voxels)
        {
            Schematic schematic = new Schematic();
            int       minX      = voxels.Min(x => x.X);
            int       minY      = voxels.Min(x => x.Y);
            int       minZ      = voxels.Min(x => x.Z);
            int       width     = Math.Abs(voxels.Min(x => x.X) - voxels.Max(x => x.X)) + 1;
            int       length    = Math.Abs(voxels.Min(x => x.Z) - voxels.Max(x => x.Z)) + 1;
            int       height    = Math.Abs(voxels.Min(x => x.Y) - voxels.Max(x => x.Y)) + 1;

            schematic.Width  = (ushort)width;
            schematic.Heigth = (ushort)height;
            schematic.Length = (ushort)length;
            schematic.Blocks = new HashSet <Block>();

            LoadedSchematic.LengthSchematic = schematic.Length;
            LoadedSchematic.HeightSchematic = schematic.Heigth;
            LoadedSchematic.WidthSchematic  = schematic.Width;

            Console.WriteLine("[LOG] Started to write schematic from qb...");
            Console.WriteLine("[INFO] Qb Width: " + schematic.Width);
            Console.WriteLine("[INFO] Qb Length: " + schematic.Length);
            Console.WriteLine("[INFO] Qb Height: " + schematic.Heigth);
            using (ProgressBar progressbar = new ProgressBar())
            {
                for (var index = 0; index < voxels.Count; index++)
                {
                    VoxelDTO voxel = voxels[index];
                    ushort   x     = (ushort)(minX < 0 ? voxel.X + Math.Abs(minX) : voxel.X);
                    ushort   y     = (ushort)(minY < 0 ? voxel.Y + Math.Abs(minY) : voxel.Y);
                    ushort   z     = (ushort)(minZ < 0 ? voxel.Z + Math.Abs(minZ) : voxel.Z);
                    schematic.Blocks.Add(new Block(x, y, z,
                                                   FctExtensions.ByteArrayToUInt(voxel.R, voxel.G, voxel.B, voxel.A)));
                    progressbar.Report((index / (float)voxels.Count));
                }
            }
            Console.WriteLine("[LOG] Done.");

            return(schematic);
        }