Save-game file format (Voxel Play 3)

Modified on Thu, 20 Feb at 5:00 PM

Current format version: 16.


Game can be saved either by scripting or using the console command /save.

The file format is binary. Chunk data is RLE compressed to reduce redundant data. Custom data sections are compressed using Deflate algorithm.


In version 16, Voxel Play stores world/game data in 3 files:

- main file containing header data as well as a list of the names of region files.

- one or more region files containing chunk & voxel data.

- an extra datafile containing gameobject data and custom sections data.


When the contents of the world are modified, only the affected region file is updated.


Header datafile structure


Byte PosLengthTypeDescription
01ByteFile format number
11ByteChunk size (16 or 32)
14FloatPosition x of the character controller
54FloatPosition y of the character controller
94FloatPosition z of the character controller
134FloatCharacter controller’s transform.eulerAngles.x
174FloatCharacter controller’s transform.eulerAngles.y
214FloatCharacter controller’s transform.eulerAngles.z
254FloatCamera’s transform.eulerAngles.x
294FloatCamera’s transform.eulerAngles.y
334FloatCamera’s transform.eulerAngles.z
37
2
Int
Stage number
39Variable
StringIds of the regions included in the stage


Region datafile format


Byte PosLengthTypeDescription
0
2
Int16
Number of voxel definitions
2
VariableStringsNames of each voxel definition (list)
??
2Int16Number of item definitions

VariableStringsNames of each item definition (list) - this includes the item definitions for torches

4IntNumber of chunks
START OF CHUNK
 4FloatPosition x of the chunk
 4FloatPosition y of the chunk
 4FloatPosition z of the chunk

1ByteIf this chunk has some voxels above terrain surface (1) or not (0). Used for computing lightmap when neighbour chunks do not exist (yet). Above surface chunks assume Sun light from above. Chunks below surface won't receive Sun light from above if there's no chunk on top.

1
Byte
1 if the chunk is completely generated. 0 if the chunk was modified after calling GetChunkUnpopulated() method but the terrain generator has not yet filled the chunk with contents.
 2Int16Number of words
FOR EACH VOXEL REPETITION ("WORD")...

2Int16Index of the voxel definition list
 1ByteVoxel color (R) (0-255)
 1ByteVoxel color (G) (0-255)
 1ByteVoxel color (B) (0-255)
 2Int16Start index of the voxel repetition
 2Int16Repetitions
 1ByteIf voxel is of transparent type or 6-textures opaque type, a flags byte with info with water level and/or voxel texture rotation info. "0" otherwise
...END VOXEL REPETITION

2Int16Number of torches or light sources
FOR EACH LIGHT SOURCE...
 2Int16Index of the voxel within the chunk where the light source is
 4FloatNormal.x (used to determine the face of the voxel where the light source is attached)
 4FloatNormal.y
 4FloatNormal.z

2Int16Index of the item definition for the torch in the header list
...END OF LIGHT SOURCES SECTION

2Int16Number of items in the chunk
FOR EACH ITEM

2Int16Index of the item definition in the header list

4FloatPosition x of the item

4FloatPosition y of the item

4FloatPosition z of the item

4
FloatQuantity
...END OF ITEMS SECTION

2Int16Number of voxels in this chunk with custom data
FOR EACH VOXEL WITH CUSTOM DATA...

2Int16Index of voxel in the chunk

2Int16Number of custom properties

4IntProperty Id

4FloatFloat value

??StringString value
...END OF PER VOXEL CUSTOM DATA SECTION
END OF CHUNK

2Int16Number of voxels with microvoxels in the chunk
FOR EACH VOXEL WITH MICROVOXELS...

2Int16Index of the voxel in the chunk
8UInt64Entries of UInt64 containing the occupancy mask of the microvoxels (actual amount depends on the resolution of microvoxels defined in the Voxel Play Environment - this value should be set and not changed).


Extra datafile format:


Byte PosLengthTypeDescription
 2Int16Number of gameobjects with "VoxelPlaySaveThis" component
FOR EACH GAMEOBJECT...


StringPath for the prefab from a Resources folder (ie. "MyPrefabs/thisprefab" where MyPrefabs is a folder inside Resources folder)


StringName of the gameobject

4FloatPosition x

4FloatPosition y

4FloatPosition z

4FloatRotation angle x

4FloatRotation angle y

4FloatRotation angle z

4FloatScale x

4FloatScale y

4FloatScale z

2Int16Number of custom data values
PER EACH GAMEOBJECT DATA VALUE


StringKey


StringValue
END OF DATA VALUE
END OF GAMEOBJECT



2Int16Number of custom data sections
PER EACH CUSTOM DATA SECTION


StringKey


Int16Length of byte array


Byte[]Data contents
END OF CUSTOM DATA SECTION


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article