Given a voxelization of the environment and a triangle with vertices A, B, and C, what would be the best way to determine which voxels that the triangle "occupies" or resides in? In other words, how can can I enumerate all of the voxels in which any part of the triangle is in it?
First, you need a voxel / triangle intersection test.
To achieve this, a natural approach is to apply repeatedly a polygon-clipping algorithm (for instance Sutherland-Hodgman in 3D) on the triangle using the half-planes of the six faces of the cube and check what is left afterwards.
A better approach is described in Graphics Gems III, Triangle-Cube Intersection, pp. 236-239 (an implementation is available).
Then, you need to enumerate all the voxels intersected by the triangle.
A first possible approach:
[xmin,xmax]x[ymin,ymax]x[zmin,zmax]
Sweep the voxels to find out which ones are intersected by the triangle:
For x
in [xmin, xmax]
For y
in [ymin, ymax]
For z
in [zmin, zmax]
Check whether the voxel (x, y, z)
intersects the triangle
This can be optimized in at least a few ways:
for
loops.for
loop might be reduced by considering only voxels intersecting the supporting plane of the triangle.A second possible approach:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With