MagicaX.VoxParser (MagicaX v0.1.0)

View Source

A comprehensive VOX file parser for MagicaVoxel format.

Parses VOX files with 100% data coverage, handling all major chunk types: SIZE, XYZI, RGBA, MATL, LAYR, rOBJ, rCAM, NOTE, nTRN, nSHP, nGRP, META.

Returns structured data with voxels, palette, materials, layers, objects, cameras, transforms, shapes, groups, notes, and metadata.

Achieves perfect parsing with zero skipped bytes across all tested VOX files.

Examples

iex> {:ok, data} = MagicaX.VoxParser.parse_vox_file("model.vox")
iex> data.size
{32, 32, 32}

iex> length(data.voxels)
1024

Summary

Functions

Parses a .vox file and returns a map with size, voxels, palette, and matrix.

Functions

parse_vox_file(filename)

Parses a .vox file and returns a map with size, voxels, palette, and matrix.

Parameters

  • filename - Path to the VOX file to parse

Returns

  • {:ok, data} - Successfully parsed data structure
  • {:error, reason} - Parse error with description

Data Structure

The returned data contains:

  • :size - Tuple of {x, y, z} dimensions
  • :voxels - List of {x, y, z, color_index} tuples
  • :palette - List of {r, g, b, a} color tuples
  • :matrix - 3D nested map for spatial operations
  • :materials - Material definitions
  • :layers - Layer information
  • :objects - Object references
  • :cameras - Camera data
  • :transforms - Transform nodes
  • :shapes - Shape nodes
  • :groups - Group nodes
  • :notes - File notes/comments
  • :metadata - File metadata