Radium Engine  1.5.20
Loading...
Searching...
No Matches
Material.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
5#include <map>
6#include <string>
7
8#include <Engine/Data/MaterialTextureSet.hpp>
9#include <Engine/Data/RenderParameters.hpp>
10#include <Engine/Data/Texture.hpp>
11#include <Engine/Data/TextureManager.hpp>
12#include <Engine/RadiumEngine.hpp>
13
14namespace Ra {
15namespace Engine {
16namespace Data {
17
23class 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
41 virtual ~Material() = default;
42
45 inline const std::string& getInstanceName() const { return m_instanceName; }
46
50 inline const std::string& getMaterialName() const { return m_materialName; }
51
55 inline void setMaterialAspect( const MaterialAspect& aspect ) { m_aspect = aspect; }
56
61 inline const MaterialAspect& getMaterialAspect() const { return m_aspect; }
62
65 virtual bool isTransparent() const { return m_aspect == MaterialAspect::MAT_TRANSPARENT; }
66
79 return ShaderParameterProvider::getPropertyList();
80 }
81
90 virtual void setColoredByVertexAttrib( [[maybe_unused]] bool state ) {};
91
94 virtual bool isColoredByVertexAttrib() const { return false; }
95
98 inline void needUpdate() { setDirty(); }
99
100 protected:
107 explicit Material( const std::string& instanceName,
108 const std::string& materialName,
109 MaterialAspect aspect = MaterialAspect::MAT_OPAQUE );
110
115 inline void setMaterialName( std::string newName ) { m_materialName = std::move( newName ); }
116
118 bool isDirty() { return m_isDirty; }
119
121 void setDirty() { m_isDirty = true; }
122
124 void setClean() { m_isDirty = false; }
125
126 private:
128 std::string m_instanceName {};
130 MaterialAspect m_aspect { MaterialAspect::MAT_OPAQUE };
133 bool m_isDirty { true };
135 std::string m_materialName;
136};
137
138} // namespace Data
139} // namespace Engine
140} // namespace Ra
Base class for materials.
Definition Material.hpp:24
const std::string & getInstanceName() const
Definition Material.hpp:45
const std::string & getMaterialName() const
Definition Material.hpp:50
virtual ~Material()=default
bool isDirty()
Return dirty state.
Definition Material.hpp:118
virtual void setColoredByVertexAttrib(bool state)
Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.
Definition Material.hpp:90
std::list< std::string > getPropertyList() const override
Get the list of properties the material migh use in a shader.
Definition Material.hpp:78
void setMaterialName(std::string newName)
Change the material name.
Definition Material.hpp:115
void setDirty()
Set dirty state to true.
Definition Material.hpp:121
void setMaterialAspect(const MaterialAspect &aspect)
Definition Material.hpp:55
void setClean()
Set dirty state to false.
Definition Material.hpp:124
virtual bool isColoredByVertexAttrib() const
Indicates if the material takes the VERTEX_COLOR attribute into account.
Definition Material.hpp:94
void needUpdate()
Mark the Material as needing update before the next OpenGL call.
Definition Material.hpp:98
MaterialAspect
Identifies the type of the material.
Definition Material.hpp:31
virtual bool isTransparent() const
Definition Material.hpp:65
const MaterialAspect & getMaterialAspect() const
Get the aspect (MAT_OPAQUE or MAT_TRANSPARENT) of the material.
Definition Material.hpp:61
Shader program parameter provider.
T move(T... args)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3