The .vox format used in this editor is similar to RIFF format. Sample Codes is here.

The data in the file is organized in a hierarchical chunk structure. The header of the file contains :

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 contents ( n )
    4 bytes : total size of children chunks ( m )

    // chunk content
    n bytes : chunk contents

    // children chunks : m bytes
    { child chunk 0 }
    { child chunk 1 }
    ...
}
( so the total chunk size is 4 + 4 + 4 + n + m )

there are several children chunks within the root MAIN chunk :

MAIN chunk :
    id : ( 'M' 'A' 'I' 'N' )
-------------------------------------------------
SIZE chunk :
    id : ( 'S' 'I' 'Z' 'E' )
    content : ( 4 bytes x 3 : x, y, z )

VOXEL chunk :
    id : ( 'X' 'Y' 'Z' 'I' )
    content :
        ( numVoxels  : 4 bytes )
        ( each voxel : 1 byte x 4 : x, y, z, colorIndex ) x numVoxels

// NOTICE :
// 1. if Palette chunk does not exist, use default palette instead.
// 2. last color is not used ( only the first 255 colors are used ).
// 3. the first color ( at position 0 ) is corresponding to color index 1.
PALETTE chunk (optional) :
    id : ( 'R' 'G' 'B' 'A' )
    content :
        ( each pixel : 1 byte x 4 : r, g, b, a ) x 256

For the color information, you can firstly export the palette as .act file, and then read color from it :
- notice that the first valid color index of voxel is 1 ( since 0 is reserved for empty voxels )
- while the first valid color in .act file is at position 0 ( so the last color is not used )
.act :( each pixel : 1 byte x 3 : r, g, b ) x 256

NOTICE
There are also some deprecated chunk types from old version models.
Just skip them by content size and children size.

Last edited Dec 9, 2013 at 1:03 AM by glkasumi, version 20

Comments

No comments yet.