Skip to content
Snippets Groups Projects
Commit 2524971d authored by Anakin's avatar Anakin
Browse files

include all parent modelmatrices

parent 15743e11
No related branches found
No related tags found
No related merge requests found
...@@ -102,6 +102,7 @@ private: ...@@ -102,6 +102,7 @@ private:
void startGLEW(); void startGLEW();
void setCallbackFunctions(); void setCallbackFunctions();
glm::mat4 getModelMatrix(unsigned int index);
glm::mat4 getMVPMatrix(unsigned int index); glm::mat4 getMVPMatrix(unsigned int index);
......
...@@ -184,6 +184,22 @@ void OpenGLController::setCallbackFunctions() ...@@ -184,6 +184,22 @@ void OpenGLController::setCallbackFunctions()
glfwSetKeyCallback(pWindow, keyPress); glfwSetKeyCallback(pWindow, keyPress);
} }
glm::mat4 OpenGLController::getModelMatrix(unsigned int index)
{
glm::mat4 tempParentMatrix = glm::mat4(1.0f);
for (unsigned int loop = 0; loop < vModels.size(); loop++)
{
if (!strcmp(vModels[index]->parent.c_str(), vModels[loop]->name.c_str()))
{
tempParentMatrix = getModelMatrix(loop);
break;
}
}
return tempParentMatrix * vModels[index]->m4x4Translation;
}
glm::mat4 OpenGLController::getMVPMatrix(unsigned int index) glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
{ {
// Projection // Projection
...@@ -196,10 +212,6 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index) ...@@ -196,10 +212,6 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
glm::vec3(0, 1, 0) glm::vec3(0, 1, 0)
); );
// Model
//TODO for all
glm::mat4 m4x4Model = vModels[index]->m4x4Translation;
// User controlled rotation // User controlled rotation
glm::mat4 m4x4ModelRot = glm::mat4(1.0f); glm::mat4 m4x4ModelRot = glm::mat4(1.0f);
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationX, glm::vec3(1, 0, 0)); m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationX, glm::vec3(1, 0, 0));
...@@ -207,7 +219,7 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index) ...@@ -207,7 +219,7 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1)); m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1));
// Return MVP // Return MVP
return m4x4Projection * m4x4View * m4x4ModelRot * m4x4Model; return m4x4Projection * m4x4View * m4x4ModelRot * getModelMatrix(index);
} }
......
...@@ -20,8 +20,7 @@ int main(int argc, char** argv) ...@@ -20,8 +20,7 @@ int main(int argc, char** argv)
else else
scene = OpenGLController::getInstance(); scene = OpenGLController::getInstance();
scene->loadMsh("..\\Release\\Msh\\multiModTex.msh"); scene->loadMsh("..\\Release\\Msh\\structured.msh");
//scene->loadMsh("..\\Release\\Msh\\cubeTex.msh");
do { do {
scene->updateScene(); scene->updateScene();
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment