Using morphable and freecam controllers in example app, blending matrices using vectors, improvements regarding updating projection matrices, removed FreeCam components from MorphableController, renamed variable to m_targetMorphStatePerspective, setting target morph state using setter

This commit is contained in:
Vladyslav Baranovskyi
2024-06-26 14:00:21 +03:00
parent 1fbd072429
commit a696ae2c7f
4 changed files with 27 additions and 71 deletions

View File

@@ -15,7 +15,7 @@ namespace OpenVulkano::Scene
Math::Matrix4f result;
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j) { result[i][j] = glm::mix(mat1[i][j], mat2[i][j], t); }
result[i] = Math::Utils::mix(mat1[i], mat2[i], t);
}
return result;
}
@@ -25,8 +25,17 @@ namespace OpenVulkano::Scene
PerspectiveCamera::UpdateProjectionMatrix();
float aspectH = m_aspect;
float aspectV = 1;
m_orthoMatrix = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane);
m_projection = BlendMatrices(m_projection, m_orthoMatrix, m_morphState);
UpdateViewProjectionMatrix();
if (m_morphState == 0) { UpdateViewProjectionMatrix(); }
else if (m_morphState == 1)
{
m_projection = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane);
UpdateViewProjectionMatrix();
}
else
{
m_orthoMatrix = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane);
m_projection = BlendMatrices(m_projection, m_orthoMatrix, m_morphState);
UpdateViewProjectionMatrix();
}
}
}