diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 4f0c0f2f..3e5c5785 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) auto mesh = extractMarchingCubesMesh(&volData, regToExtract); //Pass the surface to the OpenGL window - openGLWidget.addMesh(mesh); + openGLWidget.addMesh(mesh, Vector3DInt32(x, y, z)); meshCounter++; } diff --git a/examples/common/OpenGLWidget.h b/examples/common/OpenGLWidget.h index a1c1c37c..fe13a23a 100644 --- a/examples/common/OpenGLWidget.h +++ b/examples/common/OpenGLWidget.h @@ -38,6 +38,7 @@ struct OpenGLMeshData GLuint vertexBuffer; GLuint vertexArrayObject; PolyVox::Vector3DInt32 translation; + float scale; }; class OpenGLWidget : public QGLWidget @@ -60,7 +61,7 @@ public: // Convert a SurfaceMesh to OpenGL index/vertex buffers. Inlined because it's templatised. template - void addMesh(const MeshType& surfaceMesh) + void addMesh(const MeshType& surfaceMesh, const PolyVox::Vector3DInt32& translation = PolyVox::Vector3DInt32(0, 0, 0), float scale = 1.0f) { //Convienient access to the vertices and indices const auto& vecIndices = surfaceMesh.getIndices(); @@ -99,7 +100,8 @@ public: meshData.noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later - meshData.translation = surfaceMesh.m_Region.getLowerCorner(); + meshData.translation = translation; + meshData.scale = scale; mMeshData.push_back(meshData); }