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 "OpenGLWidget.h"
|
||||||
|
|
||||||
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
|
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
|
||||||
|
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
|
||||||
#include "PolyVoxCore/SurfaceMesh.h"
|
#include "PolyVoxCore/SurfaceMesh.h"
|
||||||
#include "PolyVoxCore/SimpleVolume.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
|
//And compute how far the current position is from the center of the volume
|
||||||
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
|
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 the current voxel is less than 'radius' units from the center then we make it solid.
|
||||||
if(fDistToCenter <= fRadius)
|
if(fDistToCenter <= fRadius)
|
||||||
{
|
{
|
||||||
//Our new density value
|
//Our new voxel value
|
||||||
uMaterial = 1;
|
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
|
//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)));
|
SimpleVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
|
||||||
createSphereInVolume(volData, 30);
|
createSphereInVolume(volData, 30);
|
||||||
|
|
||||||
//Extract the surface
|
//A mesh object to hold the result of surface extraction
|
||||||
SurfaceMesh<PositionMaterialNormal> mesh;
|
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);
|
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||||
|
//MarchingCubesSurfaceExtractor< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||||
|
|
||||||
|
//Execute the surface extractor.
|
||||||
surfaceExtractor.execute();
|
surfaceExtractor.execute();
|
||||||
|
|
||||||
//Pass the surface to the OpenGL window
|
//Pass the surface to the OpenGL window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user