This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
combining [2024/03/31 21:34] badmin [Splitting the 3D model] |
combining [2024/04/02 15:19] (current) badmin [Merging the resulting binvox files] |
||
|---|---|---|---|
| Line 15: | Line 15: | ||
| 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. | 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: [[https://www.patrickmin.com/binvox_merge/example/puppet.obj|[puppet.obj]] and [[https://www.patrickmin.com/binvox_merge/example/heart.obj|heart.obj]] | + | The resulting files: [[https://www.patrickmin.com/binvox_merge/example/puppet.obj|puppet.obj]] and [[https://www.patrickmin.com/binvox_merge/example/heart.obj|heart.obj]] |
| ==== Voxelizing both models in the same coordinate system ==== | ==== Voxelizing both models in the same coordinate system ==== | ||
| Line 25: | Line 25: | ||
| ''binvox'' determines a model's bounding box and prints it to the terminal: | ''binvox'' determines a model's bounding box and prints it to the terminal: | ||
| + | <code> | ||
| + | # > binvox -d 128 puppet.obj | ||
| + | --- [binvox] mesh voxelizer, version 1.36, build #889 on 2023/07/23 12:28:17, running on Linux | ||
| + | ... | ||
| - | - merging the resulting binvox files | + | Mesh::normalize, bounding box: [-0.768355, -0.313688, -0.034275, 1] - [0.658711, 0.407517, 2.04301, 1] |
| - | - visualizing the merged binvox file | + | |
| + | ... | ||
| + | </code> | ||
| + | Make a note of these values, and pass them to ''binvox'' when voxelizing the heart: | ||
| + | <code> | ||
| + | # > binvox -d 128 -bb -0.768355 -0.313688 -0.034275 0.658711 0.407517 2.04301 heart.obj | ||
| + | </code> | ||
| + | |||
| + | 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 ==== | ||
| + | |||
| + | For this, the ''binvox_merge'' tool was created. It takes two binvox files as input, and produces a single binvox file: | ||
| + | <code> | ||
| + | binvox_merge heart.binvox puppet.binvox -o puppet_with_heart.binvox | ||
| + | </code> | ||
| + | |||
| + | ''binvox_merge'' simply sets an output voxel to 1 if it is set in the first input file, and to 2 if it is set in the second input file. | ||
| + | |||
| + | The output file is in the binvox **version 2** file format, which supports different values for a set voxel (in the range 1-255). | ||
| + | |||
| + | ----- | ||
| + | |||
| + | **TODO**: some explanation/options needed about what happens when a voxel is set in both input files | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ==== 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). | ||