Use camera class

This commit is contained in:
saschawillems 2018-04-13 19:45:05 +02:00
parent 9310c34f07
commit 983c5d95da

View file

@ -87,12 +87,12 @@ public:
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
{
zoom = -7.5f;
zoomSpeed = 2.5f;
rotation = { 0.0f, -90.0f, 0.0f };
cameraPos = glm::vec3(2.5f, 2.5f, 0.0f);
title = "Multisampling";
settings.overlay = true;
camera.type = Camera::CameraType::lookat;
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
camera.setRotation(glm::vec3(0.0f, -90.0f, 0.0f));
camera.setTranslation(glm::vec3(2.5f, 2.5f, -7.5f));
}
~VulkanExample()
@ -681,19 +681,8 @@ public:
void updateUniformBuffers()
{
// Vertex shader
glm::mat4 viewMatrix = glm::mat4(1.0f);
uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);
viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));
float offset = 0.5f;
int uboIndex = 1;
uboVS.model = glm::mat4(1.0f);
uboVS.model = viewMatrix * glm::translate(uboVS.model, 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.model = camera.matrices.view;
memcpy(uniformBuffer.mapped, &uboVS, sizeof(uboVS));
}
@ -731,11 +720,9 @@ public:
if (!prepared)
return;
draw();
}
virtual void viewChanged()
{
updateUniformBuffers();
if (camera.updated) {
updateUniformBuffers();
}
}
// Returns the maximum sample count usable by the platform