I have a 3d mesh (a set of triangles) that defines a closed watertight surface. I want to rasterize this mesh, that is divide the space occupied by the mesh to even, little cubes (the 3d equivalent of 2d pixels), and paint the cubes that a triangle passes through as black and the rest as white. Similar to how one would rasterize a 2d vector-graphic image into a rasterized bmp, for instance.
In other words, I want to output a 3d array, A
that is M x M x M
, such that A(i,j,k)
is 1 if there is some triangle which passes through the space occupied by the cube at the location i,j,k
.
Hope that was clear, if not - tell me and I'll clarify.
Any algorithm, library, matlab routine will do.
I've found this voxelizer quite fitting for my needs. It works quite fast, and also has a matlab script for reading the resulting voxel file into matlab.