#include <stdafx.h> #include "Mesh.h" #include "Context.h" #include "IO.h" namespace fpr { Mesh::Mesh( uint32_t mesh_index, vk::DeviceSize index_offset, uint32_t index_count, vk::DeviceSize vertex_offset, uint32_t vertex_count, const std::string& diffuse_name): m_index_offset(index_offset), m_index_count(index_count), m_vertex_offset(vertex_offset), m_vertex_count(vertex_count), m_albedo(CreateTexture(diffuse_name)), m_model_matrix({ glm::scale(glm::mat4(1.0f), glm::vec3(1.0f)) }), m_mesh_index(mesh_index) { } fpr::Texture* Mesh::CreateTexture(const std::string& texture_name) { auto& rendergraph = fpr::Context::Get().m_render_graph; bool already_loaded = rendergraph->DiffuseTextures.Exists(texture_name); //If texture is already loaded, just fetch it from the render graph. if(!already_loaded) [[likely]] { return rendergraph->DiffuseTextures.Add(texture_name, std::make_unique<fpr::Texture>(texture_name)); } return rendergraph->DiffuseTextures.Get(texture_name); } void Mesh::SetModelMatrix(const glm::mat4& new_model_mat) FPR_NOEXCEPT { m_model_matrix = new_model_mat; } [[nodiscard]] uint32_t Mesh::GetVertexCount() const FPR_NOEXCEPT { return m_vertex_count; } [[nodiscard]] uint32_t Mesh::GetIndexCount() const FPR_NOEXCEPT { return m_index_count; } vk::DeviceSize Mesh::GetIndexOffset() const FPR_NOEXCEPT { return m_index_offset; } vk::DeviceSize Mesh::GetVertexOffset() const FPR_NOEXCEPT { return m_vertex_offset; } const fpr::Texture* Mesh::GetTexture() const { return m_albedo; } const glm::mat4& Mesh::GetMatrix() const { return m_model_matrix; } uint32_t Mesh::GetMeshIndex() const { return m_mesh_index; } } // namespace fpr