Nameless Engine
Loading...
Searching...
No Matches
MeshData.h
1#pragma once
2
3// Custom.
4#include "math/GLMath.hpp"
5#include "io/Serializable.h"
6
7#include "MeshData.generated.h"
8
9namespace ne RNAMESPACE() {
10 class GpuResource;
11
16
24 this->pIndexBuffer = pIndexBuffer;
25 this->iIndexCount = iIndexCount;
26 }
27
30
32 unsigned int iIndexCount = 0;
33 };
34
40 struct MeshVertex { // not using inheritance to avoid extra fields that are not related to vertex
41 MeshVertex() = default;
42 ~MeshVertex() = default;
43
45 MeshVertex(const MeshVertex&) = default;
46
52 MeshVertex& operator=(const MeshVertex&) = default;
53
55 MeshVertex(MeshVertex&&) noexcept = default;
56
62 MeshVertex& operator=(MeshVertex&&) noexcept = default;
63
71 bool operator==(const MeshVertex& other) const;
72
73 // --------------------------------------------------------------------------------------
74
76 glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);
77
79 glm::vec3 normal = glm::vec3(0.0f, 0.0f, 0.0f);
80
82 glm::vec2 uv = glm::vec2(0.0f, 0.0f);
83
84 // --------------------------------------------------------------------------------------
85
86 // ! only vertex related fields (same as in shader) can be added here !
87 // (not deriving from `Serializable` to avoid extra fields that are not related to vertex)
88
89 // --------------------------------------------------------------------------------------
90 };
91
93 class RCLASS(Guid("b60e4b47-b1e6-4001-87a8-b7885b4e8383")) MeshData : public Serializable {
94 public:
96 using meshindex_t = unsigned int; // if making this dynamic (changes depending on the number of
97 // indices) change hardcoded FORMAT in the renderer
98
99 MeshData();
100 virtual ~MeshData() override = default;
101
103 MeshData(const MeshData&) = default;
104
110 MeshData& operator=(const MeshData&) = default;
111
113 MeshData(MeshData&&) noexcept = default;
114
120 MeshData& operator=(MeshData&&) noexcept = default;
121
127 std::vector<MeshVertex>* getVertices();
128
136 std::vector<std::vector<meshindex_t>>* getIndices();
137
138 private:
140 RPROPERTY(Serialize)
141 std::vector<MeshVertex> vVertices;
142
150 RPROPERTY(Serialize)
151 std::vector<std::vector<meshindex_t>> vIndices;
152
153 ne_MeshData_GENERATED
154 };
155}
156
157File_MeshData_GENERATED
Definition: GpuResource.h:16
Definition: GuidProperty.h:30
Definition: MeshData.h:93
MeshData(const MeshData &)=default
MeshData & operator=(const MeshData &)=default
unsigned int meshindex_t
Definition: MeshData.h:96
MeshData(MeshData &&) noexcept=default
Definition: Serializable.h:113
Definition: SerializeProperty.h:42
Definition: MeshData.h:13
MeshIndexBufferInfo(GpuResource *pIndexBuffer, unsigned int iIndexCount)
Definition: MeshData.h:23
GpuResource * pIndexBuffer
Definition: MeshData.h:29
unsigned int iIndexCount
Definition: MeshData.h:32
Definition: MeshData.h:40
glm::vec3 normal
Definition: MeshData.h:79
glm::vec2 uv
Definition: MeshData.h:82
MeshVertex(MeshVertex &&) noexcept=default
MeshVertex & operator=(const MeshVertex &)=default
glm::vec3 position
Definition: MeshData.h:76
MeshVertex(const MeshVertex &)=default