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

@ -74,7 +74,7 @@ public:
struct {
glm::mat4 projection;
glm::mat4 model;
glm::mat4 modelView;
} uboVS;
int vertexBufferSize;
@ -83,8 +83,11 @@ public:
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
{
zoom = -2.0f;
title = "Compute shader image load/store";
camera.type = Camera::CameraType::lookat;
camera.setPosition(glm::vec3(0.0f, 0.0f, -2.0f));
camera.setRotation(glm::vec3(0.0f));
camera.setPerspective(60.0f, (float)width * 0.5f / (float)height, 1.0f, 256.0f);
settings.overlay = true;
}
@ -613,15 +616,8 @@ public:
void updateUniformBuffers()
{
// Vertex shader uniform buffer block
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width*0.5f / (float)height, 0.1f, 256.0f);
glm::mat4 viewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, zoom));
uboVS.model = viewMatrix * glm::translate(glm::mat4(1.0f), cameraPos);
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
uboVS.projection = camera.matrices.perspective;
uboVS.modelView = camera.matrices.view;
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
}