move the model to the center,

clean up variables,
use delete[]
This commit is contained in:
Anakin
2016-12-01 19:51:11 +01:00
parent 1c0ed61b34
commit a47eefe92e
4 changed files with 24 additions and 9 deletions

View File

@@ -122,8 +122,8 @@ void OpenGLController::deleteVectors()
Segment* segmCuror = cursor->segmLst.back();
cursor->segmLst.pop_back();
delete segmCuror->uv;
delete segmCuror->vertex;
delete[] segmCuror->uv;
delete[] segmCuror->vertex;
while (!segmCuror->meshIndices.empty())
{
@@ -243,8 +243,13 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationY, glm::vec3(0, 1, 0));
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1));
glm::mat4 m4x4ModelCenter = glm::translate(
glm::mat4(1.0f),
glm::vec3(-sceneBoundingBox.center[0], -sceneBoundingBox.center[1], -sceneBoundingBox.center[2])
);
// Return MVP
return m4x4Projection * m4x4View * m4x4ModelRot * getModelMatrix(index);
return m4x4Projection * m4x4View * m4x4ModelRot * m4x4ModelCenter * getModelMatrix(index);
}
@@ -378,11 +383,12 @@ void OpenGLController::loadMsh(const char * path)
Object obj(path);
vModels = obj.getModels();
tempTexList = obj.getTextureList();
sceneBoundingBox = obj.getBoundgBox();
}
catch (std::invalid_argument e)
{
MessageBox(NULL, e.what(), "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
return; exit(1);
return;
}
// collect vertex data of all models