Ocular Engine
Mesh.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_GRAPHICS_MESH__H__
19 #define __H__OCULAR_GRAPHICS_MESH__H__
20 
21 #include "Resources/Resource.hpp"
22 #include "Graphics/Mesh/SubMesh.hpp"
23 #include "Math/Vector3.hpp"
24 
25 #include <vector>
26 
27 //------------------------------------------------------------------------------------------
28 
33 namespace Ocular
34 {
39  namespace Graphics
40  {
41  class SubMesh;
42  class VertexBuffer;
43  class IndexBuffer;
44 
49  class Mesh : public Core::Resource
50  {
51  public:
52 
53  Mesh();
54  virtual ~Mesh();
55 
56  //------------------------------------------------------------
57  // Virtual Methods
58  //------------------------------------------------------------
59 
65  virtual bool bind();
66 
72  virtual void unbind();
73 
77  virtual void unload() override;
78 
79  //------------------------------------------------------------
80  // Buffer Methods
81  //------------------------------------------------------------
82 
96  void setVertexBuffer(VertexBuffer* buffer, uint32_t submesh = 0);
97 
111  VertexBuffer* getVertexBuffer(uint32_t submesh = 0);
112 
122  void setIndexBuffer(IndexBuffer* buffer, uint32_t submesh = 0);
123 
131  IndexBuffer* getIndexBuffer(uint32_t submesh = 0);
132 
133  //------------------------------------------------------------
134  // Min/Max Point Methods
135  //------------------------------------------------------------
136 
141  void calculateMinMaxPoints();
142 
152  void setMinMaxPoints(Math::Vector3f const& min, Math::Vector3f const& max);
153 
164  Math::Vector3f const& getMinPoint() const;
165 
176  Math::Vector3f const& getMaxPoint() const;
177 
178  //------------------------------------------------------------
179  // Sub-Mesh Methods
180  //------------------------------------------------------------
181 
188  SubMesh* getSubMesh(uint32_t index) const;
189 
200  uint32_t addSubMesh(SubMesh* submesh = nullptr);
201 
214  bool setSubMesh(SubMesh* submesh, uint32_t index);
215 
222  bool removeSubMesh(uint32_t index);
223 
227  uint32_t getNumSubMeshes() const;
228 
229  protected:
230 
231  Math::Vector3f m_MinPoint;
232  Math::Vector3f m_MaxPoint;
233 
234  std::vector<SubMesh*> m_SubMeshes;
235 
236  private:
237  };
238  }
242 }
247 //------------------------------------------------------------------------------------------
248 
249 #endif
Definition: VertexBuffer.hpp:78
virtual void unload() override
Definition: Mesh.cpp:67
void setIndexBuffer(IndexBuffer *buffer, uint32_t submesh=0)
Definition: Mesh.cpp:112
uint32_t getNumSubMeshes() const
Definition: Mesh.cpp:280
void setVertexBuffer(VertexBuffer *buffer, uint32_t submesh=0)
Definition: Mesh.cpp:82
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
bool removeSubMesh(uint32_t index)
Definition: Mesh.cpp:261
virtual void unbind()
Definition: Mesh.cpp:62
Math::Vector3f const & getMinPoint() const
Definition: Mesh.cpp:193
Combination of a VertexBuffer and IndexBuffer.
Definition: Mesh.hpp:49
bool setSubMesh(SubMesh *submesh, uint32_t index)
Definition: Mesh.cpp:235
uint32_t addSubMesh(SubMesh *submesh=nullptr)
Definition: Mesh.cpp:219
SubMesh * getSubMesh(uint32_t index) const
Definition: Mesh.cpp:207
VertexBuffer * getVertexBuffer(uint32_t submesh=0)
Definition: Mesh.cpp:95
void calculateMinMaxPoints()
Definition: Mesh.cpp:146
Math::Vector3f const & getMaxPoint() const
Definition: Mesh.cpp:198
Definition: IndexBuffer.hpp:77
virtual bool bind()
Definition: Mesh.cpp:55
void setMinMaxPoints(Math::Vector3f const &min, Math::Vector3f const &max)
Definition: Mesh.cpp:187
Combination of a VertexBuffer and IndexBuffer.
Definition: SubMesh.hpp:45
Definition: Resource.hpp:46
IndexBuffer * getIndexBuffer(uint32_t submesh=0)
Definition: Mesh.cpp:125