-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlve_model.hpp
More file actions
70 lines (53 loc) · 2.04 KB
/
lve_model.hpp
File metadata and controls
70 lines (53 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include "lve_buffer.hpp"
#include "lve_device.hpp"
// libs
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
// std
#include <memory>
#include <vector>
namespace lve {
class LveModel {
public:
struct Vertex {
glm::vec3 position{};
glm::vec3 color{};
glm::vec3 normal{};
glm::vec2 uv{};
static std::vector<VkVertexInputBindingDescription> getBindingDescriptions();
static std::vector<VkVertexInputAttributeDescription> getAttributeDescriptions();
bool operator==(const Vertex& other) const {
return position == other.position && color == other.color && normal == other.normal &&
uv == other.uv;
}
};
struct Builder {
std::vector<Vertex> vertices{};
std::vector<uint32_t> indices{};
void loadModel(const std::string& filepath);
};
LveModel(LveDevice& device, const LveModel::Builder& builder);
~LveModel();
//LveModel() = default;
LveModel(const LveModel&) = delete;
LveModel& operator=(const LveModel&) = delete;
static std::unique_ptr<LveModel> createModelFromFile(
LveDevice& device, const std::string& filepath);
void bind(VkCommandBuffer commandBuffer);
void draw(VkCommandBuffer commandBuffer);
//later let's add some blinn phong exponent term either here or in the Vertex Struct
// this term needs to be properly bound so it can be accessed in the point_light/mesh render system
float blinnPhongTerm = 512.f;
private:
void createVertexBuffers(const std::vector<Vertex>& vertices);
void createIndexBuffers(const std::vector<uint32_t>& indices);
LveDevice& lveDevice;
std::unique_ptr<LveBuffer> vertexBuffer;
uint32_t vertexCount;
bool hasIndexBuffer = false;
std::unique_ptr<LveBuffer> indexBuffer;
uint32_t indexCount;
};
} // namespace lve