For now there isn't a 'terrain' with multiple regions.
I only created a solid block in a 128x128x3 volume and this takes about 6 seconds to load.
By the way, your voxelins needs only 1-2 seconds for a bigger volume.
My code:
Code:
voldata = new SimpleVolume<PolyVox::Material8>(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(128, 2, 128)));
Code:
terrain->createChunkInVolume(voldata); // <<<< this creates the a solid block in the volume
SurfaceMesh<PositionMaterial/*Normal*/> mesh;
//CubicSurfaceExtractorWithNormals<SimpleVolume, PolyVox::Material8 > surfaceExtractor(voldata, voldata->getEnclosingRegion(), &mesh);
PolyVox::CubicSurfaceExtractor<SimpleVolume, PolyVox::Material8> surfaceExtractor(voldata, voldata->getEnclosingRegion(), &mesh);
surfaceExtractor.execute();
/////
Ogre::ManualObject* obj = App::getSceneManager()->createManualObject();
uint32_t noVertices = mesh.getNoOfVertices();
uint32_t noIndices = mesh.getNoOfIndices();
obj->estimateVertexCount(noVertices);
obj->estimateIndexCount(noIndices);
obj->begin(/*"WireFrame"*/"ColouredCubicVoxel", Ogre::RenderOperation::OT_TRIANGLE_LIST);
// vertexes
const std::vector<PolyVox::PositionMaterial/*Normal*/>& vVertices = mesh.getVertices();
for (unsigned int i=0; i<noVertices; i++) {
const PolyVox::Vector3DFloat& pos = vVertices[i].getPosition();
obj->position(pos.getX(), pos.getY(), pos.getZ());
//const PolyVox::Vector3DFloat& normal = vVertices[i].getNormal();
//obj->normal(normal.getX(), normal.getY(), normal.getZ());
}
// indices
const std::vector<uint32_t>& vIndices = mesh.getIndices();
for (unsigned int i=0; i<noIndices; i++) {
obj->index( vIndices[i] );
}
obj->end();
if ( node == NULL ) {
node = App::getSceneManager()->getRootSceneNode()->createChildSceneNode();
}
node = App::getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->attachObject(obj);
node->setScale(10.0, 10.0, 10.0);
node->setPosition(pos);
Code:
void voxel::terrain::createChunkInVolume(SimpleVolume<PolyVox::Material8>* voldata){
Vector3DFloat v3dVolCenter(voldata->getWidth() / 2, voldata->getHeight() / 2, voldata->getDepth() / 2);
for (int z = 0; z < voldata->getWidth(); z++){
for (int y = 0; y < voldata->getHeight(); y++){
for (int x = 0; x < voldata->getDepth(); x++){
Vector3DFloat v3dCurrentPos(x,y,z);
voldata->setVoxelAt(x, y, z, 1);
}
}
}
}