diff options
Diffstat (limited to 'src/vk/graphics_pipeline.cpp')
-rw-r--r-- | src/vk/graphics_pipeline.cpp | 30 |
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. |