Radium Engine  1.5.0
Ra::Engine::Data::SimpleMaterial Class Reference

#include <Engine/Data/SimpleMaterial.hpp>

+ Inheritance diagram for Ra::Engine::Data::SimpleMaterial:
+ Collaboration diagram for Ra::Engine::Data::SimpleMaterial:

Public Types

enum class  TextureSemantic { TEX_COLOR , TEX_MASK }
 Semantic of the texture : define which BSDF parameter is controled by the texture.
 
- Public Types inherited from Ra::Engine::Data::Material
enum class  MaterialAspect { MAT_OPAQUE , MAT_TRANSPARENT , MAT_DENSITY }
 

Public Member Functions

 SimpleMaterial (const std::string &instanceName, const std::string &materialName, MaterialAspect aspect=MaterialAspect::MAT_OPAQUE)
 
 ~SimpleMaterial () override
 
void updateGL () override final
 
TextureParametersaddTexture (const TextureSemantic &semantic, const TextureParameters &texture)
 
void addTexture (const TextureSemantic &semantic, Texture *texture)
 
TexturegetTexture (const TextureSemantic &semantic) const
 
void setColoredByVertexAttrib (bool state) override
 Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry. More...
 
bool isColoredByVertexAttrib () const override
 Indicates if the material takes the VERTEX_COLOR attribute into account.
 
- Public Member Functions inherited from Ra::Engine::Data::Material
const std::string & getInstanceName () const
 
const std::string & getMaterialName () const
 
void setMaterialAspect (const MaterialAspect &aspect)
 
const MaterialAspectgetMaterialAspect () const
 
virtual bool isTransparent () const
 
std::list< std::string > getPropertyList () const override
 
void needUpdate ()
 
- Public Member Functions inherited from Ra::Engine::Data::ShaderParameterProvider
virtual RenderParametersgetParameters ()
 
virtual const RenderParametersgetParameters () const
 
virtual void updateFromParameters ()
 Update the attributes of the ShaderParameterProvider to their actual values stored in the renderParameters.
 
- Public Member Functions inherited from Ra::Engine::Data::ParameterSetEditingInterface
virtual nlohmann::json getParametersMetadata () const =0
 Get a json containing metadata about the parameters. More...
 

Public Attributes

Core::Utils::Color m_color { 0.9, 0.9, 0.9, 1.0 }
 The base color of the material.
 
bool m_perVertexColor { false }
 

Static Protected Member Functions

static void loadMetaData (nlohmann::json &destination)
 Load the material parameter description.
 

Additional Inherited Members

- Static Public Member Functions inherited from Ra::Engine::Data::ParameterSetEditingInterface
static void loadMetaData (const std::string &basename, nlohmann::json &destination)
 Load the ParameterSet description.
 
- Protected Member Functions inherited from Ra::Engine::Data::Material
 Material (const std::string &instanceName, const std::string &materialName, MaterialAspect aspect=MaterialAspect::MAT_OPAQUE)
 
void setMaterialName (std::string newName)
 
- Protected Attributes inherited from Ra::Engine::Data::Material
std::string m_instanceName {}
 Material instance name.
 
MaterialAspect m_aspect { MaterialAspect::MAT_OPAQUE }
 Material aspect.
 
bool m_isDirty { true }
 

Detailed Description

Base implementation for simple, monocolored, materials. This material could not be used as is. Only derived class could be used by a renderer.

Definition at line 19 of file SimpleMaterial.hpp.

Constructor & Destructor Documentation

◆ SimpleMaterial()

Ra::Engine::Data::SimpleMaterial::SimpleMaterial ( const std::string &  instanceName,
const std::string &  materialName,
MaterialAspect  aspect = MaterialAspect::MAT_OPAQUE 
)
explicit

Construct a named material

Parameters
nameThe name of the material

Definition at line 10 of file SimpleMaterial.cpp.

◆ ~SimpleMaterial()

Ra::Engine::Data::SimpleMaterial::~SimpleMaterial ( )
override

Destructor.

Note
The material does not have ownership on its texture. This destructor do not delete the associated textures.

Definition at line 15 of file SimpleMaterial.cpp.

Member Function Documentation

◆ addTexture() [1/2]

TextureParameters & Ra::Engine::Data::SimpleMaterial::addTexture ( const TextureSemantic semantic,
const TextureParameters texture 
)
inline

Add an new texture, from a TextureParameters, to control the specified BSDF parameter. The textures will be finalized (i.e loaded from a file if needed and transformed to OpenGL texture) only when needed by the updateGL method.

Parameters
semanticThe texture semantic
textureThe texture to use (Descriptor of the texture by its parameters)
Returns
the corresponding TextureData struct

Definition at line 111 of file SimpleMaterial.hpp.

◆ addTexture() [2/2]

void Ra::Engine::Data::SimpleMaterial::addTexture ( const TextureSemantic semantic,
Texture texture 
)
inline

Add an already existing texture to control the specified BSDF parameter.

Parameters
semanticThe texture semantic
textureThe texture to use

Definition at line 103 of file SimpleMaterial.hpp.

◆ getTexture()

Texture * Ra::Engine::Data::SimpleMaterial::getTexture ( const TextureSemantic semantic) const
inline

Get the texture associated to the given semantic.

Parameters
semantic
Returns

Definition at line 119 of file SimpleMaterial.hpp.

◆ setColoredByVertexAttrib()

void Ra::Engine::Data::SimpleMaterial::setColoredByVertexAttrib ( bool  )
inlineoverridevirtual

Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.

Parameters
stateactivate (true) or deactivate (false) VERTEX_COLOR attribute usage

Any material that support per-vertex color parameterization should implement this method accordingly

Reimplemented from Ra::Engine::Data::Material.

Definition at line 128 of file SimpleMaterial.hpp.

+ Here is the call graph for this function:

◆ updateGL()

void Ra::Engine::Data::SimpleMaterial::updateGL ( )
finaloverridevirtual

Update the openGL state of the material. This state only consists on associated textures.

Implements Ra::Engine::Data::ShaderParameterProvider.

Definition at line 32 of file SimpleMaterial.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_perVertexColor

bool Ra::Engine::Data::SimpleMaterial::m_perVertexColor { false }

Indicates if the material will takes its base color from vertices' attributes.

Todo:
make this private ?

Definition at line 80 of file SimpleMaterial.hpp.


The documentation for this class was generated from the following files: