Put every triangle in its final position
A 3D model is built from lots of tiny flat triangles. Before we can place cubes around the duck, every triangle must be moved, rotated, and scaled into the position we see on screen.
A computer sees this rubber duck as thousands of textured triangles. Move the controls, then follow six steps to see how those triangles become a compact grid of colored cubes.
Drag or zoom any view.
Each step pairs a simple explanation with the math, terminology, and pseudocode behind it.
A 3D model is built from lots of tiny flat triangles. Before we can place cubes around the duck, every triangle must be moved, rotated, and scaled into the position we see on screen.
The large cube may contain millions of cells. For each triangle, we first find the smallest rectangular group of cells it could possibly touch. Everything outside that group can be skipped immediately.
A candidate box is only a possibility. We accurately test the triangle against that box. If they touch, the box becomes a surface voxel; if there is a gap, we discard it.
Surface voxels form a shell. To find the inside, we start with empty cells along the outer boundary and let imaginary water spread through neighboring empty cells. Dry cells trapped behind the shell are inside.
Each surface voxel chooses the triangle closest to its center. A point on that triangle tells us where to look on the model’s flat texture image, and that sampled texture color becomes the voxel’s color.
Creating a separate 3D mesh for every voxel would be wasteful. Instead, the GPU receives one cube shape plus a short position and color record for each visible voxel, then draws them all together.