Radium Engine  1.5.0
Material.hpp
1 #pragma once
2 
3 #include <Engine/RaEngine.hpp>
4 
5 #include <map>
6 #include <string>
7 
8 // This include brings only the macro EIGEN_MAKE_ALIGNED_OPERATOR_NEW in the file scope.
9 // Need to be separated to reduce compilation time
10 #include <Core/Types.hpp>
11 
12 #include <Engine/Data/RenderParameters.hpp>
13 
14 namespace Ra {
15 namespace Engine {
16 namespace Data {
23 class RA_ENGINE_API Material : public Data::ShaderParameterProvider
24 {
25  public:
31  enum class MaterialAspect {
32  MAT_OPAQUE,
33  MAT_TRANSPARENT,
34  MAT_DENSITY
35  };
36 
37  public:
38  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
39 
40  protected:
47  explicit Material( const std::string& instanceName,
48  const std::string& materialName,
49  MaterialAspect aspect = MaterialAspect::MAT_OPAQUE );
50 
54  inline void setMaterialName( std::string newName ) { m_materialName = std::move( newName ); }
55 
56  public:
57  virtual ~Material() = default;
58 
62  inline const std::string& getInstanceName() const { return m_instanceName; }
63 
68  inline const std::string& getMaterialName() const { return m_materialName; }
69 
73  inline void setMaterialAspect( const MaterialAspect& aspect ) { m_aspect = aspect; }
74 
79  inline const MaterialAspect& getMaterialAspect() const { return m_aspect; }
80 
84  virtual bool isTransparent() const;
85 
97  std::list<std::string> getPropertyList() const override;
98 
106  virtual void setColoredByVertexAttrib( bool /* state */ ) {};
107 
111  virtual bool isColoredByVertexAttrib() const { return false; }
112 
116  inline void needUpdate() { m_isDirty = true; }
117 
118  protected:
120  std::string m_instanceName {};
122  MaterialAspect m_aspect { MaterialAspect::MAT_OPAQUE };
125  bool m_isDirty { true };
126 
127  private:
129  std::string m_materialName;
130 };
131 
132 } // namespace Data
133 } // namespace Engine
134 } // namespace Ra
const MaterialAspect & getMaterialAspect() const
Definition: Material.hpp:79
const std::string & getMaterialName() const
Definition: Material.hpp:68
void setMaterialName(std::string newName)
Definition: Material.hpp:54
virtual void setColoredByVertexAttrib(bool)
Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.
Definition: Material.hpp:106
void setMaterialAspect(const MaterialAspect &aspect)
Definition: Material.hpp:73
virtual bool isColoredByVertexAttrib() const
Indicates if the material takes the VERTEX_COLOR attribute into account.
Definition: Material.hpp:111
const std::string & getInstanceName() const
Definition: Material.hpp:62
Definition: Cage.cpp:3