Hi I was experimenting with the PolyVox Library and it worked great. But now I ran into a problem which I don't know how to fix. It seems like the extractor does not extract everything. I get patches of no material, but if I print out the Material into a file I can see, that there should be a surface.
Here are two images to visualize it:
http://i.imgur.com/9f3Xl.pngFor my testing I am using Irrlicht to render the meshes. Here is my conversion code:
Code:
SurfaceMesh<PositionMaterialNormal> surfaceMesh;
CubicSurfaceExtractorWithNormals<LargeVolume<Material16> > extractor(m_pVolume, region, &surfaceMesh);
extractor.execute();
createIrrlichtMesh(surfaceMesh);
//...
// createIrrlichtMesh method:
const std::vector<uint32_t>& indices = surfaceMesh->getIndices();
const std::vector<PositionMaterialNormal>& vertices = surfaceMesh->getVertices();
irr::scene::SMesh* smesh = new irr::scene::SMesh();
irr::scene::SMeshBuffer* buf = new irr::scene::SMeshBuffer();
smesh->addMeshBuffer(buf);
buf->drop();
buf->Vertices.set_used(surfaceMesh->getNoOfVertices());
buf->Indices.set_used(surfaceMesh->getNoOfIndices());
for(uint32_t v = 0 ; v < surfaceMesh->getNoOfVertices() ; v++)
{
const PolyVox::Vector3DFloat& position = vertices[v].getPosition();
const PolyVox::Vector3DFloat& normal = vertices[v].getNormal();
buf->Vertices[v].Pos.set(position.getX(), position.getY(), position.getZ());
buf->Vertices[v].Normal.set(normal.getX(), normal.getY(), normal.getZ());
buf->Vertices[v].Color.set(255, 255, 255, 255);
}
for(uint32_t i = 0 ; i < surfaceMesh->getNoOfIndices(); i++)
{
buf->Indices[i] = indices[i];
}
buf->recalculateBoundingBox();
//.....
And here is the code for the initialization of the Volume:
Code:
m_pVolume = new LargeVolume<Material16>(&VoxelWorld::loadPage, &VoxelWorld::unloadPage, VOXEL_PAGE_SIZE);
m_pVolume->setMaxNumberOfBlocksInMemory(4096);
m_pVolume->setMaxNumberOfUncompressedBlocks(64);
m_pVolume->setBorderValue(0);
Region reg(Vector3DInt32(0,0,0), Vector3DInt32(64,64,64));
m_pVolume->prefetch(reg);
VOXEL_PAGE_SIZE is 32 in this test but making it smaller or bigger does not make a difference (just where the holes are located). I would appreciate your help, thanks is advance.
Edit: Sorry, the problem was that I tried to extract the Regions one by one. I feel really stupid, but is there any way to get smaller regions out of the Volume so I don't have to recreate the whole region if I change one Voxel?