converting 3D models for building in minecraft using [binvox] and [viewvox] |
binvox viewvox
(if you're looking for a free 3D model converter, try meshconv)
|
Introductionbinvox and viewvox can be of help when trying to build a voxelized version of a 3D mesh in minecraft.Executables are available for Linux, Mac OS X, and Windows. Do send me screenshots of the models you have built! Click on the image on the right to see the gallery in the picasa web album binvox/viewvox for minecraft.
Note to Windows users: binvox and viewvox are commandline tools,
which means they must be run from a command shell. In Windows, start a command shell
with Start → Run → cmd (enter), then use the cd command to change
to the folder where you have binvox.exe, viewvox.exe, and the model you want to
convert. Send me a note if anything is unclear.
Eric Haines wrote a good
step-by-step tutorial for Windows users,
and has created a
quickstart package
of all software needed for Windows (including two sample models).
Here is a
tutorial in German (Tutorial auf Deutsch).
(I've had one report from a Windows user where the downloaded binvox and viewvox files had to be renamed to binvox.exe and viewvox.exe)
Note to Mac users: the same goes for the Mac, you should run binvox and viewvox from
the Terminal: after downloading them into the same folder as your model, do:
Here is a Mac tutorial, written by Manic Miner. If you have questions about how to use the Terminal app, please search Google for "mac os x using terminal".
Note to Linux users: I assume you're familiar with the commandline :-) (but do send me a note if something is unclear)
ProcessAssume we have a 3D model like the one at the top left, in a file mug.wrl.
Step 1: voxelize itRun:./binvox -d 32 -c mug.wrl which will create a file mug.binvox.
View the result with viewvox:
In viewvox, the x axis is red, the y axis green, and the z
axis blue.
Some models (like this one) use the z axis as the up axis, whereas viewvox
uses the y axis. You can fix this by passing -rotx parameter to binvox,
which makes it rotate the object by 90 degrees counter-clockwise around the x axis,
effectively changing the up axis from z to y:
If your model has no thin features, you can skip this section.
If the model has thin features that are lost in the voxelization, you may want to voxelize
at a higher resolution and downsample:
If the model has features with zero width (e.g. a single triangle/quad/etc.), you could use
both the -aw option ("add wireframe"), which also renders the model in wireframe
(only when carving), which does render zero width triangles seen from the side, and
-dc ("dilated carving"), which doesn't carve away as much (the carving stops one
voxel before the intersection), for example: How to voxelize only part of the model
Suppose you have a model of a gargoyle, and you want to voxelize just the head:
You can see from the axes in the image that this means we need to limit the voxelization in the z direction.
You can crop the rendering of binvox with the -bb parameter, noting that your model will always be in the
unit cube (i.e. the cube from (0, 0, 0) to (1, 1, 1)).
Examine the whole voxel model (voxelized with binvox -d 64 -cb)
to estimate approximately where you need to crop:
The bottom image shows the voxel model from the top (press y in viewvox
to get the view straight from the top, and possibly p to switch to an orthographic projection).
You can see the head ends approximately 25 voxels from the left. 25/64 is about 0.4, to we'll limit voxelization
to 0.4 in the z direction:
Note: because the exact voxelization method (select with -e) doesn't use OpenGL, the -bb parameter has no effect. Also, you may have to experiment with using the voting method only (select with -v) for example, because cropping a model is likely to make it hollow.
Step 2: visualize slice by sliceRun:./viewvox mug.binvox By default viewvox removes the internal voxels (creating a "hollow" model). If you want to keep the internal voxels, run it like this: ./viewvox -ki mug.binvox. The keyboard and mouse commands available in viewvox are printed in the terminal window you run it from ("cmd" in Windows, "Terminal" in Mac OS X).
Now, typically you'd press s to show one slice of the voxel model, k and j
to show the next slice up and down (the current slice index is shown in the terminal window),
and a to show the voxels with alternating colours,
for example: To better examine the correspondence between successive slices, press n to show the slices above and below the current slice (optionally t to make these slices transparent). The right image shows a top view in orthographic projection.
To build the model in minecraft, I run minecraft and viewvox side-by-side so I can see where the blocks should go. Obviously many improvements are possible, send me your suggestions. Some recent additions:
Still on the to do list are:
Do check out...
|
Last modified: Mon Jul 17 17:19:44 2023