Okay, thank you very much!
I've now got a question about the surface extractor.
I've got my volume broken down into small chunks, each chunk has it's own SurfaceMesh thats filled from a surface extractor.
I'm iterating through each chunk and taking the vertices and indices from the surface mesh and combining them together.
When I render this it's just a mess of polygons.
So, when I use the surface extractor on each of the individual chunks does it number the extracted indices and position of vertices from within that small region or does it take into consideration what section from the whole volume I'm extracting out of?
Sorry that might not make sense

Code:
void Render(void)
{
// Maximum sector distance for rendering
float SectorRenderDistance = 1000.0f;
// Maximum chunk distance for rendering
float ChunkRenderDistance = 800.0f;
// Get camera position
Camera = SMGR->getActiveCamera();
PolyVox::Vector3DFloat CamPos(Camera->getPosition().X, Camera->getPosition().Y, Camera->getPosition().Z);
// Vector of indices to render
std::vector<uint32_t> indices;
// Vector of vertices to render
std::vector<PolyVox::PositionMaterialNormal> vertices;
// Loop through all planets
for (auto iPlanet : Planets)
{
// Check planet render distance
Planet* ThisPlanet = iPlanet->GetPlanet();
if ((CamPos - ThisPlanet->GetPlanetData()->PlanetPosition).length() <= PlanetRenderDistance)
{
// Loop through all planets sectors
std::vector<Sector*> Sectors = ThisPlanet->GetSectors();
for (auto Sec : Sectors)
{
// Check sector render distance
if (wSpecs.WorldPosFromVoxelPos(Sec->GetCenterPos()).length() <= SectorRenderDistance)
{
// Loop through all sectors chunks
std::vector<Chunk*> Chunks = Sec->GetChunks();
for (auto Chk : Chunks)
{
// Check if chunk not empty
if (!Chk->GetEmpty())
{
// Check chunk render distance
if (wSpecs.WorldPosFromVoxelPos(Chk->GetCenterPos()).length() <= ChunkRenderDistance)
{
// Get the chunks SurfaceMesh
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> Mesh_PolyVox = Chk->GetMesh();
// Grab its indices and vertices
std::vector<uint32_t> NewIndicies = Mesh_PolyVox.getIndices();
std::vector<PolyVox::PositionMaterialNormal> NewVertices = Mesh_PolyVox.getVertices();
// If there are indices and vertices
if (NewVertices.size() > 0 && NewIndicies.size() > 0)
{
// Add them into the vectors for rendering
indices.reserve(indices.size() + NewIndicies.size());
vertices.reserve(vertices.size() + NewVertices.size());
indices.insert(indices.end(), NewIndicies.begin(), NewIndicies.end());
vertices.insert(vertices.end(), NewVertices.begin(), NewVertices.end());
}
}
}
}
}
}
}
}
//
//
// How many indices and vertices to render
size_t VerticeSize = vertices.size();
size_t IndiceSize = indices.size();
// Make sure there are some to render
if (VerticeSize > 0 && IndiceSize > 0)
{
//16 or 32 bit?
if (VerticeSize <= 65536)
{
// May need to delete and recreate as either 16/32 bit
MeshBuffer->getIndexBuffer().setType(irr::video::EIT_16BIT);
}
else{
// May need to delete and recreate as either 16/32 bit
MeshBuffer->getIndexBuffer().setType(irr::video::EIT_32BIT);
}
// Grab the vertex and index buffer
irr::scene::IVertexBuffer& VBuff = MeshBuffer->getVertexBuffer();
irr::scene::IIndexBuffer& IBuff = MeshBuffer->getIndexBuffer();
// Set how many vertices and indices were using
VBuff.set_used(VerticeSize);
IBuff.set_used(IndiceSize);
// Loop through each and set parametrs
for (size_t i = 0; i < VerticeSize; ++i)
{
const PolyVox::Vector3DFloat position = vertices[i].getPosition();
const PolyVox::Vector3DFloat normal = vertices[i].getNormal();
VBuff[i].Pos.X = position.getX();
VBuff[i].Pos.Y = position.getY();
VBuff[i].Pos.Z = position.getZ();
VBuff[i].Normal.X = normal.getX();
VBuff[i].Normal.Y = normal.getY();
VBuff[i].Normal.Z = normal.getZ();
VBuff[i].TCoords = irr::core::vector2df(position.getX(), position.getZ());
VBuff[i].Color = irr::video::SColor(255, 255, 255, 255);
}
for (size_t i = 0; i < IndiceSize; ++i)
{
IBuff.setValue(i, indices[i]);
}
// BoundingBox
MeshBuffer->recalculateBoundingBox();
// Setup a wireframe material
Driver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
irr::video::SMaterial Mat1 = MeshBuffer->getMaterial();
Mat1.setFlag(irr::video::EMF_LIGHTING, false);
Mat1.setFlag(irr::video::EMF_WIREFRAME, true);
Driver->setMaterial(Mat1);
// Draw the MeshBuffer to screen
Driver->drawMeshBuffer(MeshBuffer);
}
}