Tidying up comments.
This commit is contained in:
parent
1444f187a6
commit
c0b72b6a55
@ -99,13 +99,8 @@ protected:
|
|||||||
createSphereInVolume(volData, 30);
|
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.
|
// Extract the surface for the specified region of the volume. Uncomment the line for the kind of surface extraction you want to see.
|
||||||
//auto mesh = extractCubicMesh(&volData, volData.getEnclosingRegion());
|
|
||||||
auto mesh = extractMarchingCubesMesh(&volData, volData.getEnclosingRegion());
|
auto mesh = extractMarchingCubesMesh(&volData, volData.getEnclosingRegion());
|
||||||
|
|
||||||
// The surface extractor outputs the mesh in an efficient compressed format which is not directly suitable for rendering. The easiest approach is to
|
|
||||||
// decode this on the CPU as shown below, though more advanced applications can upload the compressed mesh to the GPU and decompress in shader code.
|
|
||||||
//auto decodedMesh = decodeMesh(mesh);
|
|
||||||
|
|
||||||
//Pass the surface to the OpenGL window
|
//Pass the surface to the OpenGL window
|
||||||
OpenGLMeshData meshData = buildOpenGLMeshData(mesh);
|
OpenGLMeshData meshData = buildOpenGLMeshData(mesh);
|
||||||
addMeshData(meshData);
|
addMeshData(meshData);
|
||||||
|
@ -35,16 +35,19 @@
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
/// A specialised vertex format which encodes the data from the cubic extraction algorithm in a very
|
||||||
|
/// compact way. You will probably want to use the decodeVertex() function to turn it into a regular
|
||||||
|
/// Vertex for rendering, but advanced users should also be able to decode it on the GPU (not tested).
|
||||||
template<typename _DataType>
|
template<typename _DataType>
|
||||||
struct CubicVertex
|
struct CubicVertex
|
||||||
{
|
{
|
||||||
typedef _DataType DataType;
|
typedef _DataType DataType;
|
||||||
|
|
||||||
// Each component of the position is stored as a single unsigned byte.
|
/// Each component of the position is stored as a single unsigned byte.
|
||||||
// The true position is found by offseting each component by 0.5f.
|
/// The true position is found by offseting each component by 0.5f.
|
||||||
Vector3DUint8 encodedPosition;
|
Vector3DUint8 encodedPosition;
|
||||||
|
|
||||||
// User data
|
/// A copy of the data which was stored in the voxel which generated this vertex.
|
||||||
DataType data;
|
DataType data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,11 +63,11 @@ namespace PolyVox
|
|||||||
template<typename DataType>
|
template<typename DataType>
|
||||||
Vertex<DataType> decodeVertex(const CubicVertex<DataType>& cubicVertex);
|
Vertex<DataType> decodeVertex(const CubicVertex<DataType>& cubicVertex);
|
||||||
|
|
||||||
// Generates a cubic-style mesh from the voxel data.
|
/// Generates a cubic-style mesh from the voxel data.
|
||||||
template<typename VolumeType, typename MeshType, typename IsQuadNeeded = DefaultIsQuadNeeded<typename VolumeType::VoxelType> >
|
template<typename VolumeType, typename MeshType, typename IsQuadNeeded = DefaultIsQuadNeeded<typename VolumeType::VoxelType> >
|
||||||
void extractCubicMeshCustom(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true);
|
void extractCubicMeshCustom(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true);
|
||||||
|
|
||||||
// Generates a cubic-style mesh from the voxel data, placing the result into a user-provided Mesh.
|
/// Generates a cubic-style mesh from the voxel data, placing the result into a user-provided Mesh.
|
||||||
template<typename VolumeType, typename IsQuadNeeded = DefaultIsQuadNeeded<typename VolumeType::VoxelType> >
|
template<typename VolumeType, typename IsQuadNeeded = DefaultIsQuadNeeded<typename VolumeType::VoxelType> >
|
||||||
Mesh<CubicVertex<typename VolumeType::VoxelType> > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true);
|
Mesh<CubicVertex<typename VolumeType::VoxelType> > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true);
|
||||||
|
|
||||||
|
@ -40,17 +40,18 @@ namespace PolyVox
|
|||||||
/// Vertex for rendering, but advanced users can also decode it on the GPU (see PolyVox examples).
|
/// Vertex for rendering, but advanced users can also decode it on the GPU (see PolyVox examples).
|
||||||
template<typename _DataType>
|
template<typename _DataType>
|
||||||
struct MarchingCubesVertex
|
struct MarchingCubesVertex
|
||||||
{
|
{
|
||||||
typedef _DataType DataType;
|
typedef _DataType DataType;
|
||||||
|
|
||||||
// Each component of the position is stored using 8.8 fixed-point encoding.
|
/// Each component of the position is stored using 8.8 fixed-point encoding.
|
||||||
Vector3DUint16 encodedPosition;
|
Vector3DUint16 encodedPosition;
|
||||||
|
|
||||||
// The normal is encoded as a 16-bit unsigned integer using the 'oct16'
|
/// The normal is encoded as a 16-bit unsigned integer using the 'oct16'
|
||||||
// encoding described here: http://jcgt.org/published/0003/02/01/
|
/// encoding described here: http://jcgt.org/published/0003/02/01/
|
||||||
uint16_t encodedNormal;
|
uint16_t encodedNormal;
|
||||||
|
|
||||||
// User data
|
/// The interpolated voxel data from the neighbouring voxels which generated this
|
||||||
|
/// vertex (every vertex is placed between two voxels by the MArching Cubes algorithm)
|
||||||
DataType data;
|
DataType data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,11 +64,11 @@ namespace PolyVox
|
|||||||
template<typename DataType>
|
template<typename DataType>
|
||||||
Vertex<DataType> decodeVertex(const MarchingCubesVertex<DataType>& marchingCubesVertex);
|
Vertex<DataType> decodeVertex(const MarchingCubesVertex<DataType>& marchingCubesVertex);
|
||||||
|
|
||||||
// Generates a mesh from the voxel data using the Marching Cubes algorithm.
|
/// Generates a mesh from the voxel data using the Marching Cubes algorithm.
|
||||||
template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
||||||
Mesh<MarchingCubesVertex<typename VolumeType::VoxelType> > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType());
|
Mesh<MarchingCubesVertex<typename VolumeType::VoxelType> > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType());
|
||||||
|
|
||||||
// Generates a mesh from the voxel data using the Marching Cubes algorithm, placing the result into a user-provided Mesh.
|
/// Generates a mesh from the voxel data using the Marching Cubes algorithm, placing the result into a user-provided Mesh.
|
||||||
template< typename VolumeType, typename MeshType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
template< typename VolumeType, typename MeshType, typename ControllerType = DefaultMarchingCubesController<typename VolumeType::VoxelType> >
|
||||||
void extractMarchingCubesMeshCustom(VolumeType* volData, Region region, MeshType* result, ControllerType controller = ControllerType());
|
void extractMarchingCubesMeshCustom(VolumeType* volData, Region region, MeshType* result, ControllerType controller = ControllerType());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user