Small changes to basic example, mostly for clarity.
This commit is contained in:
parent
27f943adb3
commit
03cd1ada6d
@ -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<uint8_t>& 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<uint8_t> 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<PositionMaterialNormal> mesh;
|
||||
|
||||
//Create a surface extractor. Comment out one of the following two lines to decide which type gets created.
|
||||
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||
//MarchingCubesSurfaceExtractor< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||
|
||||
//Execute the surface extractor.
|
||||
surfaceExtractor.execute();
|
||||
|
||||
//Pass the surface to the OpenGL window
|
||||
|
Loading…
x
Reference in New Issue
Block a user