midstreeeam / MidVoxIO

A python io to load/write/visualize vox files (MagicalVoxel's .vox format).
MIT License
23 stars 4 forks source link

What about a object over 256×256×256 #5

Open boringfish opened 9 months ago

boringfish commented 9 months ago

Hi, Thank you for your great work! I am trying to use a big object (for example, 1024×1024×1024. It is transformed from .obj format) in magicavoxel, like that,

image

When I exported it as .vox and used MidVoxIO to parse it, I found that MidVoxIO can only show a part of it (256×256×256). So How can I handle big .vox object? Here attached the .vox I used: bunny-vox.zip

midstreeeam commented 9 months ago

@boringfish According to MagicaVoxel's document for vox format, they only use 1 byte to store the location of a voxel.

6. Chunk id 'XYZI' : model voxels, paired with the SIZE chunk
-------------------------------------------------------------------------------
# Bytes  | Type       | Value
-------------------------------------------------------------------------------
4        | int        | numVoxels (N)
4 x N    | int        | (x, y, z, colorIndex) : 1 byte for each component
-------------------------------------------------------------------------------

It means that a single model can not be bigger than 256×256×256.

For larger models, usually it is treated as multiple models and is combined together. (Like your bunny example)

For multiple models in one single vox file, you can try to use vox_to_arr('bunny.vox',-1) to get the python array of the combined model. You can replace -1 with other number to get a specific part of the larger model.

To be noticed, the tool is not designed to work with super large models. For larger files, parsing can be slow, and viz_vox() might not work.