Chunks
intermediate conceptsVoxel Play 4 · World Architecture
Imagine the world is divided in a 3D grid of 16x16x16 voxels (or optionally 32x32x32, this can be configured in Voxel Play Environment inspector). Each group of 16x16x16 voxels is called a "chunk" in Voxel Play 4.
Chunks are positioned at integer locations. So the first chunk starts at 0,0,0. The right chunk starts at X=16, Y=0, Z=0. The left chunk starts at X=-16. Same for Y and Z directions.
In C#, each chunk is represented by a VoxelChunk object. You can get any chunk from the world calling GetChunk() methods (see the API for available methods). Each chunk object provides several properties and a link to the neighbor chunk. Usually these properties are only used by the engine but if you're curious about them, they're fully commented in the source.
In Voxel Play 4 the block of 16x16x16 voxels is stored as a linear array of 16x16x16 length (4K per chunk).
Contents of a chunks are stored in a linear array of voxels (Voxel[] voxels]. The position of each voxel inside the array can be calculated using the formula:
arrayIndex = Y * (16*16) + Z * 16 + X;
Some methods in Voxel Play 4 allow you to use a 3-dimensional array (ie. [4,9,7]). In this case the order is [y,z,x].
The VoxelChunk class contains the chunk data in Voxel Play 4. Check the VoxelChunk page for more details.
Suggest an improvement
Help us improve this documentation page.