Chunks

Modified on Tue, 04 Aug 2020 at 11:31 AM

Imagine the world is divided in a 3D grid of 16x16x16 voxels. Each cell of that grid is called a "chunk" in Voxel Play.

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 neighbour 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 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 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. Check the VoxelChunk page for more details.


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 atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article