From 2b5b076b9814343f885c9de509625cfc87a3f4b6 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 20 Apr 2009 19:43:40 +0000 Subject: [PATCH] Adjusting example to use non-cubic volume... --- examples/OpenGL/OpenGLWidget.cpp | 6 ++++++ examples/OpenGL/OpenGLWidget.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index b0c2440b..cc4909c2 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -32,6 +32,10 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //If we have any volume data then generate the new surface patches. if(m_volData != 0) { + m_uVolumeWidthInRegions = volData->getWidth() / m_uRegionSideLength; + m_uVolumeHeightInRegions = volData->getHeight() / m_uRegionSideLength; + m_uVolumeDepthInRegions = volData->getDepth() / m_uRegionSideLength; + //Our volume is broken down into cuboid regions, and we create one mesh for each region. //This three-level for loop iterates over each region. for(PolyVox::uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) @@ -81,6 +85,8 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) } } } + + m_distance = m_volData->getLongestSideLength() / -2.0f; } } diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index 8bfd4b6f..9fffdbf2 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -54,6 +54,11 @@ 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_mapOpenGLSurfacePatches; std::map m_mapIndexedSurfacePatches; + + unsigned int m_uRegionSideLength; + unsigned int m_uVolumeWidthInRegions; + unsigned int m_uVolumeHeightInRegions; + unsigned int m_uVolumeDepthInRegions; }; #endif //__PolyVox_OpenGLWidget_H__ \ No newline at end of file