Each mesh now has it's own transform matrix applied, so that our example framework can support breaking a volume into regions.

This commit is contained in:
David Williams
2014-05-23 22:03:57 +02:00
parent 9f5b2e1659
commit 4f7e1e6846
3 changed files with 48 additions and 51 deletions

View File

@ -127,17 +127,14 @@ void OpenGLWidget::paintGL()
//Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QMatrix4x4 modelToWorldMatrix{};
//modelToWorldMatrix.rotate(m_xRotation, 0, 1, 0); //rotate around y-axis
//modelToWorldMatrix.rotate(m_yRotation, 1, 0, 0); //rotate around x-axis
//modelToWorldMatrix.translate(-32, -32, -32); //centre the model on the origin
shader.bind();
shader.setUniformValue("modelToWorldMatrix", modelToWorldMatrix); //Update to the latest camera matrix
for (OpenGLMeshData meshData : mMeshData)
{
QMatrix4x4 modelToWorldMatrix{};
modelToWorldMatrix.translate(meshData.translation.getX(), meshData.translation.getY(), meshData.translation.getZ()); // Centre the model on the origin
shader.setUniformValue("modelToWorldMatrix", modelToWorldMatrix); // Update to the latest camera matrix
glBindVertexArray(meshData.vertexArrayObject);
glDrawElements(GL_TRIANGLES, meshData.noOfIndices, GL_UNSIGNED_INT, 0);