Initial version of mesh decimation.
This commit is contained in:
@ -44,6 +44,7 @@ namespace PolyVox
|
||||
bool operator>=(const BlockVolumeIterator& rhs);
|
||||
|
||||
float getAveragedVoxel(boost::uint16_t size) const;
|
||||
VoxelType getMaxedVoxel(void) const;
|
||||
boost::uint16_t getPosX(void) const;
|
||||
boost::uint16_t getPosY(void) const;
|
||||
boost::uint16_t getPosZ(void) const;
|
||||
|
@ -136,6 +136,21 @@ namespace PolyVox
|
||||
return sum;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType BlockVolumeIterator<VoxelType>::getMaxedVoxel(void) const
|
||||
{
|
||||
VoxelType tValue = getVoxel();
|
||||
tValue = (std::max)(tValue, peekVoxel1px0py0pz());
|
||||
tValue = (std::max)(tValue, peekVoxel0px1py0pz());
|
||||
tValue = (std::max)(tValue, peekVoxel1px1py0pz());
|
||||
tValue = (std::max)(tValue, peekVoxel0px0py1pz());
|
||||
tValue = (std::max)(tValue, peekVoxel1px0py1pz());
|
||||
tValue = (std::max)(tValue, peekVoxel0px1py1pz());
|
||||
tValue = (std::max)(tValue, peekVoxel1px1py1pz());
|
||||
return tValue;
|
||||
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosX(void) const
|
||||
{
|
||||
|
@ -32,6 +32,9 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(BlockVolumeIterator<VoxelType>& volIter);
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeDecimatedCentralDifferenceGradient(BlockVolumeIterator<VoxelType>& volIter);
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSobelGradient(const BlockVolumeIterator<VoxelType>& volIter);
|
||||
}
|
||||
|
@ -42,6 +42,31 @@ namespace PolyVox
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeDecimatedCentralDifferenceGradient(const BlockVolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
const uint16_t x = volIter.getPosX();
|
||||
const uint16_t y = volIter.getPosY();
|
||||
const uint16_t z = volIter.getPosZ();
|
||||
|
||||
//FIXME - bitwise way of doing this?
|
||||
VoxelType voxel1nx = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0;
|
||||
VoxelType voxel1px = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0;
|
||||
|
||||
VoxelType voxel1ny = volIter.getVoxelAt(x , y-2,z ) > 0 ? 1: 0;
|
||||
VoxelType voxel1py = volIter.getVoxelAt(x , y-2,z ) > 0 ? 1: 0;
|
||||
|
||||
VoxelType voxel1nz = volIter.getVoxelAt(x , y ,z-2) > 0 ? 1: 0;
|
||||
VoxelType voxel1pz = volIter.getVoxelAt(x , y ,z-2) > 0 ? 1: 0;
|
||||
|
||||
return Vector3DFloat
|
||||
(
|
||||
static_cast<float>(voxel1px) - static_cast<float>(voxel1nx),
|
||||
static_cast<float>(voxel1py) - static_cast<float>(voxel1ny),
|
||||
static_cast<float>(voxel1pz) - static_cast<float>(voxel1nz)
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(BlockVolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
|
@ -49,6 +49,8 @@ namespace PolyVox
|
||||
|
||||
POLYVOX_API void generateSmoothMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API Vector3DFloat computeSmoothNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||
|
||||
POLYVOX_API void generateDecimatedMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user