Function dot_vox::load [] [src]

pub fn load(filename: &str) -> Result<DotVoxData, &'static str>

Loads the supplied MagicaVoxel .vox file

Loads the supplied file, parses it, and returns a DotVoxData containing the version of the MagicaVoxel file, a Vec<Model> containing all Models contained within the file, a Vec<u32> containing the pallete information (RGBA), and a Vec<Material> containing all the specialized materials.

Panics

No panics should occur with this library - if you find one, please raise a GitHub issue for it.

Errors

All errors are strings, and should describe the issue that caused them to occur.

Examples

Loading a file:

use dot_vox::*;

let result = load("src/resources/placeholder.vox");
assert_eq!(result.unwrap(), DotVoxData {
  version: 150,
  models: vec!(
    Model {
      size: Size { x: 2, y: 2, z: 2 },
      voxels: vec!(
        Voxel { x: 0, y: 0, z: 0, i: 226 },
        Voxel { x: 0, y: 1, z: 1, i: 216 },
        Voxel { x: 1, y: 0, z: 1, i: 236 },
        Voxel { x: 1, y: 1, z: 0, i: 6 }
      )
    }
  ),
  pallete: DEFAULT_PALLETE.to_vec(),
  materials: vec![],
});