A set of library classes for s&box to create runtime voxel models
Merge the files with your gamemode however you want, for developing I have the two voxel folders symlinked into my local copy of facepunch/sandbox
Format | File Signature | Extension | Notes |
---|---|---|---|
Voxlap | "Kvxl" | .kv6 | |
MagicaVoxel | "VOX " | .vox | Only RGBA, SIZE and XYZI chunks are handled, multiple XYZI chunks should work but haven't been tested |
Models can be manually built and registered through the following method:
VoxelBuilder builder = new();
builder.Set( 0, 0, 0, new Color( 1, 0, 0 ) );
builder.Set( 1, 0, 0, new Color( 1, 0, 0 ) );
builder.Set( 0, 1, 0, new Color( 0, 1, 0 ) );
builder.Set( 1, 1, 0, new Color( 0, 1, 0 ) );
builder.Set( 0, 0, 10, new Color( 0, 0, 1 ) );
builder.Set( 1, 0, 10, new Color( 0, 0, 1 ) );
builder.Set( 0, 1, 10, new Color( 0, 0, 1 ) );
builder.Set( 1, 1, 10, new Color( 0, 0, 1 ) );
VoxelManager.RegisterModel("test", builder.Build());
This will result in the following prop when spawned with spawn_voxel test 8
If you want to load external files you can use one of the existing importers or create your own by implementing IVoxelLoader
into your class and registering it through VoxelManager.RegisterLoader(string signature, IVoxelLoader loader)
, after that you'll be able to load your models through any of the VoxelManager.LoadFrom*
functions