Table of Contents

Combining (merging) multiple models into a single .binvox file

This is a fairly popular use case, for which I had promised to write a tutorial many years ago.. :-|

An example 3D model with multiple components

I constructed the example from a model on Sketchfab (since deleted) and a sphere, combined using the blender 3D modeller (https://www.blender.org):

Splitting the 3D model

In blender I selected the “heart” sphere, deleted it, and saved the puppet as an .obj file (File → Export → Wavefront (.obj), then select Z as the up axis). Next, Edit → Undo, and the same step to save the sphere to an .obj file.

The resulting files: puppet.obj and heart.obj

Voxelizing both models in the same coordinate system

The goal is to voxelize them such that after merging they end up in the same spot relative to each other.

For this we need to determine the smallest bounding box that contains both models. Since in our example the “heart” is inside the body, we can use the bounding box of the puppet.

binvox determines a model's bounding box and prints it to the terminal:

# > binvox -d 128 puppet.obj

--- [binvox] mesh voxelizer, version 1.36, build #889 on 2023/07/23 12:28:17, running on Linux

...

  Mesh::normalize, bounding box: [-0.768355, -0.313688, -0.034275, 1] - [0.658711, 0.407517, 2.04301, 1]
...
mesh bounding box as binvox parameter:
  -bb -0.768355 -0.313688 -0.034275 0.658711 0.407517 2.04301
  
...

Copy and paste the line with '-bb', and pass it to binvox when voxelizing the heart:

# > binvox -d 128 -bb -0.768355 -0.313688 -0.034275 0.658711 0.407517 2.04301 heart.obj

Now both models have been voxelized such that they can be merged, and be the same relative size and in the same relative position.

Merging the resulting binvox files

For this, the binvox_merge tool was created. It takes two binvox files as input, and produces a single binvox file:

binvox_merge heart.binvox puppet.binvox -o puppet_with_heart.binvox

binvox_merge simply sets an output voxel to 1 if it is set in either input file. Because the voxel models overlap, you could run binvox_merge like this instead:

binvox_merge heart.binvox puppet.binvox -ov 2 -o puppet_with_heart.binvox

so the overlapping values get set to 2.

The output file is in the binvox version 2 file format, which supports different values for a set voxel (in the range 1-255).


Visualising the merged binvox file

viewvox (from version 0.51 onwards) supports viewing this new binvox version 2 file format.

A useful new feature is the ability to toggle “point rendering” of each input component, using the number keys 1 through 9 (so in our example only keys 1 and 2 are useful).

Note that typically you want to see all the voxels, so call viewvox with the -ki parameter (keep internal voxels).


Combining more than two binvox models

In version 0.2 (Sept. 2026) the -map parameter was added, which gives you more control over which input values map to which output values. This is useful when you want to merge more than two binvox models, and keep the output values distinct.


Voxelize the largest model to find the reference coordinate system

We will first create a voxel of the “skin” (outer layer) of the puppet:

# -> ../binvox -d 128 -ri puppet.obj

--- [binvox] mesh voxelizer, version 1.39, build #918 on 2025/11/16 17:30:30, running on Linux
--- written by Patrick Min, 2004-2025

  will remove internal voxels
  
parameter string [ -d 128 -ri puppet.obj]
...
  mesh bounding box as binvox parameter:
  -bb -0.061142 0.006028 -0.709564 0.741424 2.11964 0.7046
...

You can verify that only the boundary was voxelized by running viewvox -ki puppet.binvox, and toggling “single layer display” by pressing s: the -ki parameter was passed to viewvox (“keep internal voxels”), but you can see only the boundary has voxels:


Voxelize the remaining models in the same coordinate system

Next, voxelize the three “organ objects” with the same bounding box (and same voxel resolution of course):

binvox -d 128 -bb -0.061142 0.006028 -0.709564 0.741424 2.11964 0.7046 stomach.obj
binvox -d 128 -bb -0.061142 0.006028 -0.709564 0.741424 2.11964 0.7046 heart.obj
binvox -d 128 -bb -0.061142 0.006028 -0.709564 0.741424 2.11964 0.7046 brain.obj

Merge two pairs

You can now, for example, merge them in pairs (e.g. puppet_brain.binvox and heart_stomach.binvox), and then merge those:

binvox_merge puppet.binvox brain.binvox -map 1:1 1:2 -o puppet_brain.binvox
binvox_merge heart.binvox stomach.binvox -map 1:1 1:2 -o heart_stomach.binvox

Note the -map 1:1 1:2 parameter to make sure the source models get different voxel values in the output models.


Merge resulting merged pairs to a single model

And now to merge these two:

binvox_merge puppet_brain.binvox heart_stomach.binvox -map 1:1,2:2 1:3,2:5 -o all.binvox

(I picked 5 as the voxel value for the stomach, because the viewvox colour of value 4 is not very different from that of value 3 ..) (so an idea is to add user-specified palettes to viewvox :-) ).

Then running viewvox -ki all.binvox (and pressing '1' to get the “fake transparency”):