Skip to content

Reads and parses Magicavoxel .vox files into a nice data structure. Can handle the .vox file extensions for larger models.

License

Notifications You must be signed in to change notification settings

SteveSmith16384/VoxFileParser

Repository files navigation

VOX FILE PARSER

Reads in a .vox file and creates a data structure. Can handle files created with the latest version of Magicavoxel, i.e. can handle very large multi-model scenes.

Also implements minimal functionality of writing out the structure back to a .vox file.

Reading usage:

try (VoxReader reader = new VoxReader(new FileInputStream(filename))) {
    VoxFile voxFile = reader.read();
    
    for (VoxModelInstance model_instance : voxFile.getModelInstances()) {
        GridPoint3 world_Offset = model_instance.world_offset;
        VoxModelBlueprint model = model_instance.model;
        for (Voxel voxel : model.getVoxels()) {
            int x = world_Offset.x + voxel.getPosition().x;
            int y = world_Offset.y + voxel.getPosition().y;
            int z = world_Offset.z + voxel.getPosition().z;
            
            // Do stuff with the data 
        }
    }
}

Writing usage:

See CreateNewFileTest

Expected result:

Notes

  • Any "rotation" settings are ignored.
  • Magicavoxel treats the Z axis as up/down.

Licence

MIT Licence. See included LICENCE file.

Credits

About

Reads and parses Magicavoxel .vox files into a nice data structure. Can handle the .vox file extensions for larger models.

Topics

Resources

License

Stars

Watchers

Forks

Languages