Initial work on exposing the wrap modes to the marching cubes surface extractor.
This commit is contained in:
parent
c69417a72b
commit
c06bfa9c09
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
|||||||
#ifndef __PolyVox_MarchingCubesController_H__
|
#ifndef __PolyVox_MarchingCubesController_H__
|
||||||
#define __PolyVox_MarchingCubesController_H__
|
#define __PolyVox_MarchingCubesController_H__
|
||||||
|
|
||||||
|
#include "PolyVoxCore/BaseVolume.h"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
@ -77,17 +79,21 @@ namespace PolyVox
|
|||||||
DefaultMarchingCubesController(void)
|
DefaultMarchingCubesController(void)
|
||||||
{
|
{
|
||||||
m_tThreshold = ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2;
|
m_tThreshold = ((std::numeric_limits<DensityType>::min)() + (std::numeric_limits<DensityType>::max)()) / 2;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
|
m_tBorder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Constructor
|
/// Constructor
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// This version of the constructor allows you to set a custom threshold.
|
/// This version of the constructor allows you to set some custom parameters
|
||||||
/// \param tThreshold The threshold to use.
|
/// \param tThreshold The threshold to use.
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
DefaultMarchingCubesController(DensityType tThreshold)
|
DefaultMarchingCubesController(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
|
m_tBorder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -124,8 +130,21 @@ namespace PolyVox
|
|||||||
return m_tThreshold;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
WrapMode getWrapMode(void)
|
||||||
|
{
|
||||||
|
return m_eWrapMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType(0))
|
||||||
|
{
|
||||||
|
m_eWrapMode = eWrapMode;
|
||||||
|
m_tBorder = tBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
DensityType m_tThreshold;
|
DensityType m_tThreshold;
|
||||||
|
WrapMode m_eWrapMode;
|
||||||
|
VoxelType m_tBorder;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +155,13 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// Default to a threshold value halfway between the min and max possible values.
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
m_tThreshold = (Density<Type>::getMinDensity() + Density<Type>::getMaxDensity()) / 2;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMarchingCubesController(DensityType tThreshold)
|
DefaultMarchingCubesController(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(Density<Type> voxel)
|
DensityType convertToDensity(Density<Type> voxel)
|
||||||
@ -177,8 +179,20 @@ namespace PolyVox
|
|||||||
return m_tThreshold;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
WrapMode getWrapMode(void)
|
||||||
|
{
|
||||||
|
return m_eWrapMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWrapMode(WrapMode eWrapMode)
|
||||||
|
{
|
||||||
|
m_eWrapMode = eWrapMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
DensityType m_tThreshold;
|
DensityType m_tThreshold;
|
||||||
|
WrapMode m_eWrapMode;
|
||||||
|
Density<Type> m_tBorder;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ namespace PolyVox
|
|||||||
//m_regSizeInVoxels.cropTo(m_volData->getEnclosingRegion());
|
//m_regSizeInVoxels.cropTo(m_volData->getEnclosingRegion());
|
||||||
m_regSizeInCells = m_regSizeInVoxels;
|
m_regSizeInCells = m_regSizeInVoxels;
|
||||||
m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1));
|
m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1));
|
||||||
|
|
||||||
|
m_sampVolume.setWrapMode(m_controller.getWrapMode(), m_controller.m_tBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename VolumeType, typename Controller>
|
template<typename VolumeType, typename Controller>
|
||||||
|
@ -119,11 +119,13 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
// Default to a threshold value halfway between the min and max possible values.
|
// Default to a threshold value halfway between the min and max possible values.
|
||||||
m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
m_tThreshold = (MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMinDensity() + MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>::getMaxDensity()) / 2;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultMarchingCubesController(DensityType tThreshold)
|
DefaultMarchingCubesController(DensityType tThreshold)
|
||||||
{
|
{
|
||||||
m_tThreshold = tThreshold;
|
m_tThreshold = tThreshold;
|
||||||
|
m_eWrapMode = WrapModes::Border;
|
||||||
}
|
}
|
||||||
|
|
||||||
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
DensityType convertToDensity(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> voxel)
|
||||||
@ -139,10 +141,22 @@ namespace PolyVox
|
|||||||
DensityType getThreshold(void)
|
DensityType getThreshold(void)
|
||||||
{
|
{
|
||||||
return m_tThreshold;
|
return m_tThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
WrapMode getWrapMode(void)
|
||||||
|
{
|
||||||
|
return m_eWrapMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWrapMode(WrapMode eWrapMode)
|
||||||
|
{
|
||||||
|
m_eWrapMode = eWrapMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
DensityType m_tThreshold;
|
DensityType m_tThreshold;
|
||||||
|
WrapMode m_eWrapMode;
|
||||||
|
MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> m_tBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||||
|
@ -59,6 +59,13 @@ public:
|
|||||||
{
|
{
|
||||||
return 50.0f;
|
return 50.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WrapMode getWrapMode(void)
|
||||||
|
{
|
||||||
|
return WrapModes::Border;
|
||||||
|
}
|
||||||
|
|
||||||
|
float m_tBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
// These 'writeDensityValueToVoxel' functions provide a unified interface for writting densities to primative and class voxel types.
|
||||||
@ -145,6 +152,7 @@ void testCustomController(SurfaceMesh<PositionMaterialNormal>& result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomMarchingCubesController controller;
|
CustomMarchingCubesController controller;
|
||||||
|
controller.m_tBorder = 0.0f; //Temporary HACK!
|
||||||
MarchingCubesSurfaceExtractor< SimpleVolume<float>, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller);
|
MarchingCubesSurfaceExtractor< SimpleVolume<float>, CustomMarchingCubesController > extractor(&volData, volData.getEnclosingRegion(), &result, controller);
|
||||||
extractor.execute();
|
extractor.execute();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user