Lugdunum  0.1.0
Mesh.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <vector>
5 
9 #include <lug/Math/Vector.hpp>
10 
11 namespace lug {
12 namespace Graphics {
13 
14 // For friend
15 namespace Builder {
16 class Mesh;
17 } // Builder
18 
19 namespace Render {
20 
26 class LUG_GRAPHICS_API Mesh : public Resource {
27  friend class ::lug::Graphics::Builder::Mesh;
28 
29 public:
33  struct PrimitiveSet {
34  struct Attribute {
35  enum class Type : uint8_t {
36  Indice,
37  Position,
38  Normal,
39  TexCoord,
40  Tangent,
41  Color,
42  } type;
43 
47  struct Buffer {
48  char* data{nullptr};
49  uint32_t size{0};
50  uint32_t elementsCount{0};
51  } buffer;
52 
53  void* _data{nullptr}; // Specific to each Renderer
54  };
55 
59  enum class Mode : uint8_t {
60  Points = 0,
61  Lines = 1,
62  LineStrip = 3,
63  Triangles = 4,
64  TriangleStrip = 5,
65  TriangleFan = 6
66  } mode{Mode::Triangles};
67 
68  std::vector<Attribute> attributes{};
69 
70  Attribute* indices{nullptr};
71  Attribute* position{nullptr};
72  Attribute* normal{nullptr};
73  std::vector<Attribute*> texCoords{};
74  std::vector<Attribute*> colors{};
75  Attribute* tangent{nullptr};
76 
77  Resource::SharedPtr<Material> material{nullptr};
78 
79  void* _data{nullptr}; // Specific to each Renderer
80  };
81 
82 public:
83  Mesh(const Mesh&) = delete;
84  Mesh(Mesh&&) = delete;
85 
86  Mesh& operator=(const Mesh&) = delete;
87  Mesh& operator=(Mesh&&) = delete;
88 
89  virtual ~Mesh();
90 
91  const std::vector<Mesh::PrimitiveSet>& getPrimitiveSets() const;
92 
93 protected:
94  explicit Mesh(const std::string& name);
95 
96 protected:
97  std::vector<PrimitiveSet> _primitiveSets;
98 };
99 
101 
102 } // Render
103 } // Graphics
104 } // lug
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
Describes part of a Mesh.
Definition: Mesh.hpp:33
A Mesh, which itsef is a Resource. A mesh is composed of a vector of PrimitiveSet.
Definition: Mesh.hpp:26
Dummy class for a shared pointer.
Definition: Resource.hpp:66
std::vector< PrimitiveSet > _primitiveSets
Definition: Mesh.hpp:97
Class for resource.
Definition: Resource.hpp:17
Access to the data of the attribute.
Definition: Mesh.hpp:47
Mode
Type of the primitive set, defaults to Triangles.
Definition: Mesh.hpp:59