Renamed Volume base class to BaseVolume.

Added initial version of simple interface.
This commit is contained in:
David Williams
2011-10-14 23:57:10 +01:00
parent 7220bf866f
commit 6f31898fd7
18 changed files with 201 additions and 105 deletions

View File

@ -23,17 +23,14 @@ freely, subject to the following restrictions:
#include "OpenGLWidget.h"
#include "PolyVoxCore/MaterialDensityPair.h"
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
#include "PolyVoxCore/SurfaceMesh.h"
#include "PolyVoxCore/SimpleVolume.h"
#include "PolyVoxCore/SimpleInterface.h"
#include <QApplication>
//Use the PolyVox namespace
using namespace PolyVox;
void createSphereInVolume(SimpleVolume<MaterialDensityPair44>& volData, float fRadius)
void createSphereInVolume(BasicVolume& volData, float fRadius)
{
//This vector hold the position of the center of the volume
Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2);
@ -54,10 +51,10 @@ void createSphereInVolume(SimpleVolume<MaterialDensityPair44>& volData, float fR
if(fDistToCenter <= fRadius)
{
//Our new density value
uint8_t uDensity = MaterialDensityPair44::getMaxDensity();
uint8_t uDensity = MaterialDensityPair88::getMaxDensity();
//Get the old voxel
MaterialDensityPair44 voxel = volData.getVoxelAt(x,y,z);
MaterialDensityPair88 voxel = volData.getVoxelAt(x,y,z);
//Modify the density
voxel.setDensity(uDensity);
@ -78,13 +75,14 @@ int main(int argc, char *argv[])
openGLWidget.show();
//Create an empty volume and then place a sphere in it
SimpleVolume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
BasicVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
createSphereInVolume(volData, 30);
//Extract the surface
SurfaceMesh<PositionMaterialNormal> mesh;
CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
surfaceExtractor.execute();
BasicMesh mesh;
//CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44 > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
//surfaceExtractor.execute();
extractCubicMesh(volData, volData.getEnclosingRegion(), mesh);
//Pass the surface to the OpenGL window
openGLWidget.setSurfaceMeshToRender(mesh);