├── .gitignore
├── LICENSE
├── README.md
├── VoxSlicer.sln
├── VoxSlicerCore
├── Program.cs
├── Properties
│ ├── PublishProfiles
│ │ ├── FolderProfile.pubxml
│ │ └── FolderProfile.pubxml.user
│ └── launchSettings.json
├── VoxSlicerCore.csproj
└── VoxSlicerCore.csproj.user
└── img
├── img0.png
├── img1.png
└── img2.png
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | VoxSlicer/bin/
3 | VoxSlicer/obj/
4 | VoxSlicerCore/obj/
5 | VoxSlicerCore/bin/
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Nicolas Perrier
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VoxSlicer
2 | Slice a MagicaVoxel project into smaller volumes.
3 |
4 | ## Usage:
5 |
6 | `VoxSlicer.exe SIZE FILE`
7 |
8 | - SLICE represent the volume size of the exported regions. (Max 256)
9 | - FILE the .vox file to process:
10 |
11 | Example :
12 |
13 | `VoxSlicer.exe 32 myfile.vox`
14 |
15 | Before process:
16 |
17 | 
18 |
19 | After process:
20 |
21 | 
22 | 
23 |
--------------------------------------------------------------------------------
/VoxSlicer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.28822.285
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoxSlicerCore", "VoxSlicerCore\VoxSlicerCore.csproj", "{D7941860-9A84-4F12-B1AC-4AC5080651F9}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D7941860-9A84-4F12-B1AC-4AC5080651F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D7941860-9A84-4F12-B1AC-4AC5080651F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D7941860-9A84-4F12-B1AC-4AC5080651F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D7941860-9A84-4F12-B1AC-4AC5080651F9}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {F9A94362-D4E1-4CC5-A79A-252C2B0C41CE}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/VoxSlicerCore/Program.cs:
--------------------------------------------------------------------------------
1 | using FileToVoxCore.Schematics;
2 | using FileToVoxCore.Vox;
3 | using System;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Reflection;
8 |
9 | namespace VoxSlicerCore
10 | {
11 | class Program
12 | {
13 | static void Main(string[] args)
14 | {
15 | VoxReader reader = new VoxReader();
16 | VoxWriter writer = new VoxWriter();
17 |
18 | DisplayInformations();
19 |
20 | if (args.Length < 2)
21 | {
22 | Console.WriteLine("[ERROR] Missing arguments");
23 | Console.WriteLine("Usage: VoxSlicer.exe SIZE FILE");
24 | return;
25 | }
26 |
27 | try
28 | {
29 | short size = Convert.ToInt16(args[0]);
30 | if (size <= 10 || size > 256)
31 | {
32 | Console.WriteLine("[ERROR] Size must be between 10 and 256");
33 | return;
34 | }
35 |
36 | VoxModel model = reader.LoadModel(args[1]);
37 |
38 | if (model == null)
39 | {
40 | Console.WriteLine("[ERROR] Failed to load model");
41 | return;
42 | }
43 |
44 | Schematic.CHUNK_SIZE = size;
45 | DirectoryInfo directory = Directory.CreateDirectory(Path.GetFileNameWithoutExtension(args[1]));
46 | foreach (VoxelData data in model.VoxelFrames)
47 | {
48 | int sizeX = (int)Math.Ceiling((decimal)data.VoxelsWide / size);
49 | int sizeY = (int)Math.Ceiling((decimal)data.VoxelsTall / size);
50 | int sizeZ = (int)Math.Ceiling((decimal)data.VoxelsDeep / size);
51 |
52 | Schematic[,,] schematics = new Schematic[sizeX, sizeY, sizeZ];
53 | Color[] colors = model.Palette;
54 | for (int y = 0; y < data.VoxelsTall; y++)
55 | {
56 | for (int z = 0; z < data.VoxelsDeep; z++)
57 | {
58 | for (int x = 0; x < data.VoxelsWide; x++)
59 | {
60 | int posX = x / size;
61 | int posY = y / size;
62 | int posZ = z / size;
63 |
64 | schematics[posX, posY, posZ] ??= new Schematic();
65 | int indexColor = data.Get(x, y, z);
66 | Color color = colors[indexColor];
67 |
68 | if (indexColor != 0)
69 | {
70 | schematics[posX, posY, posZ].AddVoxel(x, y, z, color);
71 | }
72 | }
73 | }
74 | }
75 |
76 | for (int x = 0; x < schematics.GetLength(0); x++)
77 | {
78 | for (int y = 0; y < schematics.GetLength(1); y++)
79 | {
80 | for (int z = 0; z < schematics.GetLength(2); z++)
81 | {
82 | if (schematics[x, y, z].GetAllVoxels().Count != 0)
83 | {
84 | var rotation = model.TransformNodeChunks.First().RotationAt();
85 | string name = $"{Path.GetFileNameWithoutExtension(args[1])}-{x}-{y}-{z}.vox";
86 | Console.WriteLine("[INFO] Started to process: " + name);
87 | string outputPath = Path.Combine(directory.FullName, name);
88 | writer.WriteModel(size, outputPath, model.Palette.ToList(), schematics[x, y, z], rotation);
89 | }
90 | }
91 | }
92 | }
93 | }
94 | }
95 | catch (Exception)
96 | {
97 | Console.WriteLine("[ERROR] Failed to read voxel volume size");
98 | }
99 | }
100 |
101 | private static void DisplayInformations()
102 | {
103 | Console.WriteLine("[INFO] VoxSlicer v" + Assembly.GetExecutingAssembly().GetName().Version);
104 | Console.WriteLine("[INFO] Author: @Zarbuz. Contact : https://twitter.com/Zarbuz");
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/VoxSlicerCore/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | bin\publish\
10 | FileSystem
11 | net5.0
12 | win-x86
13 | true
14 | True
15 | True
16 | True
17 |
18 |
--------------------------------------------------------------------------------
/VoxSlicerCore/Properties/PublishProfiles/FolderProfile.pubxml.user:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/VoxSlicerCore/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "VoxSlicerCore": {
4 | "commandName": "Project",
5 | "commandLineArgs": "32 apeslice.vox"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/VoxSlicerCore/VoxSlicerCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 | 0.0.4.0
7 | 0.0.4
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/VoxSlicerCore/VoxSlicerCore.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <_LastSelectedProfileId>E:\Documents\VoxSlicer\VoxSlicerCore\Properties\PublishProfiles\FolderProfile.pubxml
5 |
6 |
--------------------------------------------------------------------------------
/img/img0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zarbuz/VoxSlicer/b1d5cd36df19cf4a166c5a10a18b98ab6efe6834/img/img0.png
--------------------------------------------------------------------------------
/img/img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zarbuz/VoxSlicer/b1d5cd36df19cf4a166c5a10a18b98ab6efe6834/img/img1.png
--------------------------------------------------------------------------------
/img/img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zarbuz/VoxSlicer/b1d5cd36df19cf4a166c5a10a18b98ab6efe6834/img/img2.png
--------------------------------------------------------------------------------