TheAtlasEngine
 
Loading...
Searching...
No Matches
mesh.hpp
1#pragma once
2#define GLM_ENABLE_EXPERIMENTAL
3#include <glm/gtx/hash.hpp>
4#include <filesystem>
5#include <vulkan-cpp/uniform_buffer.hpp>
6#include <vulkan-cpp/vertex_buffer.hpp>
7#include <vulkan-cpp/index_buffer.hpp>
8#include <vulkan-cpp/texture.hpp>
9#include <drivers/vulkan-cpp/vk_physical_driver.hpp>
10#include <core/scene/components.hpp>
11
12namespace atlas::vk {
13
28 class mesh {
29 public:
30 mesh() = default;
31 mesh(std::span<::vk::vertex_input> p_vertices,
32 std::span<uint32_t> p_indices);
33 mesh(const std::filesystem::path& p_filename, bool p_flip = false);
34
36 void reload_mesh(const std::filesystem::path& p_path);
37
38 void draw(const VkCommandBuffer& p_command_buffer);
39
40 void destroy();
41
43 void add_diffuse(const std::filesystem::path& p_path);
44
45 void add_specular(const std::filesystem::path& p_path);
46
47 [[nodiscard]] ::vk::sample_image diffuse() const {
48 return m_diffuse.image();
49 }
50 [[nodiscard]] ::vk::sample_image specular() const {
51 return m_specular.image();
52 }
53
55 [[nodiscard]] bool loaded() const { return m_model_loaded; }
56
57 [[nodiscard]] bool diffuse_loaded() const { return m_diffuse.loaded(); }
58 [[nodiscard]] bool specular_loaded() const {
59 return m_specular.loaded();
60 }
61
62 void set_flip(bool p_flip) { m_flip = p_flip; }
63
64 private:
65 void load_obj(const std::filesystem::path& p_filename);
66
67 private:
68 vk_physical_driver m_physical;
69 VkDevice m_device = nullptr;
70 ::vk::texture m_diffuse;
71 ::vk::texture m_specular;
72 ::vk::vertex_buffer m_vbo{};
73 ::vk::index_buffer m_ibo{};
74 ::vk::uniform_buffer m_geoemtry_ubo;
75 ::vk::uniform_buffer m_material_ubo;
76 bool m_model_loaded = false;
77 bool m_flip = false;
78 };
79};
mesh class specifically defined with vulkan implementations for specific primitives TODO: Whenever we...
Definition mesh.hpp:28
void reload_mesh(const std::filesystem::path &p_path)
Reload mesh vertices and indices when requested.
void add_diffuse(const std::filesystem::path &p_path)
Loading single texture with specified std::filesystem::path.
bool loaded() const
Definition mesh.hpp:55