VoxelVoxLoader

Inherits: RefCounted

Utility class to load voxels from MagicaVoxel files

Methods:

Return Signature
int load_from_file ( String fpath, VoxelBuffer voxels, VoxelColorPalette palette, ChannelId dst_channel=CHANNEL_COLOR (2) ) static

Method Descriptions

int load_from_file( String fpath, VoxelBuffer voxels, VoxelColorPalette palette, ChannelId dst_channel=CHANNEL_COLOR (2) )

Loads voxels from the first model found in a vox file and stores it in a single VoxelBuffer. Other models that might be in the file are not loaded. Transform of the model is not considered.

Data will be stored in one channel of the provided buffer. 64-bit depth channel is not supported.

If palette is provided, it will also load the color palette from the file and voxels will be indices pointing into it. 8-bit channel depth is optimal (as MagicaVoxel voxels use 8-bit indices), but 16-bit and 32-bit are also supported.

If palette is not provided (null), the loader will attempt to store colors bit-packed directly into the voxels, according to the depth the provided buffer has (2-bit per component if 8-bit, 4-bit per component if 16-bit, 8-bit per component if 32-bit).

Returns an Error enum code to tell if loading succeeded or not.

Note: MagicaVoxel uses a different axis convention than Godot: X is right, Y is forwards and Z is up. Voxel coordinates will be the same when looked up in the buffer, but they mean different location in space.

Generated on Jan 26, 2026