diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 3e5c5785..586b5197 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -173,7 +173,6 @@ int main(int argc, char *argv[]) cout << endl << "Time taken = " << time.elapsed() / 1000.0f << "s" << endl << endl; const int32_t extractedRegionSize = 32; - const int32_t gapBetweenRegions = 1; // Set this to '1' int meshCounter = 0; for (int32_t z = 0; z < volData.getDepth(); z += extractedRegionSize) diff --git a/examples/common/OpenGLWidget.cpp b/examples/common/OpenGLWidget.cpp index 76bdff47..380c6fe0 100644 --- a/examples/common/OpenGLWidget.cpp +++ b/examples/common/OpenGLWidget.cpp @@ -135,7 +135,7 @@ void OpenGLWidget::paintGL() for (OpenGLMeshData meshData : mMeshData) { QMatrix4x4 modelToWorldMatrix{}; - modelToWorldMatrix.translate(meshData.translation.getX(), meshData.translation.getY(), meshData.translation.getZ()); + modelToWorldMatrix.translate(meshData.translation); modelToWorldMatrix.scale(meshData.scale); shader->setUniformValue("modelToWorldMatrix", modelToWorldMatrix); diff --git a/examples/common/OpenGLWidget.h b/examples/common/OpenGLWidget.h index fe13a23a..755563fa 100644 --- a/examples/common/OpenGLWidget.h +++ b/examples/common/OpenGLWidget.h @@ -31,16 +31,21 @@ distribution. #include #include +// This structure holds all the data required +// to render one of our meshes through OpenGL. struct OpenGLMeshData { GLuint noOfIndices; GLuint indexBuffer; GLuint vertexBuffer; GLuint vertexArrayObject; - PolyVox::Vector3DInt32 translation; + QVector3D translation; float scale; }; +// Our OpenGLWidget is used by all the examples to render the extracted meshes. It is +// fairly specific to our needs (you probably won't want to use it in your own project) +// but should provide a useful illustration of how PolyVox meshes can be rendered. class OpenGLWidget : public QGLWidget { public: @@ -51,9 +56,11 @@ public: void mouseMoveEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event); - // The viewable region can be adjusted so that this example framework can be use for different volume sizes. + // The viewable region can be adjusted so that this example framework can be used for different volume sizes. void setViewableRegion(PolyVox::Region viewableRegion); + // For our purposes we use a single shader for the whole volume, and + // this example framework is only meant to show a single volume at a time void setShader(QGLShaderProgram* shader) { this->shader = shader; @@ -100,14 +107,13 @@ public: meshData.noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later - meshData.translation = translation; + meshData.translation = QVector3D(translation.getX(), translation.getY(), translation.getZ()); meshData.scale = scale; mMeshData.push_back(meshData); } protected: - // Qt OpenGL functions void initializeGL();