From 2524971d19b19713455e90a63bd9bf6376e0a463 Mon Sep 17 00:00:00 2001 From: Anakin Date: Sat, 12 Nov 2016 11:54:44 +0100 Subject: [PATCH] include all parent modelmatrices --- MshViewer/Header/OpenGLController.h | 1 + MshViewer/Source/OpenGlController.cpp | 22 +++++++++++++++++----- MshViewer/main.cpp | 3 +-- Release/Msh/structured.msh | Bin 0 -> 9136 bytes 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 Release/Msh/structured.msh diff --git a/MshViewer/Header/OpenGLController.h b/MshViewer/Header/OpenGLController.h index d5c9c3d..1132361 100644 --- a/MshViewer/Header/OpenGLController.h +++ b/MshViewer/Header/OpenGLController.h @@ -102,6 +102,7 @@ private: void startGLEW(); void setCallbackFunctions(); + glm::mat4 getModelMatrix(unsigned int index); glm::mat4 getMVPMatrix(unsigned int index); diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index bee631d..d2c4831 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -184,6 +184,22 @@ void OpenGLController::setCallbackFunctions() 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) { // Projection @@ -196,10 +212,6 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index) glm::vec3(0, 1, 0) ); - // Model - //TODO for all - glm::mat4 m4x4Model = vModels[index]->m4x4Translation; - // User controlled rotation glm::mat4 m4x4ModelRot = glm::mat4(1.0f); m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationX, glm::vec3(1, 0, 0)); @@ -207,7 +219,7 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index) m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1)); // Return MVP - return m4x4Projection * m4x4View * m4x4ModelRot * m4x4Model; + return m4x4Projection * m4x4View * m4x4ModelRot * getModelMatrix(index); } diff --git a/MshViewer/main.cpp b/MshViewer/main.cpp index 024d5cb..531e087 100644 --- a/MshViewer/main.cpp +++ b/MshViewer/main.cpp @@ -20,8 +20,7 @@ int main(int argc, char** argv) else scene = OpenGLController::getInstance(); - scene->loadMsh("..\\Release\\Msh\\multiModTex.msh"); - //scene->loadMsh("..\\Release\\Msh\\cubeTex.msh"); + scene->loadMsh("..\\Release\\Msh\\structured.msh"); do { scene->updateScene(); diff --git a/Release/Msh/structured.msh b/Release/Msh/structured.msh new file mode 100644 index 0000000000000000000000000000000000000000..3669c3ce2f8a1578e540587dd1fa563e73dd2cc6 GIT binary patch literal 9136 zcmcIp3v^Z0ncji$3<)ui2d@x95)c9;Bq1U9-o0<01jvI4QL!q9nh2~$zyMv)PFdS! zn_&T#z|g67grV}#rYb7Zakb&z)Yw)OmpWB^jJBYbVs(|&Izl_RnD5)??3y1D|&U6s7z3MhCaO{u}k@ z=o4zoon^tAl7{Lla1xC%@a3C88JE6mR&8o-UAw9!7kqh1LrFepUS6KEw-6dW``$lz z-~nlGXRNBUq@li){&_X5$SIEp&7EJg1^1%XRh#E-TD@w}*tGcv#jan!$%Hnsw;)dc zyyyR&V{IoI_2%@(@pskoibXYtVT--8*yg{iZh3VM z3N?XXg${deyFVx+?;W$em0L==m*=yUS$Tiz9p_m8aqqJow>0d*Wo4FftUphg_vX0w znLK6owqy30lrmLYU*oBpDV|%uFXCxyuYvf1WYq5?2L^i)r@g#9W!~q(_-obc6W`6j z$}H{UOA|m}49@cnH|A8I#vs?*dH?+~SiIY}>s+Fm)crllXVQZUcl-VTJ_Y=DF~(<7 z>XA~9<9sGSV?+vc#tOb?nz&cp_Zs)Bea}GL`<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