diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 5da065c5..e7359f52 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -24,6 +24,7 @@ freely, subject to the following restrictions: #include "OpenGLWidget.h" #include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h" +#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h" #include "PolyVoxCore/SurfaceMesh.h" #include "PolyVoxCore/SimpleVolume.h" @@ -49,23 +50,17 @@ void createSphereInVolume(SimpleVolume& volData, float fRadius) //And compute how far the current position is from the center of the volume float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); - uint8_t uMaterial = 0; + uint8_t uVoxelValue = 0; //If the current voxel is less than 'radius' units from the center then we make it solid. if(fDistToCenter <= fRadius) { - //Our new density value - uMaterial = 1; + //Our new voxel value + uVoxelValue = 255; } - //Get the old voxel - //Material8 voxel = volData.getVoxelAt(x,y,z); - - //Modify the density and material - //voxel.setMaterial(uMaterial); - //Wrte the voxel value into the volume - volData.setVoxelAt(x, y, z, uMaterial); + volData.setVoxelAt(x, y, z, uVoxelValue); } } } @@ -82,9 +77,14 @@ int main(int argc, char *argv[]) SimpleVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); createSphereInVolume(volData, 30); - //Extract the surface + //A mesh object to hold the result of surface extraction SurfaceMesh mesh; + + //Create a surface extractor. Comment out one of the following two lines to decide which type gets created. CubicSurfaceExtractorWithNormals< SimpleVolume > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); + //MarchingCubesSurfaceExtractor< SimpleVolume > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); + + //Execute the surface extractor. surfaceExtractor.execute(); //Pass the surface to the OpenGL window