scale everything to 1,

cloth not displayed completely,
corvette is not displayed why?
This commit is contained in:
Anakin 2016-12-02 12:10:52 +01:00
parent a47eefe92e
commit 9b3d12dfeb
3 changed files with 9 additions and 3 deletions

View File

@ -81,7 +81,7 @@ private:
float fRotationZ = 0; float fRotationZ = 0;
double dTranslationX = 0; double dTranslationX = 0;
double dTranslationY = 0; double dTranslationY = 0;
double dTranslationZ = 5; double dTranslationZ = 3;
// ======================================== // ========================================

View File

@ -243,13 +243,19 @@ glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationY, glm::vec3(0, 1, 0)); m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationY, glm::vec3(0, 1, 0));
m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1)); m4x4ModelRot = glm::rotate(m4x4ModelRot, fRotationZ, glm::vec3(0, 0, 1));
// move to center
glm::mat4 m4x4ModelCenter = glm::translate( glm::mat4 m4x4ModelCenter = glm::translate(
glm::mat4(1.0f), glm::mat4(1.0f),
glm::vec3(-sceneBoundingBox.center[0], -sceneBoundingBox.center[1], -sceneBoundingBox.center[2]) glm::vec3(-sceneBoundingBox.center[0], -sceneBoundingBox.center[1], -sceneBoundingBox.center[2])
); );
//scale to 1
float maxExtent = max(max(sceneBoundingBox.extents[0], sceneBoundingBox.extents[1]), sceneBoundingBox.extents[2]);
glm::mat4 m4x4Normalize = glm::mat4(1.0f);
m4x4Normalize = glm::scale(m4x4Normalize, glm::vec3(1/maxExtent, 1 / maxExtent, 1 / maxExtent));
// Return MVP // Return MVP
return m4x4Projection * m4x4View * m4x4ModelRot * m4x4ModelCenter * getModelMatrix(index); return m4x4Projection * m4x4View * m4x4ModelRot * m4x4Normalize * m4x4ModelCenter * getModelMatrix(index);
} }

View File

@ -17,7 +17,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\\quadPoly.msh");
do { do {
scene->updateScene(); scene->updateScene();