Export into a vol (or raw) file

Oct 3, 2013 at 3:37 PM
This is a very nice application for editing voxels. Thank you very much for developers.

When I save an object, it is saved in vox format.
Though I could not find any documents on the specification of vox file, it seems that the file contains 60 byte header + voxel info + 1036 byte footer. And each voxel is represented by 4 byte. (am I right?)

Usually there are empty voxels around an object (such as sphere) which is in, for example, 20x20x20 cubic space. In such a case, the empty voxels seems to be omitted in a vox file, and only voxels shaping the object are saved in the file.
Hence even I used 20x20x20 space, the file size changed depending on the shape of the object.

Now, what I want to have is a vol (or raw) file. In a vol file, the empty voxels are represented by 0 (not omitted), and voxels shaping the object are represented by 1. Apparently it looses color information.
In case of raw file, a voxel can be represented by 1 byte or other length, hence it can represent color information for each voxel. But still the empty voxels are represented by 0.
Hence in this case, the file size is constant, if the space size (such as 20x20x20) is constant, and does not change according to the shape.

These formats are also kind of standard, and convenient to utilize in other applications.

I'd like to ask developers to implement a function to export an object into vol or raw format.

Thank you for your kind consideration.
Coordinator
Oct 7, 2013 at 4:55 AM
Hi,

The .vox format is similar to RIFF format.

The data in the file is organized in a hierarchical chunk structure :
4 bytes : magic number ( 'V' 'O' 'X' 'space' )
4 bytes : version number ( current version is 150 )
{ MAIN chunk }
( all the magic number used here is big endian, for example, 'M''A''I''N', M is at 0 bytes, N is at 3 bytes )

The format for each chunk is as following :
// chunk
{
    // header
    4 bytes : chunk id
    4 bytes : size of chunk content ( n )
    4 bytes : size of children chunks 

    // chunk content
    n bytes : chunk contents

    // children chunks
    { child chunk 0 }
    { child chunk 1 }
    ...
}
there are several children chunks within the MAIN chunk :
MAIN chunk :
    id : ( 'M' 'A' 'I' 'N' )

SIZE chunk :
    id : ( 'S' 'I' 'Z' 'E' )
    content : ( 3 x 4 bytes : x, y, z )

VOXEL chunk :
    id : ( 'X' 'Y' 'Z' 'I' )
    content :
        ( numVoxels  : 4 bytes : m )
        ( each voxel : 4 bytes : x, y, z, color index ) x m
For the color information, you can export the palette as .act file, and then read color from it :
.act :( 3 bytes : r, g, b ) x 256
hope it helps^ ^
Coordinator
Jan 24, 2014 at 1:31 AM
Hi,

MagicaVoxel is now able to import and export a very simple raw volume data format called [XRAW Format]

Hope it helps:)