Code: Select all
//Create the volume that contains the actual voxel data and make it 64x64x64
SimpleVolume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
//This vector hold the position of the center of the volume
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
//Our new density value
uint8_t uDensity = MaterialDensityPair44::getMaxDensity();
//Get the old voxel
MaterialDensityPair44 voxel = volData.getVoxelAt(10, 10, 10);
//Modify the density
voxel.setDensity(uDensity);
//Wrte the voxel value into the volume
volData.setVoxelAt(10, 10, 10, voxel);
scene::CDynamicMeshBuffer *newBuffer = new scene::CDynamicMeshBuffer(video::EVT_STANDARD, video::EIT_32BIT);
IrrSurfaceExtractor<SimpleVolume, MaterialDensityPair44 > irrsurfaceExtractor(&volData, volData.getEnclosingRegion(), newBuffer);
irrsurfaceExtractor.execute();
//Create the scene node
scene::SMesh * newMesh = new scene::SMesh;
newMesh->addMeshBuffer(newBuffer);
newMesh->recalculateBoundingBox();
scene::ISceneNode * newNode = smgr->addMeshSceneNode(newMesh);
newMesh->drop();
newBuffer->drop();
2. and i don't know how to texture the voxels (blocks of my terrain)