Code-Cleanup: All samples now use the camera class and it's matrices

Cleaned up base class
This commit is contained in:
Sascha Willems 2020-04-22 20:58:24 +02:00
parent 27d5abc038
commit ab38f8b150
42 changed files with 234 additions and 396 deletions

View file

@ -131,9 +131,11 @@ public:
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
{
zoom = -20.0f;
rotation = { -15.0f, -390.0f, 0.0f };
title = "Projected shadow mapping";
camera.type = Camera::CameraType::lookat;
camera.setPosition(glm::vec3(0.0f, -0.0f, -20.0f));
camera.setRotation(glm::vec3(-15.0f, -390.0f, 0.0f));
camera.setPerspective(60.0f, (float)width / (float)height, 1.0f, 256.0f);
timerSpeed *= 0.5f;
settings.overlay = true;
}
@ -689,26 +691,16 @@ public:
{
// Shadow map debug quad
float AR = (float)height / (float)width;
uboVSquad.projection = glm::ortho(2.5f / AR, 0.0f, 0.0f, 2.5f, -1.0f, 1.0f);
uboVSquad.model = glm::mat4(1.0f);
memcpy(uniformBuffers.debug.mapped, &uboVSquad, sizeof(uboVSquad));
// 3D scene
uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);
uboVSscene.view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
uboVSscene.projection = camera.matrices.perspective;
uboVSscene.view = camera.matrices.view;
uboVSscene.model = glm::mat4(1.0f);
uboVSscene.lightPos = lightPos;
uboVSscene.depthBiasMVP = uboOffscreenVS.depthMVP;
memcpy(uniformBuffers.scene.mapped, &uboVSscene, sizeof(uboVSscene));
}