Skip to content

A set of library classes for s&box to create runtime voxel models

License

Notifications You must be signed in to change notification settings

TankNut/sbox-voxel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbox-voxel

A set of library classes for s&box to create runtime voxel models

Installing

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

Supported formats

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

Usage

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

example.png

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

About

A set of library classes for s&box to create runtime voxel models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages