From e87f84af86eb2af35e0d28fb1a429d0c80e8ff0a Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 20 Apr 2009 19:51:10 +0000 Subject: [PATCH] Adjusting example to use non-cubic volume... --- examples/OpenGL/OpenGLWidget.cpp | 25 +++++++++++++------------ examples/OpenGL/OpenGLWidget.h | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index cc4909c2..e0921ca3 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -15,6 +15,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) { m_xRotation = 0; m_yRotation = 0; + m_uRegionSideLength = 16.0f; m_distance = -g_uVolumeSideLength / 2.0f; timer = new QTimer(this); @@ -38,11 +39,11 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //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) + for(PolyVox::uint16_t uRegionZ = 0; uRegionZ < m_uVolumeDepthInRegions; ++uRegionZ) { - for(PolyVox::uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(PolyVox::uint16_t uRegionY = 0; uRegionY < m_uVolumeHeightInRegions; ++uRegionY) { - for(PolyVox::uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(PolyVox::uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX) { //Create a new surface patch (which is basiaclly the PolyVox term for a mesh). IndexedSurfacePatch* ispCurrent = new IndexedSurfacePatch(); @@ -50,13 +51,13 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //Compute the extents of the current region //FIXME - This is a little complex? PolyVox could //provide more functions for dealing with regions? - PolyVox::uint16_t regionStartX = uRegionX * g_uRegionSideLength; - PolyVox::uint16_t regionStartY = uRegionY * g_uRegionSideLength; - PolyVox::uint16_t regionStartZ = uRegionZ * g_uRegionSideLength; + PolyVox::uint16_t regionStartX = uRegionX * m_uRegionSideLength; + PolyVox::uint16_t regionStartY = uRegionY * m_uRegionSideLength; + PolyVox::uint16_t regionStartZ = uRegionZ * m_uRegionSideLength; - PolyVox::uint16_t regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here? - PolyVox::uint16_t regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here? - PolyVox::uint16_t regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here? + PolyVox::uint16_t regionEndX = regionStartX + m_uRegionSideLength + 1; //Why do we need the '+1' here? + PolyVox::uint16_t regionEndY = regionStartY + m_uRegionSideLength + 1; //Why do we need the '+1' here? + PolyVox::uint16_t regionEndZ = regionStartZ + m_uRegionSideLength + 1; //Why do we need the '+1' here? Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ); Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ); @@ -154,11 +155,11 @@ void OpenGLWidget::paintGL() //Centre the volume on the origin glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2); - for(PolyVox::uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(PolyVox::uint16_t uRegionZ = 0; uRegionZ < m_uVolumeDepthInRegions; ++uRegionZ) { - for(PolyVox::uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(PolyVox::uint16_t uRegionY = 0; uRegionY < m_uVolumeHeightInRegions; ++uRegionY) { - for(PolyVox::uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(PolyVox::uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX) { Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); if(m_bUseOpenGLVertexBufferObjects) diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index 9fffdbf2..f72ba6ed 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -16,8 +16,8 @@ #include "Shapes.h" const PolyVox::uint16_t g_uVolumeSideLength = 128; -const PolyVox::uint16_t g_uRegionSideLength = 16; -const PolyVox::uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; +//const PolyVox::uint16_t g_uRegionSideLength = 16; +//const PolyVox::uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; class OpenGLWidget : public QGLWidget {