summaryrefslogtreecommitdiff
path: root/src/vk/graphics_pipeline.cpp
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2022-08-22 17:26:43 -0300
committerFrederico Linhares <fred@linhares.blue>2022-08-22 17:50:58 -0300
commit42e03ddc3b28c41b81fb5410feb72750530ffa13 (patch)
tree3d13318c57d45eb93348edb63122258a61531eef /src/vk/graphics_pipeline.cpp
parent67b78f24a9ec8c823bbb8ff091ccd6bb4144a435 (diff)
feat Make camera and model instance more abstract
* src/camera.cpp src/camera.hpp: Remove the camera as Vector3D and Rotation3D are going to replace it. * src/model.cpp: Add draw command as instances do not exist anymore. * src/model/instance.cpp src/model/instance.hpp: Remove the instance as Vector3D and Rotation3D are going to replace it.
Diffstat (limited to 'src/vk/graphics_pipeline.cpp')
-rw-r--r--src/vk/graphics_pipeline.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/vk/graphics_pipeline.cpp b/src/vk/graphics_pipeline.cpp
index de08945..3956a99 100644
--- a/src/vk/graphics_pipeline.cpp
+++ b/src/vk/graphics_pipeline.cpp
@@ -845,7 +845,8 @@ namespace VK
GraphicsPipeline::GraphicsPipeline():
current_frame{0},
- camera{std::make_shared<VK::Camera>()},
+ camera_position{std::make_shared<glm::vec3>(0.0f, 0.0f, 0.0f)},
+ camera_rotation{std::make_shared<glm::vec3>(0.0f, 0.0f, 0.0f)},
models_to_draw{cg_core.vk_swapchain->images_count}
{
loader.execute(this);
@@ -952,17 +953,14 @@ GraphicsPipeline::draw()
{
// Object matrix.
glm::mat4 instance_matrix{1.0f};
+ instance_matrix = glm::translate(
+ instance_matrix, instances[i].position);
instance_matrix = glm::rotate(
- instance_matrix, glm::radians(instances[i].rotation.x),
- glm::vec3{1.0, 0.0, 0.0});
+ instance_matrix, instances[i].rotation.x, glm::vec3{1.0, 0.0, 0.0});
instance_matrix = glm::rotate(
- instance_matrix, glm::radians(instances[i].rotation.y),
- glm::vec3{0.0, 1.0, 0.0});
+ instance_matrix, instances[i].rotation.y, glm::vec3{0.0, 1.0, 0.0});
instance_matrix = glm::rotate(
- instance_matrix, glm::radians(instances[i].rotation.z),
- glm::vec3{0.0, 0.0, 1.0});
- instance_matrix = glm::translate(
- instance_matrix, instances[i].position);
+ instance_matrix, instances[i].rotation.z, glm::vec3{0.0, 0.0, 1.0});
ubo_model_instance.model[i] = instance_matrix;
}
@@ -982,16 +980,16 @@ GraphicsPipeline::draw()
// View matrix.
ubo_view_projection.view = glm::mat4{1.0f};
ubo_view_projection.view = glm::translate(
- ubo_view_projection.view, this->camera->position);
+ ubo_view_projection.view, *this->camera_position);
ubo_view_projection.view = glm::rotate(
- ubo_view_projection.view, this->camera->rotation.x,
- glm::vec3{1.0, 0.0, 0.0});
+ ubo_view_projection.view, this->camera_rotation->y,
+ glm::vec3{0.0, 1.0, 0.0});
ubo_view_projection.view = glm::rotate(
- ubo_view_projection.view, this->camera->rotation.y,
- glm::vec3{0.0, 1.0, 0.0});
+ ubo_view_projection.view, this->camera_rotation->x,
+ glm::vec3{1.0, 0.0, 0.0});
ubo_view_projection.view = glm::rotate(
- ubo_view_projection.view, this->camera->rotation.z,
- glm::vec3{0.0, 0.0, 1.0});
+ ubo_view_projection.view, this->camera_rotation->z,
+ glm::vec3{0.0, 0.0, 1.0});
ubo_view_projection.view = glm::inverse(ubo_view_projection.view);
// Projection matrix.