Changing the way the examples handle translation and scaling.

This commit is contained in:
David Williams 2014-05-25 21:29:44 +02:00
parent 6738c4fc9e
commit b63a09cab3
2 changed files with 5 additions and 3 deletions

View File

@ -192,7 +192,7 @@ int main(int argc, char *argv[])
auto mesh = extractMarchingCubesMesh(&volData, regToExtract); auto mesh = extractMarchingCubesMesh(&volData, regToExtract);
//Pass the surface to the OpenGL window //Pass the surface to the OpenGL window
openGLWidget.addMesh(mesh); openGLWidget.addMesh(mesh, Vector3DInt32(x, y, z));
meshCounter++; meshCounter++;
} }

View File

@ -38,6 +38,7 @@ struct OpenGLMeshData
GLuint vertexBuffer; GLuint vertexBuffer;
GLuint vertexArrayObject; GLuint vertexArrayObject;
PolyVox::Vector3DInt32 translation; PolyVox::Vector3DInt32 translation;
float scale;
}; };
class OpenGLWidget : public QGLWidget class OpenGLWidget : public QGLWidget
@ -60,7 +61,7 @@ public:
// Convert a SurfaceMesh to OpenGL index/vertex buffers. Inlined because it's templatised. // Convert a SurfaceMesh to OpenGL index/vertex buffers. Inlined because it's templatised.
template <typename MeshType> template <typename MeshType>
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 //Convienient access to the vertices and indices
const auto& vecIndices = surfaceMesh.getIndices(); const auto& vecIndices = surfaceMesh.getIndices();
@ -99,7 +100,8 @@ public:
meshData.noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later 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); mMeshData.push_back(meshData);
} }