User Tools

Site Tools


editing_voxels

Programming::Editing Voxel Data

Voxel Data Storage

Chunk Stories makes use of a hierarchical model for it's voxel storage. A World contains many Regions, a Region is made out of 8x8x8 Chunks, themselves made out of 32x32x32 Cells. Cells are what voxels are stored in. The Voxel class in the codebase actually refers to the idea of voxel type, be aware of that !

The base CellData interface exposes two things:

  • A Location, ie a 4-uple (world, x, y, z)
  • The data associated with this location ( more detail here )
    • The voxel type: an instance of the 'Voxel.class' class.
    • Two 4-bit nibbles : sunlight and blocklight, representing the voxel flood-fill lightning values
    • A byte (8 bits) of metadata

It is recommanded to use Cells rather than directly using 'raw' cell data and unstable voxel ids.

  • CellData: base interface.
    • WorldCell: Associated with a real World, getWorld() guaranteed not to return null. If corresponding chunks are loaded, getNeighbor functions will work.
      • ChunkCell: Associated with a real, loaded chunk.
    • EditableCell: Additional interface editing the voxel data it represents
      • FutureCell: Describes future changes you wish to make to a cell
      • DummyCell: Describe a voxel cell outside of any real world (without context if you will)

Peek types and what they mean

Name Arguments Return Throws Exceptions
world.peek() int x, int y, int z ChunkCell Yes
world.peek() Vector3dc location ChunkCell Yes
world.peekSafely() int x, int y, int z WorldCell No
world.peekSafely() Vector3dc location WorldCell No
world.peekSimple() int x, int y, int z Voxel No
world.peekRaw() int x, int y, int z int No
chunk.peek() int x, int y, int z ChunkCell No
chunk.peek() Vector3dc location ChunkCell No
chunk.peekSimple() int x, int y, int z Voxel No
chunk.peekRaw() int x, int y, int z int No

Poke types and what they mean

Name Arguments Return Triggers Updates Throws Exceptions
world.poke() x, y, z, voxel, sunlight, blocklight, metadata, cause CellData Yes Yes
world.poke() futureCell, cause CellData Yes Yes
world.pokeSimple() x, y, z, voxel, sunlight, blocklight, metadata void Yes No
world.pokeSimple() futureCell void Yes No
world.pokeSimpleSilently() x, y, z, voxel, sunlight, blocklight, metadata void No No
world.pokeSimpleSilently() futureCell void No No
world.pokeRaw() x, y, z, raw_data_bits void Yes No
world.pokeRawSilently() x, y, z, raw_data_bits void No No
chunk.poke() x, y, z, voxel, sunlight, blocklight, metadata, cause CellData Yes Yes
chunk.pokeSimple() x, y, z, voxel, sunlight, blocklight, metadata void Yes No
chunk.pokeSimpleSilently() x, y, z, voxel, sunlight, blocklight, metadata void No No
chunk.pokeRaw() x, y, z, raw_data_bits void Yes No
chunk.pokeRawSilently() x, y, z, raw_data_bits void No No
editing_voxels.txt · Last modified: 2018/02/10 23:52 by gobrosse