User Tools

Site Tools


combining

This is an old revision of the document!


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 this 3D model on Sketchfab 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]
  
...

Make a note of these values, and pass them to binvox when voxelizing the heart:

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

I will update binvox such that it prints these -bb parameters so they can be copied and pasted.

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

Visualising the merged binvox file

combining.1711917703.txt.gz · Last modified: 2024/03/31 21:41 by badmin