gromgull / py-vox-io

Python module for parsing and writing MagicaVoxel vox file
MIT License
102 stars 26 forks source link

Limitation on VoxWriter when the size of the array to write reaches a critical size #8

Closed andrewrgarcia closed 3 years ago

andrewrgarcia commented 3 years ago

Just wanted to bring up this bug / limitation. After tensors go beyond 255 lengths in all 3 dimensions i.e. tensor.shape > (255,255,255) and the VoxWriter call is run (VoxWriter(save_file, vox).write()) this error is produced:

pyvox/writer.py", line 48, in <genexpr>
    chunks.append((b'XYZI', pack('i', len(m.voxels)) + b''.join(pack('BBBB', *v) for v in m.voxels)))

error: ubyte format requires 0 <= number <= 255

I was wondering if there is a way to circumvent this issue or should we just resize the array to a smaller size

gromgull commented 3 years ago

Looking at the format docs: https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt#L79

Those B's are indeed bytes. I know Magicavoxel allows WORLDS larger than 256, but I believe this is solved by having a larger world, but each model is max 256x256x256

You don't have much choice apart from using a smaller array.