Example #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("[INFO] 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.AddVoxel(x, y, z, FctExtensions.ByteArrayToUInt(voxel.R, voxel.G, voxel.B, 1));
                    progressbar.Report((index / (float)voxels.Count));
                }
            }
            Console.WriteLine("[INFO] Done.");

            return(schematic);
        }
Example #2
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);

            int maxX = voxels.Max(x => x.X);
            int maxY = voxels.Max(x => x.Y);
            int maxZ = voxels.Max(x => x.Z);

            Schematic schematic = new Schematic
            {
                Length = (ushort)(Math.Abs(maxZ - minZ) + 1),
                Width  = (ushort)(Math.Abs(maxX - minX) + 1),
                Height = (ushort)(Math.Abs(maxY - minY) + 1),
                Blocks = new HashSet <Block>()
            };

            LoadedSchematic.LengthSchematic = schematic.Length;
            LoadedSchematic.HeightSchematic = schematic.Height;
            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.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 Block(x, y, z, FctExtensions.ByteArrayToUInt(voxel.R, voxel.G, voxel.B, 1)));
                    progressbar.Report((index / (float)voxels.Count));
                }
            }
            Console.WriteLine("[LOG] Done.");

            return(schematic);
        }
Example #3
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  = (short)width;
            schematic.Heigth = (short)height;
            schematic.Length = (short)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];
                    short    x     = (short)(minX < 0 ? voxel.X + Math.Abs(minX) : voxel.X);
                    short    y     = (short)(minY < 0 ? voxel.Y + Math.Abs(minY) : voxel.Y);
                    short    z     = (short)(minZ < 0 ? voxel.Z + Math.Abs(minZ) : voxel.Z);
                    schematic.Blocks.Add(new Block(x, y, z,
                                                   Extensions.ByteArrayToUInt(voxel.R, voxel.G, voxel.B, voxel.A)));
                    progressbar.Report((index / (float)voxels.Count));
                }
            }
            Console.WriteLine("[LOG] Done.");

            return(schematic);
        }