I recently implemented a voxel cone tracking algorithm, the first step is voxelize polygons ...
I use sparse octree to convert the polygon, everything was fine except for the texture display
mipmap = 6 (64x64x64)

AABB aabb = FindAABB(in);
AABB betterAABB = FixAABB(aabb);
Octree<uint8> tree(betterAABB, mipmap);
for(auto &f: in.faces)
tree.findTouchedLeaves(f, dfunc, cb);
Callback Function ...
struct Callback
{
void operator()(OctreeNode<uint8> *node, const Face &obj)
{
if(!node->data.value)
{
const glm::vec3 ¢er=node->aabb.getCenter();
out.push_back(center);
color.push_back(text->getPixel((obj.o.texCoord+obj.a.texCoord+obj.b.texCoord)/3.0f));
}
node->data.value=1;
}
std::vector<glm::vec3> out;
std::vector<glm::vec4> color;
const ImageTexture *text;
} cb;
as you can see ... I am directly averaging the three UVs o, a, b. (terribly right?) This is more inaccurate when the triangle is larger than the grid.
Should I use a rasterization based algorithm?
My question is: how to color the grid exactly?
source
share