Code-Cleanup: All samples now use the camera class and it's matrices
Cleaned up base class
This commit is contained in:
parent
27d5abc038
commit
ab38f8b150
42 changed files with 234 additions and 396 deletions
|
|
@ -649,7 +649,7 @@ public:
|
|||
|
||||
struct UBOVS {
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::mat4 modelView;
|
||||
glm::vec4 lightPos = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
} uboVS;
|
||||
|
||||
|
|
@ -662,11 +662,11 @@ public:
|
|||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
title = "Vulkan Example - Text overlay";
|
||||
settings.overlay = false;
|
||||
camera.type = Camera::CameraType::lookat;
|
||||
camera.setPosition(glm::vec3(0.0f, 0.0f, -4.5f));
|
||||
camera.setRotation(glm::vec3(-25.0f, -0.0f, 0.0f));
|
||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||
settings.overlay = false;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -749,7 +749,7 @@ public:
|
|||
{
|
||||
std::stringstream vpos;
|
||||
vpos << std::showpos << x << "/" << y << "/" << z;
|
||||
glm::vec3 projected = glm::project(glm::vec3((float)x, (float)y, (float)z), uboVS.model, uboVS.projection, glm::vec4(0, 0, (float)width, (float)height));
|
||||
glm::vec3 projected = glm::project(glm::vec3((float)x, (float)y, (float)z), uboVS.modelView, uboVS.projection, glm::vec4(0, 0, (float)width, (float)height));
|
||||
textOverlay->addText(vpos.str(), projected.x, projected.y + (y > -1 ? 5.0f : -20.0f), TextOverlay::alignCenter);
|
||||
}
|
||||
}
|
||||
|
|
@ -762,11 +762,11 @@ public:
|
|||
{
|
||||
ss.str("");
|
||||
ss << std::fixed << std::setprecision(2) << std::showpos;
|
||||
ss << uboVS.model[0][i] << " " << uboVS.model[1][i] << " " << uboVS.model[2][i] << " " << uboVS.model[3][i];
|
||||
ss << uboVS.modelView[0][i] << " " << uboVS.modelView[1][i] << " " << uboVS.modelView[2][i] << " " << uboVS.modelView[3][i];
|
||||
textOverlay->addText(ss.str(), (float)width, 25.0f + (float)i * 20.0f, TextOverlay::alignRight);
|
||||
}
|
||||
|
||||
glm::vec3 projected = glm::project(glm::vec3(0.0f), uboVS.model, uboVS.projection, glm::vec4(0, 0, (float)width, (float)height));
|
||||
glm::vec3 projected = glm::project(glm::vec3(0.0f), uboVS.modelView, uboVS.projection, glm::vec4(0, 0, (float)width, (float)height));
|
||||
textOverlay->addText("Uniform cube", projected.x, projected.y, TextOverlay::alignCenter);
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
|
@ -888,10 +888,7 @@ public:
|
|||
void updateUniformBuffers()
|
||||
{
|
||||
uboVS.projection = camera.matrices.perspective;
|
||||
uboVS.model = glm::rotate(glm::mat4(1.0f), 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.model = camera.matrices.view * uboVS.model;
|
||||
uboVS.modelView = camera.matrices.view;
|
||||
memcpy(uniformBuffer.mapped, &uboVS, sizeof(uboVS));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue