Radium Engine  1.5.20
Loading...
Searching...
No Matches
SimpleMaterial.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
5#include <Core/Utils/Color.hpp>
6#include <Engine/Data/Material.hpp>
7#include <Engine/Data/Texture.hpp>
8
9#include <string>
10
11namespace Ra {
12namespace Engine {
13namespace Data {
14
20namespace TextureSemantics {
22enum class SimpleMaterial { TEX_COLOR, TEX_MASK };
23} // namespace TextureSemantics
24
29class RA_ENGINE_API SimpleMaterial : public Material,
31 public MaterialTextureSet<TextureSemantics::SimpleMaterial>
32{
33 public:
38 explicit SimpleMaterial( const std::string& instanceName,
39 const std::string& materialName,
40 MaterialAspect aspect = MaterialAspect::MAT_OPAQUE );
41
46 void updateGL() override final;
47
48 inline void setColoredByVertexAttrib( bool state ) override;
49
50 inline bool isColoredByVertexAttrib() const override { return m_perVertexColor; }
51
52 inline void setColor( Core::Utils::Color c ) {
53 m_color = std::move( c );
54 needUpdate();
55 }
56
57 protected:
59 static void loadMetaData( nlohmann::json& destination );
60
61 private:
64 void updateRenderingParameters();
66 Core::Utils::Color m_color { 0.9, 0.9, 0.9, 1.0 };
68 bool m_perVertexColor { false };
69};
70
72 if ( state != m_perVertexColor ) {
73 m_perVertexColor = state;
74 needUpdate();
75 }
76}
77
78} // namespace Data
79} // namespace Engine
80} // namespace Ra
Base class to manage a set of textures indexed by semantic (enum).
Base class for materials.
Definition Material.hpp:24
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
Interface to define metadata (constraints, description, ...) for the editing of parameter set.
Base implementation for simple, monocolored, materials.
bool isColoredByVertexAttrib() const override
Indicates if the material takes the VERTEX_COLOR attribute into account.
void setColoredByVertexAttrib(bool state) override
Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.
T move(T... args)
SimpleMaterial
SimpleMaterial's textures.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3