BloxxDev
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Maybe useful stuff

Go down

Maybe useful stuff Empty Maybe useful stuff

Post by Barada Wed Feb 25, 2015 7:51 pm

https://voxel.codeplex.com/discussions/461060

The .vox format is similar to RIFF format. 

The data in the file is organized in a hierarchical chunk structure :
Code:
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 :
Code:
// 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 :
Code:
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 :
Code:
.act :( 3 bytes : r, g, b ) x 256
Barada
Barada
Admin

Posts : 13
Join date : 2015-01-16
Age : 46
Location : Uk

http://jrowney.wix.com/portfolio

Back to top Go down

Maybe useful stuff Empty Re: Maybe useful stuff

Post by Barada Wed Feb 25, 2015 7:55 pm

https://voxel.codeplex.com/wikipage?title=XRAW%20Format

XRAW is a simple format designed for raw image or volume data for both RGBA and palette index color mode.

Though it can be used for general volume/image data representation, here we only use one of the many possible combinations.


It includes three sections : header ( 24 bytes ), voxel buffer, palette buffer

- integer is stored as little endian

[th]# bytes[/th][th]description[/th][th]value[/th][th]ext. ( NOT used here )[/th]
4magic number"XRAW" : X is at 0 byte
1channel data type0 : unsigned integer1: signed integer 2 : float
1# channels4 : RGBA : R is at 0 byte3, 2, 1 : RGB, RG, R
1# bits per channel8 : unsigned byte1, 16, 32, 64
1# bits per index8 : unsigned byte0, 16
4volume size x
4volume size y
4volume size z
4# palette colors256
-end of header
#Vvoxel buffervoxels
#Ppalette buffercolors



some calculations :

1. #voxels = sizex * sizey * sizez;

2. voxel offset = x + y * sizex + z * sizex * sizezy;

3. #V = #voxels *
#bitsPerChannel * #channels / 8 ( if #bitsPerIndex == 0 );
#bitsPerIndex / 8 ( otherwise );

4. #P = #bitsPerIndex * #paletteColors;
Barada
Barada
Admin

Posts : 13
Join date : 2015-01-16
Age : 46
Location : Uk

http://jrowney.wix.com/portfolio

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum