Radium Engine  1.5.20
Loading...
Searching...
No Matches
SimpleMaterial.cpp
1#include <Engine/Data/SimpleMaterial.hpp>
2#include <Engine/Data/TextureManager.hpp>
3#include <Engine/RadiumEngine.hpp>
4
5#include <fstream>
6
7namespace Ra {
8namespace Engine {
9namespace Data {
11 const std::string& materialName,
12 MaterialAspect aspect ) :
13 Material( instanceName, materialName, aspect ) {}
14
15void SimpleMaterial::updateRenderingParameters() {
16 auto& renderParameters = getParameters();
17 // update the rendering paramaters
18 renderParameters.setVariable( "material.color", m_color );
19 renderParameters.setVariable( "material.perVertexColor", m_perVertexColor );
20 Texture* tex = getTexture( SimpleMaterial::TextureSemantic::TEX_COLOR );
21 if ( tex != nullptr ) { renderParameters.setTexture( "material.tex.color", tex ); }
22 renderParameters.setVariable( "material.tex.hasColor", tex != nullptr );
23 tex = getTexture( SimpleMaterial::TextureSemantic::TEX_MASK );
24 if ( tex != nullptr ) { renderParameters.setTexture( "material.tex.mask", tex ); }
25 renderParameters.setVariable( "material.tex.hasMask", tex != nullptr );
26}
27
29 if ( !isDirty() ) { return; }
30
31 updateRenderingParameters();
32 setClean();
33}
34
35void SimpleMaterial::loadMetaData( nlohmann::json& destination ) {
36 ParameterSetEditingInterface::loadMetaData( "Simple", destination );
37}
38} // namespace Data
39} // namespace Engine
40} // namespace Ra
Texture * getTexture(const TextureSemantics::SimpleMaterial &semantic) const
Base class for materials.
Definition Material.hpp:24
bool isDirty()
Return dirty state.
Definition Material.hpp:118
void setClean()
Set dirty state to false.
Definition Material.hpp:124
MaterialAspect
Identifies the type of the material.
Definition Material.hpp:31
static void loadMetaData(const std::string &basename, nlohmann::json &destination)
Load the ParameterSet description.
void updateGL() override final
Update the openGL state of the material.
static void loadMetaData(nlohmann::json &destination)
Load the material parameter description.
SimpleMaterial(const std::string &instanceName, const std::string &materialName, MaterialAspect aspect=MaterialAspect::MAT_OPAQUE)
Construct a named material.
Represent a Texture of the engine.
Definition Texture.hpp:120
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3