^{®}object.

You need the Adobe Flash plugin to see the animation.

**Voxelizer**, Convert your 3D model online into a voxel representation.

- In addition to standard cubes, adjustable beleveled cubes are also supported.
- Your 3D model is not stored on a server; all data is processed on your local machine.
- Unlimited usage.
- Input
*.OBJ*or*.DXF*.

Output,*.OBJ*,*.DXF*,*.XML*,*.VOX*or*.POV*.

This application converts a 3D computer model representation into a voxel representation or voxel model.

The number of voxels is adjustable, so is the overall size of voxels.

In addition to standard cubes, adjustable beleveled cubes are also supported.

The calculated voxel representations can be stored and
can be used in most commercial and non-commercial 3D programmes, such as
*blender*,
*povray* or
*cinema4d*.

The orientation of the model on the screen does not influence the way the voxel representation is exported.

The generated voxel representation is free for non-commercial use.

The legolizer might be interesting for you; convert any arbitrary polygon-based 3D model into a 3D LEGO^{®} object.

A *voxel* is an enclosed three-dimensional shape, mostly a cube,
although it can be any regular, more complicated shape. Voxels are
positioned in a symmetrical/regular three-dimensional continuous
grid.

For simplicity a cube is used in the example.

To build a voxel object, you need to know whether a voxel is visible
- occupied - or invisible - empty. You can build your voxel object
manually or by using a code. This tutorial explains how to build a voxel
object by code. You need a polygon based 3D model as input.

To create a voxel object by using a code, you need to know which voxels
in the three-dimensional continuous grid contain (part of) a polygon. If
(part of) a polygon is inside, the voxel is visible, if not, the voxel
is empty.

The position of a two-dimensional rectangle with a dimension of 1.0 x 1.0 ( horizontal x vertical ) can be described by using a two-dimensional position ( x, y ). If you use the centre of the voxel as a starting point, all the horizontal and vertical positions between -0.5 and 0.5 are related to the voxel positioned at 0.0, 0.0.

The formula is very simple: you have to round the two dimensional positions.

```
x
```_{voxel} = ( x + ( x < 0.0 ? -1.0 : 1.0 ) * ( voxelWidth / 2.0 ) ) / voxelWidth;
y_{voxel} = ( y + ( y < 0.0 ? -1.0 : 1.0 ) * ( voxelHeight / 2.0 ) ) / voxelHeight;
x_{voxel} = ( x_{voxel} < 0.0 ? ceil( x_{voxel} ) : floor( x_{voxel} ) ) * voxelWidth;
y_{voxel} = ( y_{voxel} < 0.0 ? ceil( y_{voxel} ) : floor( y_{voxel} ) ) * voxelHeight;

The horizontal and vertical dimensions of a voxel is not necessarily the same, this may vary depending on your purpose and/or according to taste.

A voxel is not two-dimensional but three-dimensional: depth is added to the horizontal and vertical dimension. When adding depth, the same calculations are used to convert a position into a voxel position. A voxel position is described by using three numbers; a horizontal position, a vertical position and a depth position.

If you want to transform your polygon-based 3D model into a voxel representation, you need to know if (part of) the polygon lies within a voxel. So it seems logical to think that you need a polygon cube intersection. This requires some mathematical skills that may be difficult to understand for most people. ...You might want to stop reading here, but wait... if you have understood the introduction so far, you're done; it will not become more difficult!

Normally, a polygon has three *vertices*. The space inside these three
vertices is the visible surface of the polygon.

A simple method to convert a polygon into voxels is soly using the vertices of a polygon.

Each vertex is a three-dimensional position such as 13.45, 20.5, 120.0 ( x, y, z ). To find out to which voxel the vertex is related, you need to convert the three-dimensional positions into a voxel position, as described in the introduction.

Unless a polygon is very small, it is usually bigger than one single voxel. To convert the complete polygon into voxels, you must subdivide the poylgon and check whether all the vertices are related to the same voxel. If this is the case, you can store the single voxel position and you are done.

If the three vertices are not related to the same voxel, you must
further subdivide the already subdivided polygon and check whether all
the vertices are related to the same voxel. If not, futhter subdive the
already subdivied polygon, and so on (*see image*).

The process of subdividing is called *recursion*; the outcome of the
calculation will be used as the input for the same calculation.

In some situations, you may continue subdividing endlessly, without
getting the right outcome. Sooner or later your computer will give some
sort of warning or - worse - crash.

If the size of the (subdivided)
polygon is small enough, say one tenth of the voxel dimension, you can
stop the subdivision in order to prevent problems. Calculate the voxel
position for each individual vertex and store them separately. Instead
of one single voxel position, you have at least two, or maybe three
(adjacent) voxel positions. That's all there is to it!

By using this method, a voxel position is calculated several times so you have to check whether the voxel position has already been calculated. If not, store the position. If the voxel position is calculated previously, ignore the calculated voxel position.

You have some options to store your voxel information.

You can store the voxel position as a combination of x, y and z (floating point) numbers. Depending on your computer and operating system, a number takes 32 or 64 bits in a memory and/or on a disk. If you store three numbers, you need at least 3 x 32 = 96 bits... not a huge number nowadays.

A more sophisticated way to store your voxel information is by using individual bits; instead of 96 bits for a single voxel position you can use the same 96 bits for up to 96 voxel positions(!) If a bit has the value 1 - true - the voxel is present, if the value is 0 - false - the voxel is not present. You need some extra information for this approach. You need to number the voxel positions in your voxel universe. The number relates to a specific bit.

For example, you have a very small voxel object, with three horizontal voxel positions , three vertical voxel positions and three voxel depth-positions. The total number of voxel positions in your voxel universe equals 3 x 3 x 3, that is 27.

A real number, or so-called *integer*, like 234055, 12 and so is stored
as a binary number in your computer. Each bit in the binary sequence
which represent the number corresponds to a voxel position in the voxel
matrix (*see image*).

The first bit is related to the front left bottom voxel position, and so
on. If the value of the first bit equals 1, the voxel is present. If the
value of the bit equals 0, the voxel is not present.

Most voxel objects contain many thousands of voxel positions, so using a
more sophisticated way to store the information pays off; with a minimum
amount of data you can efficiently store your voxel data.

All contents copyright © 2015 by Arjan Westerdiep.