diff --git a/examples/Basic/OpenGLWidget.cpp b/examples/Basic/OpenGLWidget.cpp index adde1244..072fdd1a 100644 --- a/examples/Basic/OpenGLWidget.cpp +++ b/examples/Basic/OpenGLWidget.cpp @@ -12,11 +12,11 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) { } -void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh& surfaceMesh) +void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh& surfaceMesh) { //Convienient access to the vertices and indices const vector& vecIndices = surfaceMesh.getIndices(); - const vector& vecVertices = surfaceMesh.getVertices(); + const vector& vecVertices = surfaceMesh.getVertices(); //Build an OpenGL index buffer glGenBuffers(1, &indexBuffer); @@ -28,7 +28,7 @@ void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh& surfaceMes glGenBuffers(1, &vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); const GLvoid* pVertices = static_cast(&(vecVertices[0])); - glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(SurfaceVertex), pVertices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(PositionMaterialNormal), pVertices, GL_STATIC_DRAW); m_uBeginIndex = 0; m_uEndIndex = vecIndices.size(); @@ -95,8 +95,8 @@ void OpenGLWidget::paintGL() //Bind the vertex buffer glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); - glVertexPointer(3, GL_FLOAT, sizeof(SurfaceVertex), 0); - glNormalPointer(GL_FLOAT, sizeof(SurfaceVertex), (GLvoid*)12); + glVertexPointer(3, GL_FLOAT, sizeof(PositionMaterialNormal), 0); + glNormalPointer(GL_FLOAT, sizeof(PositionMaterialNormal), (GLvoid*)12); glDrawRangeElements(GL_TRIANGLES, m_uBeginIndex, m_uEndIndex-1, m_uEndIndex - m_uBeginIndex, GL_UNSIGNED_INT, 0); } diff --git a/examples/Basic/OpenGLWidget.h b/examples/Basic/OpenGLWidget.h index 0e35819b..91027ece 100644 --- a/examples/Basic/OpenGLWidget.h +++ b/examples/Basic/OpenGLWidget.h @@ -41,7 +41,7 @@ public: void mousePressEvent(QMouseEvent* event); //Convert a SrfaceMesh to OpenGL index/vertex buffers - void setSurfaceMeshToRender(const PolyVox::SurfaceMesh& surfaceMesh); + void setSurfaceMeshToRender(const PolyVox::SurfaceMesh& surfaceMesh); protected: //Qt OpenGL functions diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 1ff76f13..51dd24e4 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -24,7 +24,7 @@ freely, subject to the following restrictions: #include "OpenGLWidget.h" #include "MaterialDensityPair.h" -#include "SurfaceExtractor.h" +#include "CubicSurfaceExtractorWithNormals.h" #include "SurfaceMesh.h" #include "Volume.h" @@ -82,8 +82,8 @@ int main(int argc, char *argv[]) createSphereInVolume(volData, 30); //Extract the surface - SurfaceMesh mesh; - SurfaceExtractor surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); + SurfaceMesh mesh; + CubicSurfaceExtractorWithNormals surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); surfaceExtractor.execute(); //Pass the surface to the OpenGL window diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.cpp b/examples/OpenGL/OpenGLImmediateModeSupport.cpp index 09990abf..165a068a 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.cpp +++ b/examples/OpenGL/OpenGLImmediateModeSupport.cpp @@ -29,9 +29,9 @@ freely, subject to the following restrictions: using namespace PolyVox; using namespace std; -void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel) +void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel) { - const vector& vecVertices = mesh.getVertices(); + const vector& vecVertices = mesh.getVertices(); const vector& vecIndices = mesh.getIndices(); int beginIndex = mesh.m_vecLodRecords[uLodLevel].beginIndex; @@ -41,7 +41,7 @@ void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLeve //for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) for(int index = beginIndex; index < endIndex; ++index) { - const SurfaceVertex& vertex = vecVertices[vecIndices[index]]; + const PositionMaterialNormal& vertex = vecVertices[vecIndices[index]]; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); //const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength); const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(mesh.m_Region.getLowerCorner()); diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.h b/examples/OpenGL/OpenGLImmediateModeSupport.h index 509ef440..9fdcc03f 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.h +++ b/examples/OpenGL/OpenGLImmediateModeSupport.h @@ -28,6 +28,6 @@ freely, subject to the following restrictions: #include "glew/glew.h" -void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel); +void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel); #endif //__OpenGLExample_OpenGLImmediateModeSupport_H__ diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp index a39592d0..50f464e7 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp @@ -29,7 +29,7 @@ freely, subject to the following restrictions: using namespace PolyVox; using namespace std; -OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh& mesh) +OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh& mesh) { //Represents our filled in OpenGL vertex and index buffer objects. OpenGLSurfaceMesh result; @@ -38,7 +38,7 @@ OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh& mesh) result.sourceMesh = &mesh; //Convienient access to the vertices and indices - const vector& vecVertices = mesh.getVertices(); + const vector& vecVertices = mesh.getVertices(); const vector& vecIndices = mesh.getIndices(); //If we have any indices... @@ -62,9 +62,9 @@ OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh& mesh) glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(GLfloat) * 9, 0, GL_STATIC_DRAW); GLfloat* ptr = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - for(vector::const_iterator iterVertex = vecVertices.begin(); iterVertex != vecVertices.end(); ++iterVertex) + for(vector::const_iterator iterVertex = vecVertices.begin(); iterVertex != vecVertices.end(); ++iterVertex) { - const SurfaceVertex& vertex = *iterVertex; + const PositionMaterialNormal& vertex = *iterVertex; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); //const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength); const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(mesh.m_Region.getLowerCorner()); diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h index b73ef7af..c8a03608 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h @@ -33,10 +33,10 @@ struct OpenGLSurfaceMesh GLulong noOfIndices; GLuint indexBuffer; GLuint vertexBuffer; - const PolyVox::SurfaceMesh* sourceMesh; + const PolyVox::SurfaceMesh* sourceMesh; }; -OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const PolyVox::SurfaceMesh& mesh); +OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const PolyVox::SurfaceMesh& mesh); void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel); #endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__ diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index 21da4d10..8bbc846d 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -89,7 +89,7 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //Extract the surface for this region //extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), meshCurrent); - polyvox_shared_ptr mesh(new SurfaceMesh); + polyvox_shared_ptr< SurfaceMesh > mesh(new SurfaceMesh); SurfaceExtractor surfaceExtractor(volData, PolyVox::Region(regLowerCorner, regUpperCorner), mesh.get()); surfaceExtractor.execute(); @@ -229,7 +229,7 @@ void OpenGLWidget::paintGL() Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); if(m_mapSurfaceMeshes.find(v3dRegPos) != m_mapSurfaceMeshes.end()) { - polyvox_shared_ptr meshCurrent = m_mapSurfaceMeshes[v3dRegPos]; + polyvox_shared_ptr< SurfaceMesh > meshCurrent = m_mapSurfaceMeshes[v3dRegPos]; unsigned int uLodLevel = 0; //meshCurrent->m_vecLodRecords.size() - 1; if(m_bUseOpenGLVertexBufferObjects) { diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index 9d05a01f..dd31af7f 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -73,7 +73,7 @@ class OpenGLWidget : public QGLWidget //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region std::map m_mapOpenGLSurfaceMeshes; - std::map > m_mapSurfaceMeshes; + std::map > > m_mapSurfaceMeshes; unsigned int m_uRegionSideLength; unsigned int m_uVolumeWidthInRegions; diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 367151b4..1566ea91 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -6,7 +6,6 @@ PROJECT(PolyVoxCore) SET(CORE_SRC_FILES source/ArraySizes.cpp source/GradientEstimators.cpp - source/SurfaceMesh.cpp source/Log.cpp source/Mesh.cpp source/MeshEdge.cpp @@ -24,6 +23,8 @@ SET(CORE_INC_FILES include/ArraySizes.h include/CubicSurfaceExtractor.h include/CubicSurfaceExtractor.inl + include/CubicSurfaceExtractorWithNormals.h + include/CubicSurfaceExtractorWithNormals.inl include/Filters.h include/Filters.inl include/GradientEstimators.inl @@ -39,6 +40,7 @@ SET(CORE_INC_FILES include/SurfaceExtractor.h include/SurfaceExtractor.inl include/SurfaceMesh.h + include/SurfaceMesh.inl include/SurfaceVertex.h include/Vector.h include/Vector.inl diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/CubicSurfaceExtractor.h index 516edaca..b2aa5ba1 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.h @@ -35,7 +35,7 @@ namespace PolyVox class CubicSurfaceExtractor { public: - CubicSurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result); + CubicSurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result); void execute(); @@ -45,7 +45,7 @@ namespace PolyVox VolumeSampler m_sampVolume; //The surface patch we are currently filling. - SurfaceMesh* m_meshCurrent; + SurfaceMesh* m_meshCurrent; //Information about the region we are currently processing Region m_regSizeInVoxels; diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl index f951444b..b77e287e 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl @@ -30,7 +30,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - CubicSurfaceExtractor::CubicSurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result) + CubicSurfaceExtractor::CubicSurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result) :m_volData(volData) ,m_sampVolume(volData) ,m_regSizeInVoxels(region) @@ -63,25 +63,25 @@ namespace PolyVox { int material = m_volData->getVoxelAt(x,y,z).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v2,v1); - m_meshCurrent->addTriangle(v1,v2,v3); + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); } if(currentVoxel < plusXVoxel) { int material = m_volData->getVoxelAt(x+1,y,z).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v1,v2); - m_meshCurrent->addTriangle(v1,v3,v2); + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); } int plusYVoxel = m_volData->getVoxelAt(x,y+1,z).getDensity() >= VoxelType::getThreshold(); @@ -89,25 +89,25 @@ namespace PolyVox { int material = m_volData->getVoxelAt(x,y,z).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v1,v2); - m_meshCurrent->addTriangle(v1,v3,v2); + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); } if(currentVoxel < plusYVoxel) { int material = m_volData->getVoxelAt(x,y+1,z).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v2,v1); - m_meshCurrent->addTriangle(v1,v2,v3); + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); } int plusZVoxel = m_volData->getVoxelAt(x,y,z+1).getDensity() >= VoxelType::getThreshold(); @@ -115,25 +115,25 @@ namespace PolyVox { int material = m_volData->getVoxelAt(x,y,z).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v2,v1); - m_meshCurrent->addTriangle(v1,v2,v3); + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); } if(currentVoxel < plusZVoxel) { int material = m_volData->getVoxelAt(x,y,z+1).getMaterial(); - uint32_t v0 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); - uint32_t v1 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); - uint32_t v2 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); - uint32_t v3 = m_meshCurrent->addVertex(SurfaceVertex(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterial(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), material)); - m_meshCurrent->addTriangle(v0,v1,v2); - m_meshCurrent->addTriangle(v1,v3,v2); + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); } } } diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h new file mode 100644 index 00000000..ecee9f3c --- /dev/null +++ b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h @@ -0,0 +1,58 @@ +/******************************************************************************* +Copyright (c) 2005-2009 David Williams + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*******************************************************************************/ + +#ifndef __PolyVox_CubicSurfaceExtractorWithNormals_H__ +#define __PolyVox_CubicSurfaceExtractorWithNormals_H__ + +#include "PolyVoxForwardDeclarations.h" +#include "VolumeSampler.h" + +#include "PolyVoxImpl/TypeDef.h" + +namespace PolyVox +{ + template + class CubicSurfaceExtractorWithNormals + { + public: + CubicSurfaceExtractorWithNormals(Volume* volData, Region region, SurfaceMesh* result); + + void execute(); + + private: + //The volume data and a sampler to access it. + Volume* m_volData; + VolumeSampler m_sampVolume; + + //The surface patch we are currently filling. + SurfaceMesh* m_meshCurrent; + + //Information about the region we are currently processing + Region m_regSizeInVoxels; + Region m_regSizeInCells; + }; +} + +#include "CubicSurfaceExtractorWithNormals.inl" + +#endif diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl new file mode 100644 index 00000000..1dcf6b73 --- /dev/null +++ b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl @@ -0,0 +1,150 @@ +/******************************************************************************* +Copyright (c) 2005-2009 David Williams + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*******************************************************************************/ + +#include "Array.h" +#include "MaterialDensityPair.h" +#include "SurfaceMesh.h" +#include "PolyVoxImpl/MarchingCubesTables.h" +#include "SurfaceVertex.h" + +namespace PolyVox +{ + template + CubicSurfaceExtractorWithNormals::CubicSurfaceExtractorWithNormals(Volume* volData, Region region, SurfaceMesh* result) + :m_volData(volData) + ,m_sampVolume(volData) + ,m_regSizeInVoxels(region) + ,m_meshCurrent(result) + { + m_regSizeInVoxels.cropTo(m_volData->getEnclosingRegion()); + m_regSizeInCells = m_regSizeInVoxels; + m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt16(1,1,1)); + + m_meshCurrent->clear(); + } + + template + void CubicSurfaceExtractorWithNormals::execute() + { + for(uint16_t z = m_regSizeInVoxels.getLowerCorner().getZ(); z < m_regSizeInVoxels.getUpperCorner().getZ(); z++) + { + for(uint16_t y = m_regSizeInVoxels.getLowerCorner().getY(); y < m_regSizeInVoxels.getUpperCorner().getY(); y++) + { + for(uint16_t x = m_regSizeInVoxels.getLowerCorner().getX(); x < m_regSizeInVoxels.getUpperCorner().getX(); x++) + { + uint16_t regX = x - m_regSizeInVoxels.getLowerCorner().getX(); + uint16_t regY = y - m_regSizeInVoxels.getLowerCorner().getY(); + uint16_t regZ = z - m_regSizeInVoxels.getLowerCorner().getZ(); + + int currentVoxel = m_volData->getVoxelAt(x,y,z).getDensity() >= VoxelType::getThreshold(); + + int plusXVoxel = m_volData->getVoxelAt(x+1,y,z).getDensity() >= VoxelType::getThreshold(); + if(currentVoxel > plusXVoxel) + { + int material = m_volData->getVoxelAt(x,y,z).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(1.0f, 0.0f, 0.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); + } + if(currentVoxel < plusXVoxel) + { + int material = m_volData->getVoxelAt(x+1,y,z).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(-1.0f, 0.0f, 0.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); + } + + int plusYVoxel = m_volData->getVoxelAt(x,y+1,z).getDensity() >= VoxelType::getThreshold(); + if(currentVoxel > plusYVoxel) + { + int material = m_volData->getVoxelAt(x,y,z).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 1.0f, 0.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); + } + if(currentVoxel < plusYVoxel) + { + int material = m_volData->getVoxelAt(x,y+1,z).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ - 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, -1.0f, 0.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); + } + + int plusZVoxel = m_volData->getVoxelAt(x,y,z+1).getDensity() >= VoxelType::getThreshold(); + if(currentVoxel > plusZVoxel) + { + int material = m_volData->getVoxelAt(x,y,z).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, 1.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v2,v1); + m_meshCurrent->addTriangleCubic(v1,v2,v3); + } + if(currentVoxel < plusZVoxel) + { + int material = m_volData->getVoxelAt(x,y,z+1).getMaterial(); + + uint32_t v0 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); + uint32_t v1 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX - 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); + uint32_t v2 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY - 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); + uint32_t v3 = m_meshCurrent->addVertex(PositionMaterialNormal(Vector3DFloat(regX + 0.5f, regY + 0.5f, regZ + 0.5f), Vector3DFloat(0.0f, 0.0f, -1.0f), material)); + + m_meshCurrent->addTriangleCubic(v0,v1,v2); + m_meshCurrent->addTriangleCubic(v1,v3,v2); + } + } + } + } + + m_meshCurrent->m_Region = m_regSizeInVoxels; + + m_meshCurrent->m_vecLodRecords.clear(); + LodRecord lodRecord; + lodRecord.beginIndex = 0; + lodRecord.endIndex = m_meshCurrent->getNoOfIndices(); + m_meshCurrent->m_vecLodRecords.push_back(lodRecord); + } +} \ No newline at end of file diff --git a/library/PolyVoxCore/include/GradientEstimators.h b/library/PolyVoxCore/include/GradientEstimators.h index 5df0de0e..4a493a94 100644 --- a/library/PolyVoxCore/include/GradientEstimators.h +++ b/library/PolyVoxCore/include/GradientEstimators.h @@ -55,7 +55,7 @@ namespace PolyVox template Vector3DFloat computeSmoothSobelGradient(VolumeSampler& volIter); - POLYVOXCORE_API void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod); + POLYVOXCORE_API void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod); POLYVOXCORE_API Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod); } diff --git a/library/PolyVoxCore/include/Mesh.h b/library/PolyVoxCore/include/Mesh.h index f3d25848..688da8ae 100644 --- a/library/PolyVoxCore/include/Mesh.h +++ b/library/PolyVoxCore/include/Mesh.h @@ -38,8 +38,8 @@ namespace PolyVox { public: - void buildFromMesh(SurfaceMesh* pMesh); - void fillMesh(SurfaceMesh* pMesh); + void buildFromMesh(SurfaceMesh* pMesh); + void fillMesh(SurfaceMesh* pMesh); void matchEdgePairs(void); void computeEdgeCosts(void); diff --git a/library/PolyVoxCore/include/MeshVertex.h b/library/PolyVoxCore/include/MeshVertex.h index 98f2f1dd..68a5b221 100644 --- a/library/PolyVoxCore/include/MeshVertex.h +++ b/library/PolyVoxCore/include/MeshVertex.h @@ -37,7 +37,7 @@ namespace PolyVox { public: MeshVertex(); - SurfaceVertex m_vertexData; + PositionMaterialNormal m_vertexData; //MeshEdge* m_pEdge; //std::set m_faces; //std::set m_edges; //Edges which have this vertex as the src diff --git a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h index 1eaa818c..38ee63a6 100644 --- a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -77,9 +77,10 @@ namespace PolyVox template class MaterialDensityPair; typedef MaterialDensityPair MaterialDensityPair44; - class SurfaceMesh; + template class SurfaceMesh; class Region; - class SurfaceVertex; + class PositionMaterial; + class PositionMaterialNormal; template class CubicSurfaceExtractor; template class SurfaceExtractor; diff --git a/library/PolyVoxCore/include/SurfaceExtractor.h b/library/PolyVoxCore/include/SurfaceExtractor.h index cc5b08bc..784f3615 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.h +++ b/library/PolyVoxCore/include/SurfaceExtractor.h @@ -35,7 +35,7 @@ namespace PolyVox class SurfaceExtractor { public: - SurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result); + SurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result); void execute(); @@ -84,7 +84,7 @@ namespace PolyVox uint32_t m_uNoOfOccupiedCells; //The surface patch we are currently filling. - SurfaceMesh* m_meshCurrent; + SurfaceMesh* m_meshCurrent; //Information about the region we are currently processing Region m_regSizeInVoxels; diff --git a/library/PolyVoxCore/include/SurfaceExtractor.inl b/library/PolyVoxCore/include/SurfaceExtractor.inl index 606a45aa..0e166974 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/SurfaceExtractor.inl @@ -30,7 +30,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - SurfaceExtractor::SurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result) + SurfaceExtractor::SurfaceExtractor(Volume* volData, Region region, SurfaceMesh* result) :m_volData(volData) ,m_sampVolume(volData) ,m_regSizeInVoxels(region) @@ -457,7 +457,7 @@ namespace PolyVox const uint8_t uMaterial = v000.getMaterial() | v100.getMaterial(); //Because one of these is 0, the or operation takes the max. - SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); //surfaceVertex.setOnGeometryEdge(isXEdge || isYEdge || isZEdge); surfaceVertex.setOnGeometryEdgeNegX(isNegXEdge); surfaceVertex.setOnGeometryEdgePosX(isPosXEdge); @@ -487,7 +487,7 @@ namespace PolyVox const uint8_t uMaterial = v000.getMaterial() | v010.getMaterial(); //Because one of these is 0, the or operation takes the max. - SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); //surfaceVertex.setOnGeometryEdge(isXEdge || isYEdge || isZEdge); surfaceVertex.setOnGeometryEdgeNegX(isNegXEdge); surfaceVertex.setOnGeometryEdgePosX(isPosXEdge); @@ -517,7 +517,7 @@ namespace PolyVox const uint8_t uMaterial = v000.getMaterial() | v001.getMaterial(); //Because one of these is 0, the or operation takes the max. - SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); //surfaceVertex.setOnGeometryEdge(isXEdge || isYEdge || isZEdge); surfaceVertex.setOnGeometryEdgeNegX(isNegXEdge); surfaceVertex.setOnGeometryEdgePosX(isPosXEdge); diff --git a/library/PolyVoxCore/include/SurfaceMesh.h b/library/PolyVoxCore/include/SurfaceMesh.h index e2ae6c91..c55fc392 100644 --- a/library/PolyVoxCore/include/SurfaceMesh.h +++ b/library/PolyVoxCore/include/SurfaceMesh.h @@ -42,7 +42,8 @@ namespace PolyVox int endIndex; //Let's put it just past the end STL style }; - class POLYVOXCORE_API SurfaceMesh + template + class SurfaceMesh { public: SurfaceMesh(); @@ -53,26 +54,21 @@ namespace PolyVox uint32_t getNoOfNonUniformTrianges(void) const; uint32_t getNoOfUniformTrianges(void) const; uint32_t getNoOfVertices(void) const; - std::vector& getRawVertexData(void); //FIXME - this should be removed - const std::vector& getVertices(void) const; + std::vector& getRawVertexData(void); //FIXME - this should be removed + const std::vector& getVertices(void) const; void addTriangle(uint32_t index0, uint32_t index1, uint32_t index2); - uint32_t addVertex(const SurfaceVertex& vertex); + void addTriangleCubic(uint32_t index0, uint32_t index1, uint32_t index2); + uint32_t addVertex(const VertexType& vertex); void clear(void); const bool isEmpty(void) const; void smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices = false); void sumNearbyNormals(bool bNormaliseResult = true); - polyvox_shared_ptr extractSubset(std::set setMaterials); + polyvox_shared_ptr< SurfaceMesh > extractSubset(std::set setMaterials); void generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices = false); - - - //Vector3DInt32 m_v3dRegionPosition; //FIXME - remove this? - - /*void growMaterialBoundary(void); - int countMaterialBoundary(void);*/ bool isSubset(std::bitset a, std::bitset b); @@ -90,7 +86,7 @@ namespace PolyVox public: std::vector m_vecTriangleIndices; - std::vector m_vecVertices; + std::vector m_vecVertices; std::vector m_vecLodRecords; @@ -107,4 +103,6 @@ namespace PolyVox }; } +#include "SurfaceMesh.inl" + #endif /* __SurfaceMesh_H__ */ diff --git a/library/PolyVoxCore/source/SurfaceMesh.cpp b/library/PolyVoxCore/include/SurfaceMesh.inl similarity index 82% rename from library/PolyVoxCore/source/SurfaceMesh.cpp rename to library/PolyVoxCore/include/SurfaceMesh.inl index a815a19d..65eda4da 100644 --- a/library/PolyVoxCore/source/SurfaceMesh.cpp +++ b/library/PolyVoxCore/include/SurfaceMesh.inl @@ -21,8 +21,6 @@ freely, subject to the following restrictions: distribution. *******************************************************************************/ -#include "SurfaceMesh.h" - #include #include #include @@ -31,26 +29,31 @@ using namespace std; namespace PolyVox { - SurfaceMesh::SurfaceMesh() + template + SurfaceMesh::SurfaceMesh() { m_iTimeStamp = -1; } - SurfaceMesh::~SurfaceMesh() + template + SurfaceMesh::~SurfaceMesh() { } - const std::vector& SurfaceMesh::getIndices(void) const + template + const std::vector& SurfaceMesh::getIndices(void) const { return m_vecTriangleIndices; } - uint32_t SurfaceMesh::getNoOfIndices(void) const + template + uint32_t SurfaceMesh::getNoOfIndices(void) const { return m_vecTriangleIndices.size(); } - uint32_t SurfaceMesh::getNoOfNonUniformTrianges(void) const + template + uint32_t SurfaceMesh::getNoOfNonUniformTrianges(void) const { uint32_t result = 0; for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) @@ -67,7 +70,8 @@ namespace PolyVox return result; } - uint32_t SurfaceMesh::getNoOfUniformTrianges(void) const + template + uint32_t SurfaceMesh::getNoOfUniformTrianges(void) const { uint32_t result = 0; for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) @@ -81,22 +85,26 @@ namespace PolyVox return result; } - uint32_t SurfaceMesh::getNoOfVertices(void) const + template + uint32_t SurfaceMesh::getNoOfVertices(void) const { return m_vecVertices.size(); } - std::vector& SurfaceMesh::getRawVertexData(void) + template + std::vector& SurfaceMesh::getRawVertexData(void) { return m_vecVertices; } - const std::vector& SurfaceMesh::getVertices(void) const + template + const std::vector& SurfaceMesh::getVertices(void) const { return m_vecVertices; } - void SurfaceMesh::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) + template + void SurfaceMesh::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) { m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); @@ -114,13 +122,23 @@ namespace PolyVox } } - uint32_t SurfaceMesh::addVertex(const SurfaceVertex& vertex) + template + void SurfaceMesh::addTriangleCubic(uint32_t index0, uint32_t index1, uint32_t index2) + { + m_vecTriangleIndices.push_back(index0); + m_vecTriangleIndices.push_back(index1); + m_vecTriangleIndices.push_back(index2); + } + + template + uint32_t SurfaceMesh::addVertex(const VertexType& vertex) { m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; } - void SurfaceMesh::clear(void) + template + void SurfaceMesh::clear(void) { m_vecVertices.clear(); m_vecTriangleIndices.clear(); @@ -128,7 +146,8 @@ namespace PolyVox m_mapUsedMaterials.clear(); } - const bool SurfaceMesh::isEmpty(void) const + template + const bool SurfaceMesh::isEmpty(void) const { return (getNoOfVertices() == 0) || (getNoOfIndices() == 0); } @@ -144,7 +163,8 @@ namespace PolyVox /// SurfaceMesh should be smoothed. This can cause dicontinuities between /// neighbouring patches. //////////////////////////////////////////////////////////////////////////////// - void SurfaceMesh::smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices) + template + void SurfaceMesh::smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices) { if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -162,13 +182,13 @@ namespace PolyVox for(vector::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();) { //Get the vertex data for the triangle - SurfaceVertex& v0 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v0 = m_vecVertices[*iterIndex]; Vector3DFloat& v0New = newPositions[*iterIndex]; iterIndex++; - SurfaceVertex& v1 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v1 = m_vecVertices[*iterIndex]; Vector3DFloat& v1New = newPositions[*iterIndex]; iterIndex++; - SurfaceVertex& v2 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v2 = m_vecVertices[*iterIndex]; Vector3DFloat& v2New = newPositions[*iterIndex]; iterIndex++; @@ -220,7 +240,8 @@ namespace PolyVox /// vertex. Usually, the resulting normals should be renormalised afterwards. /// Note: This function can cause lighting discontinuities accross region boundaries. //////////////////////////////////////////////////////////////////////////////// - void SurfaceMesh::sumNearbyNormals(bool bNormaliseResult) + template + void SurfaceMesh::sumNearbyNormals(bool bNormaliseResult) { if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -234,13 +255,13 @@ namespace PolyVox for(vector::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();) { - SurfaceVertex& v0 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v0 = m_vecVertices[*iterIndex]; Vector3DFloat& v0New = summedNormals[*iterIndex]; iterIndex++; - SurfaceVertex& v1 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v1 = m_vecVertices[*iterIndex]; Vector3DFloat& v1New = summedNormals[*iterIndex]; iterIndex++; - SurfaceVertex& v2 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v2 = m_vecVertices[*iterIndex]; Vector3DFloat& v2New = summedNormals[*iterIndex]; iterIndex++; @@ -261,12 +282,13 @@ namespace PolyVox } } - void SurfaceMesh::generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices) + template + void SurfaceMesh::generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices) { Vector3DFloat offset = static_cast(m_Region.getLowerCorner()); //Initially zero the normals - for(vector::iterator iterVertex = m_vecVertices.begin(); iterVertex != m_vecVertices.end(); iterVertex++) + for(vector::iterator iterVertex = m_vecVertices.begin(); iterVertex != m_vecVertices.end(); iterVertex++) { if(m_Region.containsPoint(iterVertex->getPosition() + offset, 0.001)) { @@ -276,11 +298,11 @@ namespace PolyVox for(vector::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();) { - SurfaceVertex& v0 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v0 = m_vecVertices[*iterIndex]; iterIndex++; - SurfaceVertex& v1 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v1 = m_vecVertices[*iterIndex]; iterIndex++; - SurfaceVertex& v2 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v2 = m_vecVertices[*iterIndex]; iterIndex++; Vector3DFloat triangleNormal = (v1.getPosition()-v0.getPosition()).cross(v2.getPosition()-v0.getPosition()); @@ -301,7 +323,7 @@ namespace PolyVox if(bNormalise) { - for(vector::iterator iterVertex = m_vecVertices.begin(); iterVertex != m_vecVertices.end(); iterVertex++) + for(vector::iterator iterVertex = m_vecVertices.begin(); iterVertex != m_vecVertices.end(); iterVertex++) { Vector3DFloat normal = iterVertex->getNormal(); normal.normalise(); @@ -312,7 +334,8 @@ namespace PolyVox //This function looks at every vertex in the mesh and determines //how many of it's neighbours have the same material. - void SurfaceMesh::countNoOfNeighboursUsingMaterial(void) + template + void SurfaceMesh::countNoOfNeighboursUsingMaterial(void) { //Find all the neighbouring vertices for each vertex std::vector< std::set > neighbouringVertices(m_vecVertices.size()); @@ -347,9 +370,10 @@ namespace PolyVox } } - polyvox_shared_ptr SurfaceMesh::extractSubset(std::set setMaterials) + template + polyvox_shared_ptr< SurfaceMesh > SurfaceMesh::extractSubset(std::set setMaterials) { - polyvox_shared_ptr result(new SurfaceMesh); + polyvox_shared_ptr< SurfaceMesh > result(new SurfaceMesh); if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -369,9 +393,9 @@ namespace PolyVox for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size(); triCt += 3) { - SurfaceVertex& v0 = m_vecVertices[m_vecTriangleIndices[triCt]]; - SurfaceVertex& v1 = m_vecVertices[m_vecTriangleIndices[triCt + 1]]; - SurfaceVertex& v2 = m_vecVertices[m_vecTriangleIndices[triCt + 2]]; + PositionMaterialNormal& v0 = m_vecVertices[m_vecTriangleIndices[triCt]]; + PositionMaterialNormal& v1 = m_vecVertices[m_vecTriangleIndices[triCt + 1]]; + PositionMaterialNormal& v2 = m_vecVertices[m_vecTriangleIndices[triCt + 2]]; if( (setMaterials.find(v0.getMaterial()) != setMaterials.end()) || @@ -427,18 +451,18 @@ namespace PolyVox void SurfaceMesh::growMaterialBoundary(void) { - std::vector vecNewVertices = m_vecVertices; + std::vector vecNewVertices = m_vecVertices; for(vector::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();) { - SurfaceVertex& v0 = m_vecVertices[*iterIndex]; - SurfaceVertex& v0New = vecNewVertices[*iterIndex]; + PositionMaterialNormal& v0 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v0New = vecNewVertices[*iterIndex]; iterIndex++; - SurfaceVertex& v1 = m_vecVertices[*iterIndex]; - SurfaceVertex& v1New = vecNewVertices[*iterIndex]; + PositionMaterialNormal& v1 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v1New = vecNewVertices[*iterIndex]; iterIndex++; - SurfaceVertex& v2 = m_vecVertices[*iterIndex]; - SurfaceVertex& v2New = vecNewVertices[*iterIndex]; + PositionMaterialNormal& v2 = m_vecVertices[*iterIndex]; + PositionMaterialNormal& v2New = vecNewVertices[*iterIndex]; iterIndex++; if(v0.m_bIsMaterialEdgeVertex || v1.m_bIsMaterialEdgeVertex || v2.m_bIsMaterialEdgeVertex) @@ -452,7 +476,8 @@ namespace PolyVox m_vecVertices = vecNewVertices; }*/ - void SurfaceMesh::decimate(float fMinDotProductForCollapse) + template + void SurfaceMesh::decimate(float fMinDotProductForCollapse) { // We will need the information from this function to // determine when material boundary edges can collapse. @@ -474,7 +499,8 @@ namespace PolyVox } // Returns true if every bit which is set in 'a' is also set in 'b'. The reverse does not need to be true. - bool SurfaceMesh::isSubset(std::bitset a, std::bitset b) + template + bool SurfaceMesh::isSubset(std::bitset a, std::bitset b) { bool result = true; @@ -493,7 +519,8 @@ namespace PolyVox return result; } - uint32_t SurfaceMesh::performDecimationPass(float fMinDotProductForCollapse) + template + uint32_t SurfaceMesh::performDecimationPass(float fMinDotProductForCollapse) { // I'm using a vector of lists here, rather than a vector of sets, // because I don't believe that duplicaes should occur. But this @@ -782,7 +809,8 @@ namespace PolyVox return noOfEdgesCollapsed; } - int SurfaceMesh::noOfDegenerateTris(void) + template + int SurfaceMesh::noOfDegenerateTris(void) { int count = 0; for(int triCt = 0; triCt < m_vecTriangleIndices.size();) @@ -802,7 +830,8 @@ namespace PolyVox return count; } - void SurfaceMesh::removeDegenerateTris(void) + template + void SurfaceMesh::removeDegenerateTris(void) { int noOfNonDegenerate = 0; int targetCt = 0; diff --git a/library/PolyVoxCore/include/SurfaceVertex.h b/library/PolyVoxCore/include/SurfaceVertex.h index ee28d7f9..3ad7dd56 100644 --- a/library/PolyVoxCore/include/SurfaceVertex.h +++ b/library/PolyVoxCore/include/SurfaceVertex.h @@ -44,12 +44,28 @@ namespace PolyVox VF_NO_OF_FLAGS }; - class POLYVOXCORE_API SurfaceVertex + class POLYVOXCORE_API PositionMaterial { public: - SurfaceVertex(); - SurfaceVertex(Vector3DFloat positionToSet, float materialToSet); - SurfaceVertex(Vector3DFloat positionToSet, Vector3DFloat normalToSet, float materialToSet); + PositionMaterial(); + PositionMaterial(Vector3DFloat positionToSet, float materialToSet); + + float getMaterial(void) const; + const Vector3DFloat& getPosition(void) const; + + void setMaterial(float materialToSet); + void setPosition(const Vector3DFloat& positionToSet); + public: + Vector3DFloat position; + float material; + }; + + class POLYVOXCORE_API PositionMaterialNormal + { + public: + PositionMaterialNormal(); + PositionMaterialNormal(Vector3DFloat positionToSet, float materialToSet); + PositionMaterialNormal(Vector3DFloat positionToSet, Vector3DFloat normalToSet, float materialToSet); float getMaterial(void) const; const Vector3DFloat& getNormal(void) const; @@ -83,11 +99,6 @@ namespace PolyVox float material; //FIXME: This shouldn't be float on CPU? std::bitset m_bFlags; }; - - - - - //bool operator < (const SurfaceVertexIterator& lhs, const SurfaceVertexIterator& rhs); } #endif diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index bf406a35..2e390c70 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -66,12 +66,12 @@ namespace PolyVox { } - template //////////////////////////////////////////////////////////////////////////////// /// The border value is returned whenever an atempt is made to read a voxel which /// is outside the extents of the volume. /// \return The value used for voxels outside of the volume //////////////////////////////////////////////////////////////////////////////// + template VoxelType Volume::getBorderValue(void) const { return m_pBorderBlock->getVoxelAt(0,0,0); diff --git a/library/PolyVoxCore/source/GradientEstimators.cpp b/library/PolyVoxCore/source/GradientEstimators.cpp index 54eb19f3..d2930364 100644 --- a/library/PolyVoxCore/source/GradientEstimators.cpp +++ b/library/PolyVoxCore/source/GradientEstimators.cpp @@ -30,10 +30,10 @@ using namespace std; namespace PolyVox { - void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod) + void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod) { - std::vector& vecVertices = mesh.getRawVertexData(); - std::vector::iterator iterSurfaceVertex = vecVertices.begin(); + std::vector& vecVertices = mesh.getRawVertexData(); + std::vector::iterator iterSurfaceVertex = vecVertices.begin(); while(iterSurfaceVertex != vecVertices.end()) { const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(mesh.m_Region.getLowerCorner()); diff --git a/library/PolyVoxCore/source/Mesh.cpp b/library/PolyVoxCore/source/Mesh.cpp index 686e7c62..d81f6cac 100644 --- a/library/PolyVoxCore/source/Mesh.cpp +++ b/library/PolyVoxCore/source/Mesh.cpp @@ -29,7 +29,7 @@ freely, subject to the following restrictions: namespace PolyVox { - void Mesh::buildFromMesh(SurfaceMesh* pMesh) + void Mesh::buildFromMesh(SurfaceMesh* pMesh) { //First we copy the vertices across. //We also keep track of where each vertex went @@ -186,7 +186,7 @@ namespace PolyVox } } - void Mesh::fillMesh(SurfaceMesh* pMesh) + void Mesh::fillMesh(SurfaceMesh* pMesh) { pMesh->clear(); diff --git a/library/PolyVoxCore/source/MeshEdge.cpp b/library/PolyVoxCore/source/MeshEdge.cpp index 33af62a3..5ac59007 100644 --- a/library/PolyVoxCore/source/MeshEdge.cpp +++ b/library/PolyVoxCore/source/MeshEdge.cpp @@ -72,8 +72,8 @@ namespace PolyVox void MeshEdge::computeEdgeCost(Mesh* pParentMesh) { - SurfaceVertex v0Data = m_pSrc->m_vertexData; - SurfaceVertex v1Data = m_pDest->m_vertexData; + PositionMaterialNormal v0Data = m_pSrc->m_vertexData; + PositionMaterialNormal v1Data = m_pDest->m_vertexData; m_fCost = 1000000.0f; diff --git a/library/PolyVoxCore/source/SurfaceVertex.cpp b/library/PolyVoxCore/source/SurfaceVertex.cpp index db0bf55f..4ab73489 100644 --- a/library/PolyVoxCore/source/SurfaceVertex.cpp +++ b/library/PolyVoxCore/source/SurfaceVertex.cpp @@ -27,41 +27,41 @@ freely, subject to the following restrictions: namespace PolyVox { - SurfaceVertex::SurfaceVertex() + PositionMaterialNormal::PositionMaterialNormal() { } - SurfaceVertex::SurfaceVertex(Vector3DFloat positionToSet, float materialToSet) + PositionMaterialNormal::PositionMaterialNormal(Vector3DFloat positionToSet, float materialToSet) :position(positionToSet) ,material(materialToSet) { } - SurfaceVertex::SurfaceVertex(Vector3DFloat positionToSet, Vector3DFloat normalToSet, float materialToSet) + PositionMaterialNormal::PositionMaterialNormal(Vector3DFloat positionToSet, Vector3DFloat normalToSet, float materialToSet) :position(positionToSet) ,normal(normalToSet) ,material(materialToSet) { } - float SurfaceVertex::getMaterial(void) const + float PositionMaterialNormal::getMaterial(void) const { return material; } - const Vector3DFloat& SurfaceVertex::getNormal(void) const + const Vector3DFloat& PositionMaterialNormal::getNormal(void) const { return normal; } - const Vector3DFloat& SurfaceVertex::getPosition(void) const + const Vector3DFloat& PositionMaterialNormal::getPosition(void) const { return position; } //Returns a value between 0-3, for how many geometry edges (X,Y,Z) this vertex is on. - /*unsigned int SurfaceVertex::getNoOfGeometryEdges(void) const + /*unsigned int PositionMaterialNormal::getNoOfGeometryEdges(void) const { unsigned int uIsOnEdgeX = static_cast(isOnGeometryEdgeX()); unsigned int uIsOnEdgeY = static_cast(isOnGeometryEdgeY()); @@ -69,17 +69,17 @@ namespace PolyVox return uIsOnEdgeX + uIsOnEdgeY + uIsOnEdgeZ; }*/ - bool SurfaceVertex::isOnEdge(void) const + bool PositionMaterialNormal::isOnEdge(void) const { return (isOnMaterialEdge() || isOnGeometryEdge()); } - bool SurfaceVertex::isOnMaterialEdge(void) const + bool PositionMaterialNormal::isOnMaterialEdge(void) const { return m_bFlags[VF_ON_MATERIAL_EDGE]; } - bool SurfaceVertex::isOnGeometryEdge(void) const + bool PositionMaterialNormal::isOnGeometryEdge(void) const { return m_bFlags [VF_ON_GEOMETRY_EDGE_NEG_X] || m_bFlags[VF_ON_GEOMETRY_EDGE_POS_X] || @@ -87,82 +87,117 @@ namespace PolyVox m_bFlags [VF_ON_GEOMETRY_EDGE_NEG_Z] || m_bFlags[VF_ON_GEOMETRY_EDGE_POS_Z]; } - bool SurfaceVertex::isOnGeometryEdgeNegX(void) const + bool PositionMaterialNormal::isOnGeometryEdgeNegX(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_X]; } - bool SurfaceVertex::isOnGeometryEdgePosX(void) const + bool PositionMaterialNormal::isOnGeometryEdgePosX(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_POS_X]; } - bool SurfaceVertex::isOnGeometryEdgeNegY(void) const + bool PositionMaterialNormal::isOnGeometryEdgeNegY(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_Y]; } - bool SurfaceVertex::isOnGeometryEdgePosY(void) const + bool PositionMaterialNormal::isOnGeometryEdgePosY(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_POS_Y]; } - bool SurfaceVertex::isOnGeometryEdgeNegZ(void) const + bool PositionMaterialNormal::isOnGeometryEdgeNegZ(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_Z]; } - bool SurfaceVertex::isOnGeometryEdgePosZ(void) const + bool PositionMaterialNormal::isOnGeometryEdgePosZ(void) const { return m_bFlags[VF_ON_GEOMETRY_EDGE_POS_Z]; } - void SurfaceVertex::setMaterial(float materialToSet) + void PositionMaterialNormal::setMaterial(float materialToSet) { material = materialToSet; } - void SurfaceVertex::setNormal(const Vector3DFloat& normalToSet) + void PositionMaterialNormal::setNormal(const Vector3DFloat& normalToSet) { normal = normalToSet; } - void SurfaceVertex::setOnMaterialEdge(bool bOnMaterialEdge) + void PositionMaterialNormal::setOnMaterialEdge(bool bOnMaterialEdge) { m_bFlags[VF_ON_MATERIAL_EDGE] = bOnMaterialEdge; } - void SurfaceVertex::setOnGeometryEdgeNegX(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgeNegX(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_X] = bOnRegionEdge; } - void SurfaceVertex::setOnGeometryEdgePosX(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgePosX(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_POS_X] = bOnRegionEdge; } - void SurfaceVertex::setOnGeometryEdgeNegY(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgeNegY(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_Y] = bOnRegionEdge; } - void SurfaceVertex::setOnGeometryEdgePosY(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgePosY(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_POS_Y] = bOnRegionEdge; } - void SurfaceVertex::setOnGeometryEdgeNegZ(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgeNegZ(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_NEG_Z] = bOnRegionEdge; } - void SurfaceVertex::setOnGeometryEdgePosZ(bool bOnRegionEdge) + void PositionMaterialNormal::setOnGeometryEdgePosZ(bool bOnRegionEdge) { m_bFlags[VF_ON_GEOMETRY_EDGE_POS_Z] = bOnRegionEdge; } - void SurfaceVertex::setPosition(const Vector3DFloat& positionToSet) + void PositionMaterialNormal::setPosition(const Vector3DFloat& positionToSet) + { + position = positionToSet; + } + + //////////////////////////////////////////////////////////////////////////////// + // PositionMaterial + //////////////////////////////////////////////////////////////////////////////// + + PositionMaterial::PositionMaterial() + { + } + + PositionMaterial::PositionMaterial(Vector3DFloat positionToSet, float materialToSet) + :position(positionToSet) + ,material(materialToSet) + { + + } + + float PositionMaterial::getMaterial(void) const + { + return material; + } + + const Vector3DFloat& PositionMaterial::getPosition(void) const + { + return position; + } + + void PositionMaterial::setMaterial(float materialToSet) + { + material = materialToSet; + } + + void PositionMaterial::setPosition(const Vector3DFloat& positionToSet) { position = positionToSet; }