Skip to content

Commit

Permalink
Added argument option "chunk-size"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarbuz committed Jan 6, 2021
1 parent fe59fcd commit 71f8479
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Install first : `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.co
--c --color enable color when generating heightmap
--cl --color-limit=VALUE set the maximal number of colors for the palette
--cm --color-from-file=VALUE load color from another file
--cs --chunk-size=VALUE set the chunk size (default: 125, min: 11, max: 255)
--e --excavate delete all voxels which doesn't have at least one face connected with air
--fl --flood fill all invisibles voxels
--flo --fix-lonely delete all voxels where all connected voxels are air
Expand Down
11 changes: 8 additions & 3 deletions SchematicToVoxCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Program
private static int _heightMap = 1;
private static int _gridSize = 126;
private static int _colorLimit = 256;
private static int _chunkSize = 125;

private const int MAX_WORLD_WIDTH = 2001;
private const int MAX_WORLD_HEIGHT = 2001;
Expand All @@ -50,6 +51,7 @@ public static void Main(string[] args)
{"c|color", "enable color when generating heightmap", v => _color = v != null},
{"cm|color-from-file=", "load colors from file", v => _inputColorFile = v },
{"cl|color-limit=", "set the maximal number of colors for the palette", (int v) => _colorLimit =v },
{"cs|chunk-size=", "set the chunk size", (int v) => _chunkSize = v},
{"e|excavate", "delete all voxels which doesn't have at least one face connected with air", v => _excavate = v != null },
{"fl|flood", "fill all invisible voxels", v => _flood = v != null },
{"flo|fix-lonely", "delete all voxels where all connected voxels are air", v => _lonely = v != null },
Expand Down Expand Up @@ -146,7 +148,8 @@ private static void CheckArguments()
throw new ArgumentException("[ERROR] --color-limit argument must be positive");
if (_colorLimit > 256)
throw new ArgumentException("[ERROR] --color-limit argument must be lower than 256");

if (_chunkSize <= 10 || _chunkSize > 255)
throw new ArgumentException("[ERROR] --chunk-size argument must be lower than 256 and greater than 10");
}

private static void DisplayArguments()
Expand All @@ -169,6 +172,8 @@ private static void DisplayArguments()
Console.WriteLine("[INFO] Specified increase size: " + _scale);
if (_gridSize != 126)
Console.WriteLine("[INFO] Specified grid size: " + _gridSize);
if (_chunkSize != 125)
Console.WriteLine("[INFO] Specified chunk size: " + _chunkSize);
if (_slow != 0)
Console.WriteLine("[INFO] Specified winding_number: " + _slow);
if (_excavate)
Expand Down Expand Up @@ -305,11 +310,11 @@ private static void SchematicToVox(AbstractToSchematic converter, string outputP
{
PaletteSchematicConverter converterPalette = new PaletteSchematicConverter(_inputPaletteFile, _colorLimit);
schematic = converterPalette.ConvertSchematic(schematic);
writer.WriteModel(outputPath + ".vox", converterPalette.GetPalette(), schematic);
writer.WriteModel(_chunkSize, outputPath + ".vox", converterPalette.GetPalette(), schematic);
}
else
{
writer.WriteModel(outputPath + ".vox", null, schematic);
writer.WriteModel(_chunkSize, outputPath + ".vox", null, schematic);
}
}

Expand Down
5 changes: 3 additions & 2 deletions SchematicToVoxCore/Vox/VoxWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public class VoxWriter : VoxParser
private List<Color> _palette;
private uint[,,] _blocks;

private const int CHUNK_SIZE = 125;
private int CHUNK_SIZE = 125;

public bool WriteModel(string absolutePath, List<Color> palette, Schematic schematic)
public bool WriteModel(int chunkSize, string absolutePath, List<Color> palette, Schematic schematic)
{
CHUNK_SIZE = chunkSize;
_width = _length = _height = _countSize = _totalBlockCount = _countRegionNonEmpty = 0;
_schematic = schematic;
_palette = palette;
Expand Down

0 comments on commit 71f8479

Please sign in to comment.