Ocular Engine
MeshRenderable.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_CORE_SCENE_RENDERABLE_MESH__H__
19 #define __H__OCULAR_CORE_SCENE_RENDERABLE_MESH__H__
20 
21 #include "Scene/ARenderable.hpp"
22 
23 #include <vector>
24 
25 //------------------------------------------------------------------------------------------
26 
31 namespace Ocular
32 {
33  namespace Graphics
34  {
35  class Mesh;
36  class Material;
37  }
38 
43  namespace Core
44  {
45  class SceneObject;
46 
65  class MeshRenderable : public ARenderable
66  {
67  public:
68 
69  MeshRenderable(std::string const& name = "MeshRenderable", SceneObject* parent = nullptr);
70  virtual ~MeshRenderable();
71 
72  //------------------------------------------------------------
73  // Inherited Methods
74  //------------------------------------------------------------
75 
76  virtual bool initialize() override;
77 
78  virtual bool preRender() override;
79  virtual void render() override;
80  virtual void render(Graphics::Material* material) override;
81 
82  virtual void onLoad(BuilderNode const* node) override;
83  virtual void onSave(BuilderNode* node) const override;
84 
85  virtual void buildBounds(Math::BoundsSphere* sphere, Math::BoundsAABB* aabb, Math::BoundsOBB* obb, Math::Matrix4x4 const& matrix = Math::Matrix4x4()) override;
86 
90  virtual uint32_t getRenderPriority() const override;
91 
92  //------------------------------------------------------------
93  // Mesh Methods
94  //------------------------------------------------------------
95 
100  bool setMesh(std::string const& name);
101 
106  void setMesh(Graphics::Mesh* mesh);
107 
112  Graphics::Mesh* getMesh() const;
113 
114  //------------------------------------------------------------
115  // Material Methods
116  //------------------------------------------------------------
117 
124  uint32_t addMaterial(std::string const& name);
125 
132  uint32_t addMaterial(Graphics::Material* material);
133 
145  bool setMaterial(std::string const& name, uint32_t index = 0, bool resize = false);
146 
158  void setMaterial(Graphics::Material* material, uint32_t index = 0, bool resize = false);
159 
168  void removeMaterial(uint32_t index);
169 
176  Graphics::Material* getMaterial(uint32_t index = 0) const;
177 
181  uint32_t getNumMaterials() const;
182 
183  protected:
184 
185  bool validateMaterialIndex(uint32_t index, bool resize);
186  Graphics::Material* findMaterial(std::string const& name);
187 
188  //------------------------------------------------------------
189 
190  Graphics::Mesh* m_Mesh;
191  std::vector<Graphics::Material*> m_Materials;
192 
193  private:
194  };
195  }
196 }
197 
198 //------------------------------------------------------------------------------------------
199 
200 #endif
virtual void onLoad(BuilderNode const *node) override
Definition: MeshRenderable.cpp:113
virtual bool preRender() override
Definition: MeshRenderable.cpp:68
uint32_t getNumMaterials() const
Definition: MeshRenderable.cpp:355
uint32_t addMaterial(std::string const &name)
Definition: MeshRenderable.cpp:298
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: BoundsOBB.hpp:56
virtual void render() override
Definition: MeshRenderable.cpp:75
virtual uint32_t getRenderPriority() const override
Definition: MeshRenderable.cpp:245
Combination of a VertexBuffer and IndexBuffer.
Definition: Mesh.hpp:49
Definition: SceneObject.hpp:93
bool setMaterial(std::string const &name, uint32_t index=0, bool resize=false)
Definition: MeshRenderable.cpp:314
Graphics::Material * getMaterial(uint32_t index=0) const
Definition: MeshRenderable.cpp:343
Definition: ARenderable.hpp:53
bool setMesh(std::string const &name)
Definition: MeshRenderable.cpp:261
virtual void onSave(BuilderNode *node) const override
Definition: MeshRenderable.cpp:139
Graphics::Mesh * getMesh() const
Definition: MeshRenderable.cpp:289
Generic node system used for loading and saving SceneObjects and their components.
Definition: BuilderNode.hpp:51
A 4x4 column-major float matrix.
Definition: Matrix4x4.hpp:64
Definition: MeshRenderable.hpp:65
Definition: BoundsAABB.hpp:63
Definition: BoundsSphere.hpp:52
void removeMaterial(uint32_t index)
Definition: MeshRenderable.cpp:335
Definition: Material.hpp:62