Renamed SurfaceMesh to just Mesh
This commit is contained in:
@ -24,12 +24,12 @@ freely, subject to the following restrictions:
|
||||
#include "OpenGLImmediateModeSupport.h"
|
||||
#include "OpenGLSupport.h"
|
||||
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Mesh.h"
|
||||
|
||||
using namespace PolyVox;
|
||||
using namespace std;
|
||||
|
||||
void renderRegionImmediateMode(PolyVox::SurfaceMesh<MarchingCubesVertex<MaterialDensityPair44> >& mesh, unsigned int uLodLevel)
|
||||
void renderRegionImmediateMode(PolyVox::Mesh<MarchingCubesVertex<MaterialDensityPair44> >& mesh, unsigned int uLodLevel)
|
||||
{
|
||||
const vector<MarchingCubesVertex<MaterialDensityPair44> >& vecVertices = mesh.getVertices();
|
||||
const vector<uint32_t>& vecIndices = mesh.getIndices();
|
||||
|
@ -29,6 +29,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "glew/glew.h"
|
||||
|
||||
void renderRegionImmediateMode(PolyVox::SurfaceMesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >& mesh, unsigned int uLodLevel);
|
||||
void renderRegionImmediateMode(PolyVox::Mesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >& mesh, unsigned int uLodLevel);
|
||||
|
||||
#endif //__OpenGLExample_OpenGLImmediateModeSupport_H__
|
||||
|
@ -25,15 +25,15 @@ freely, subject to the following restrictions:
|
||||
#include "OpenGLVertexBufferObjectSupport.h"
|
||||
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Mesh.h"
|
||||
|
||||
using namespace PolyVox;
|
||||
using namespace std;
|
||||
|
||||
OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh<MarchingCubesVertex<MaterialDensityPair44> >& mesh)
|
||||
OpenGLMesh BuildOpenGLMesh(const Mesh<MarchingCubesVertex<MaterialDensityPair44> >& mesh)
|
||||
{
|
||||
//Represents our filled in OpenGL vertex and index buffer objects.
|
||||
OpenGLSurfaceMesh result;
|
||||
OpenGLMesh result;
|
||||
|
||||
//The source
|
||||
result.sourceMesh = &mesh;
|
||||
@ -102,23 +102,23 @@ OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh<MarchingCubesVertex<M
|
||||
return result;
|
||||
}
|
||||
|
||||
void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel)
|
||||
void renderRegionVertexBufferObject(const OpenGLMesh& openGLMesh, unsigned int uLodLevel)
|
||||
{
|
||||
int beginIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].beginIndex;
|
||||
int endIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].endIndex;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, openGLSurfaceMesh.vertexBuffer);
|
||||
int beginIndex = openGLMesh.sourceMesh->m_vecLodRecords[uLodLevel].beginIndex;
|
||||
int endIndex = openGLMesh.sourceMesh->m_vecLodRecords[uLodLevel].endIndex;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, openGLMesh.vertexBuffer);
|
||||
glVertexPointer(3, GL_FLOAT, 36, 0);
|
||||
glNormalPointer(GL_FLOAT, 36, (GLvoid*)12);
|
||||
glColorPointer(3, GL_FLOAT, 36, (GLvoid*)24);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLSurfaceMesh.indexBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLMesh.indexBuffer);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
//glDrawElements(GL_TRIANGLES, openGLSurfaceMesh.noOfIndices, GL_UNSIGNED_INT, 0);
|
||||
glDrawRangeElements(GL_TRIANGLES, beginIndex, endIndex-1, endIndex - beginIndex,/* openGLSurfaceMesh.noOfIndices,*/ GL_UNSIGNED_INT, 0);
|
||||
//glDrawElements(GL_TRIANGLES, openGLMesh.noOfIndices, GL_UNSIGNED_INT, 0);
|
||||
glDrawRangeElements(GL_TRIANGLES, beginIndex, endIndex-1, endIndex - beginIndex,/* openGLMesh.noOfIndices,*/ GL_UNSIGNED_INT, 0);
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
@ -28,15 +28,15 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "glew/glew.h"
|
||||
|
||||
struct OpenGLSurfaceMesh
|
||||
struct OpenGLMesh
|
||||
{
|
||||
GLulong noOfIndices;
|
||||
GLuint indexBuffer;
|
||||
GLuint vertexBuffer;
|
||||
const PolyVox::SurfaceMesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >* sourceMesh;
|
||||
const PolyVox::Mesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >* sourceMesh;
|
||||
};
|
||||
|
||||
OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const PolyVox::SurfaceMesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >& mesh);
|
||||
void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel);
|
||||
OpenGLMesh BuildOpenGLMesh(const PolyVox::Mesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> >& mesh);
|
||||
void renderRegionVertexBufferObject(const OpenGLMesh& openGLMesh, unsigned int uLodLevel);
|
||||
|
||||
#endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__
|
||||
|
@ -50,8 +50,8 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
|
||||
void OpenGLWidget::setVolume(PolyVox::LargeVolume<MaterialDensityPair44>* volData)
|
||||
{
|
||||
//First we free anything from the previous volume (if there was one).
|
||||
m_mapOpenGLSurfaceMeshes.clear();
|
||||
m_mapSurfaceMeshes.clear();
|
||||
m_mapOpenGLMeshes.clear();
|
||||
m_mapMeshes.clear();
|
||||
m_volData = volData;
|
||||
|
||||
//If we have any volume data then generate the new surface patches.
|
||||
@ -87,7 +87,7 @@ void OpenGLWidget::setVolume(PolyVox::LargeVolume<MaterialDensityPair44>* volDat
|
||||
//Extract the surface for this region
|
||||
//extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), meshCurrent);
|
||||
|
||||
std::shared_ptr< SurfaceMesh<MarchingCubesVertex<MaterialDensityPair44> > > mesh(new SurfaceMesh<MarchingCubesVertex<MaterialDensityPair44> >);
|
||||
std::shared_ptr< Mesh<MarchingCubesVertex<MaterialDensityPair44> > > mesh(new Mesh<MarchingCubesVertex<MaterialDensityPair44> >);
|
||||
MarchingCubesSurfaceExtractor< LargeVolume<MaterialDensityPair44> > surfaceExtractor(volData, PolyVox::Region(regLowerCorner, regUpperCorner), mesh.get());
|
||||
surfaceExtractor.execute();
|
||||
|
||||
@ -105,12 +105,12 @@ void OpenGLWidget::setVolume(PolyVox::LargeVolume<MaterialDensityPair44>* volDat
|
||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
||||
if(m_bUseOpenGLVertexBufferObjects)
|
||||
{
|
||||
OpenGLSurfaceMesh openGLSurfaceMesh = BuildOpenGLSurfaceMesh(*(mesh.get()));
|
||||
m_mapOpenGLSurfaceMeshes.insert(make_pair(v3dRegPos, openGLSurfaceMesh));
|
||||
OpenGLMesh openGLMesh = BuildOpenGLMesh(*(mesh.get()));
|
||||
m_mapOpenGLMeshes.insert(make_pair(v3dRegPos, openGLMesh));
|
||||
}
|
||||
//else
|
||||
//{
|
||||
m_mapSurfaceMeshes.insert(make_pair(v3dRegPos, mesh));
|
||||
m_mapMeshes.insert(make_pair(v3dRegPos, mesh));
|
||||
//}
|
||||
//delete meshCurrent;
|
||||
}
|
||||
@ -191,13 +191,13 @@ void OpenGLWidget::paintGL()
|
||||
for(uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX)
|
||||
{
|
||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
||||
if(m_mapSurfaceMeshes.find(v3dRegPos) != m_mapSurfaceMeshes.end())
|
||||
if(m_mapMeshes.find(v3dRegPos) != m_mapMeshes.end())
|
||||
{
|
||||
std::shared_ptr< SurfaceMesh<MarchingCubesVertex<MaterialDensityPair44> > > meshCurrent = m_mapSurfaceMeshes[v3dRegPos];
|
||||
std::shared_ptr< Mesh<MarchingCubesVertex<MaterialDensityPair44> > > meshCurrent = m_mapMeshes[v3dRegPos];
|
||||
unsigned int uLodLevel = 0; //meshCurrent->m_vecLodRecords.size() - 1;
|
||||
if(m_bUseOpenGLVertexBufferObjects)
|
||||
{
|
||||
renderRegionVertexBufferObject(m_mapOpenGLSurfaceMeshes[v3dRegPos], uLodLevel);
|
||||
renderRegionVertexBufferObject(m_mapOpenGLMeshes[v3dRegPos], uLodLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ freely, subject to the following restrictions:
|
||||
#include <QTimer>
|
||||
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Mesh.h"
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
|
||||
#include "OpenGLImmediateModeSupport.h"
|
||||
@ -87,8 +87,8 @@ class OpenGLWidget : public QGLWidget
|
||||
PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>* m_volData;
|
||||
|
||||
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
|
||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh, Vector3DUint8Compare> m_mapOpenGLSurfaceMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, std::shared_ptr<PolyVox::SurfaceMesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> > >, Vector3DUint8Compare> m_mapSurfaceMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, OpenGLMesh, Vector3DUint8Compare> m_mapOpenGLMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, std::shared_ptr<PolyVox::Mesh<PolyVox::MarchingCubesVertex<PolyVox::MaterialDensityPair44> > >, Vector3DUint8Compare> m_mapMeshes;
|
||||
|
||||
unsigned int m_uRegionSideLength;
|
||||
unsigned int m_uVolumeWidthInRegions;
|
||||
|
@ -27,7 +27,7 @@ freely, subject to the following restrictions:
|
||||
#include "PolyVoxCore/LowPassFilter.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
#include "PolyVoxCore/RLEBlockCompressor.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Mesh.h"
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
|
||||
#include "OpenGLImmediateModeSupport.h"
|
||||
|
Reference in New Issue
Block a user