Skip to content

A CLI tool for converting triangle meshes into voxel data binary files using VMesh

Notifications You must be signed in to change notification settings

Spatchler/VMesh-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

VMesh CLI

A CLI tool to generate voxel data from a triangle mesh using my C++ library VMesh. The tool simply outputs a binary file.

Usage:

Usage: vmesh OPTIONS input-path output-path

Options:
  -h [ --help ]                    produce help message
  -v [ --verbose ]                 verbose output
  -C [ --compressed ]              compress voxel data
  -S [ --svdag ]                   generate a Sparse Voxel DAG instead of a normal voxel grid
  -R [ --resolution ] arg (=128)   set voxel grid resolution
  --scale-mode arg (=proportional) scaling mode either (proportional, stretch, none)
  --voxel-to-svdag                 input voxel binary file and output svdag

Loading files

SVDAGs:

An SVDAG file is an array of uint32s. The first uint32 is the resolution and then from there are the indices. A value of 0 means air and a value of 1 means a solid voxel. Every value above 1 is an index for the array which you have to subtract 2 from.

Example:

// Output variables
uint32_t resolution;
std::vector<std::array<uint32_t, 8>> indices;

// Load file
std::ifstream fin;
fin.open(path, std::ios::binary | std::ios::in);

// Read resolution
fin.read(reinterpret_cast<char*>(&resolution), sizeof(uint32_t));

// Load indices
uint32_t value;
uint i = 0;
std::array<uint32_t, 8> node;
while (fin.read(reinterpret_cast<char*>(&value), sizeof(uint32_t))) {
  node[i] = value;
  ++i;
  if (i == 8) {
    indices.push_back(node);
    i = 0;
  }
}

Dependencies:

  • VMesh
  • ASSIMP
  • Boost Program Options

Build:

premake5 gmake && make

About

A CLI tool for converting triangle meshes into voxel data binary files using VMesh

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published