Merge branch 'feature/remove-wrap-modes' into develop

This commit is contained in:
David Williams
2015-03-07 21:19:21 +01:00
38 changed files with 561 additions and 1451 deletions

View File

@ -26,14 +26,14 @@ freely, subject to the following restrictions:
#include "PolyVox/CubicSurfaceExtractor.h"
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
#include "PolyVox/Mesh.h"
#include "PolyVox/PagedVolume.h"
#include "PolyVox/RawVolume.h"
#include <QApplication>
//Use the PolyVox namespace
using namespace PolyVox;
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
void createSphereInVolume(RawVolume<uint8_t>& 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);
@ -60,7 +60,7 @@ void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
}
//Wrte the voxel value into the volume
volData.setVoxelAt(x, y, z, uVoxelValue);
volData.setVoxel(x, y, z, uVoxelValue);
}
}
}
@ -78,7 +78,7 @@ protected:
void initializeExample() override
{
// Create an empty volume and then place a sphere in it
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
createSphereInVolume(volData, 30);
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.

View File

@ -26,14 +26,14 @@ freely, subject to the following restrictions:
#include "PolyVox/CubicSurfaceExtractor.h"
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
#include "PolyVox/Mesh.h"
#include "PolyVox/PagedVolume.h"
#include "PolyVox/RawVolume.h"
#include <QApplication>
//Use the PolyVox namespace
using namespace PolyVox;
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
void createSphereInVolume(RawVolume<uint8_t>& 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);
@ -60,7 +60,7 @@ void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
}
//Wrte the voxel value into the volume
volData.setVoxelAt(x, y, z, uVoxelValue);
volData.setVoxel(x, y, z, uVoxelValue);
}
}
}
@ -94,7 +94,7 @@ protected:
setShader(shader);
//Create an empty volume and then place a sphere in it
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
createSphereInVolume(volData, 30);
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.

View File

@ -27,7 +27,7 @@ freely, subject to the following restrictions:
using namespace PolyVox;
void createSphereInVolume(PagedVolume<MaterialDensityPair88>& volData, float fRadius, uint8_t uValue)
void createSphereInVolume(RawVolume<MaterialDensityPair88>& volData, float fRadius, uint8_t uValue)
{
//This vector hold the position of the center of the volume
Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / static_cast<int32_t>(2);
@ -48,14 +48,14 @@ void createSphereInVolume(PagedVolume<MaterialDensityPair88>& volData, float fRa
//then we make it solid, otherwise we make it empty space.
if(fDistToCenter <= fRadius)
{
volData.setVoxelAt(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity()));
volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity()));
}
}
}
}
}
void createCubeInVolume(PagedVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue)
{
uint8_t maxDen = MaterialDensityPair88::getMaxDensity();
uint8_t minDen = MaterialDensityPair88::getMinDensity();
@ -66,7 +66,7 @@ void createCubeInVolume(PagedVolume<MaterialDensityPair88>& volData, Vector3DInt
{
for (int x = lowerCorner.getX() ; x <= upperCorner.getX(); x++)
{
volData.setVoxelAt(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen));
volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen));
}
}
}

View File

@ -24,10 +24,10 @@ freely, subject to the following restrictions:
#ifndef __OpenGLExample_Shapes_H__
#define __OpenGLExample_Shapes_H__
#include "PolyVox/PagedVolume.h"
#include "PolyVox/RawVolume.h"
#include "PolyVox/MaterialDensityPair.h"
void createSphereInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair88>& volData, float fRadius, uint8_t uValue);
void createCubeInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair88>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
void createSphereInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, float fRadius, uint8_t uValue);
void createCubeInVolume(PolyVox::RawVolume<PolyVox::MaterialDensityPair88>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
#endif //__OpenGLExample_Shapes_H__

View File

@ -58,8 +58,7 @@ public:
protected:
void initializeExample() override
{
FilePager<MaterialDensityPair88>* pager = new FilePager<MaterialDensityPair88>(".");
PagedVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)), pager);
RawVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)));
//Make our volume contain a sphere in the center.
int32_t minPos = 0;

View File

@ -67,7 +67,7 @@ void createSphereInVolume(PagedVolume<MaterialDensityPair44>& volData, Vector3DF
voxel.setDensity(uDensity);
//Wrte the voxel value into the volume
volData.setVoxelAt(x, y, z, voxel);
volData.setVoxel(x, y, z, voxel);
}
}
}
@ -127,7 +127,7 @@ public:
// Voxel position within a chunk always start from zero. So if a chunk represents region (4, 8, 12) to (11, 19, 15)
// then the valid chunk voxels are from (0, 0, 0) to (7, 11, 3). Hence we subtract the lower corner position of the
// region from the volume space position in order to get the chunk space position.
pChunk->setVoxelAt(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel);
pChunk->setVoxel(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel);
}
}
}
@ -151,8 +151,7 @@ protected:
void initializeExample() override
{
PerlinNoisePager* pager = new PerlinNoisePager();
PagedVolume<MaterialDensityPair44> volData(PolyVox::Region::MaxRegion(), pager, 64);
volData.setMemoryUsageLimit(8 * 1024 * 1024); // 8Mb
PagedVolume<MaterialDensityPair44> volData(pager, 8 * 1024 * 1024, 64);
//createSphereInVolume(volData, 30);
//createPerlinTerrain(volData);

View File

@ -27,7 +27,6 @@ freely, subject to the following restrictions:
#include "PolyVox/MarchingCubesSurfaceExtractor.h"
#include "PolyVox/Mesh.h"
#include "PolyVox/RawVolume.h"
#include "PolyVox/PagedVolume.h"
#include "PolyVox/VolumeResampler.h"
#include <QApplication>
@ -35,7 +34,7 @@ freely, subject to the following restrictions:
//Use the PolyVox namespace
using namespace PolyVox;
void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
void createSphereInVolume(RawVolume<uint8_t>& 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);
@ -58,11 +57,11 @@ void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
uint8_t uDensity = std::numeric_limits<uint8_t>::max();
//Wrte the voxel value into the volume
volData.setVoxelAt(x, y, z, uDensity);
volData.setVoxel(x, y, z, uDensity);
}
//144 in the middle, (144 - 32) at the edges. Threshold of 128 is between these
//volData.setVoxelAt(x, y, z, 144 - fDistToCenter);
//volData.setVoxel(x, y, z, 144 - fDistToCenter);
}
}
}
@ -80,7 +79,7 @@ protected:
void initializeExample() override
{
//Create an empty volume and then place a sphere in it
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
RawVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
createSphereInVolume(volData, 28);
//Smooth the data - should reimplement this using LowPassFilter
@ -90,7 +89,7 @@ protected:
RawVolume<uint8_t> volDataLowLOD(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(15, 31, 31)));
VolumeResampler< PagedVolume<uint8_t>, RawVolume<uint8_t> > volumeResampler(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(31, 63, 63)), &volDataLowLOD, volDataLowLOD.getEnclosingRegion());
VolumeResampler< RawVolume<uint8_t>, RawVolume<uint8_t> > volumeResampler(&volData, PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(31, 63, 63)), &volDataLowLOD, volDataLowLOD.getEnclosingRegion());
volumeResampler.execute();
//Extract the surface