include all parent modelmatrices
This commit is contained in:
parent
15743e11fa
commit
2524971d19
@ -102,6 +102,7 @@ private:
|
||||
void startGLEW();
|
||||
void setCallbackFunctions();
|
||||
|
||||
glm::mat4 getModelMatrix(unsigned int index);
|
||||
glm::mat4 getMVPMatrix(unsigned int index);
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
BIN
Release/Msh/structured.msh
Normal file
BIN
Release/Msh/structured.msh
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user