Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::Material Class Reference

Base class for materials. More...

#include <Engine/Data/Material.hpp>

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

Public Types

enum class  MaterialAspect { MAT_OPAQUE , MAT_TRANSPARENT , MAT_DENSITY }
 Identifies the type of the material. More...
 

Public Member Functions

virtual ~Material ()=default
 
const std::stringgetInstanceName () const
 
const std::stringgetMaterialName () const
 
void setMaterialAspect (const MaterialAspect &aspect)
 
const MaterialAspectgetMaterialAspect () const
 Get the aspect (MAT_OPAQUE or MAT_TRANSPARENT) of the material.
 
virtual bool isTransparent () const
 
std::list< std::stringgetPropertyList () const override
 Get the list of properties the material migh use in a shader.
 
virtual void setColoredByVertexAttrib (bool state)
 Makes the Material take its base color from the VERTEX_COLOR attribute of the rendered geometry.
 
virtual bool isColoredByVertexAttrib () const
 Indicates if the material takes the VERTEX_COLOR attribute into account.
 
void needUpdate ()
 Mark the Material as needing update before the next OpenGL call.
 
- Public Member Functions inherited from Ra::Engine::Data::ShaderParameterProvider
virtual RenderParametersgetParameters ()
 
virtual const RenderParametersgetParameters () const
 
virtual void updateGL ()=0
 Update the OpenGL states used by the ShaderParameterProvider.
 
virtual void updateFromParameters ()
 Update the attributes of the ShaderParameterProvider to their actual values stored in the renderParameters.
 

Protected Member Functions

 Material (const std::string &instanceName, const std::string &materialName, MaterialAspect aspect=MaterialAspect::MAT_OPAQUE)
 Creates a named material with the given aspect.
 
void setMaterialName (std::string newName)
 Change the material name.
 
bool isDirty ()
 Return dirty state.
 
void setDirty ()
 Set dirty state to true.
 
void setClean ()
 Set dirty state to false.
 

Detailed Description

Base class for materials.

Do not assume a given Material representation but only make the difference between opaque and transparent materials.

Definition at line 23 of file Material.hpp.

Member Enumeration Documentation

◆ MaterialAspect

Identifies the type of the material.

MAT_OPAQUE and MAT_TRANSPARENT implements the GLSL "surfacic" BSDF interface MAT_DENSITY implements the GLSL "volumetric" interface

Enumerator
MAT_TRANSPARENT 

<- The material is either OPAQUE or TRANSPARENT

MAT_DENSITY 

<- The material is TRANSPARENT

<- The material implements the VOLUME interface

Definition at line 31 of file Material.hpp.

Constructor & Destructor Documentation

◆ ~Material()

virtual Ra::Engine::Data::Material::~Material ( )
virtualdefault
Note
The material does not have ownership on its texture nor its shaders. This destructor do not delete the associated textures and the corresponding shaders.

◆ Material()

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

Creates a named material with the given aspect.

Parameters
instanceName
materialName
aspect

Definition at line 6 of file Material.cpp.

Member Function Documentation

◆ getInstanceName()

const std::string & Ra::Engine::Data::Material::getInstanceName ( ) const
inline
Returns
the name of the material instance

Definition at line 45 of file Material.hpp.

◆ getMaterialAspect()

const MaterialAspect & Ra::Engine::Data::Material::getMaterialAspect ( ) const
inline

Get the aspect (MAT_OPAQUE or MAT_TRANSPARENT) of the material.

Returns
the current aspect of the Material

Definition at line 61 of file Material.hpp.

◆ getMaterialName()

const std::string & Ra::Engine::Data::Material::getMaterialName ( ) const
inline
Returns
the name of the material, can be used a UUID
Note
the material name is expected to be used to define the ShaderConfiguration name

Definition at line 50 of file Material.hpp.

◆ getPropertyList()

std::list< std::string > Ra::Engine::Data::Material::getPropertyList ( ) const
inlineoverridevirtual

Get the list of properties the material migh use in a shader.

Each property will be added to the shader used for rendering this material under the form "#define theProperty". Shaders that support the given property could then fully render the material. Others migh render the meterial eroneously.

The default implementation returns an empty list.

Todo

: Validate this proposal

: make the property list modifiable as well

Reimplemented from Ra::Engine::Data::ShaderParameterProvider.

Definition at line 78 of file Material.hpp.

◆ isColoredByVertexAttrib()

virtual bool Ra::Engine::Data::Material::isColoredByVertexAttrib ( ) const
inlinevirtual

Indicates if the material takes the VERTEX_COLOR attribute into account.

Reimplemented in Ra::Engine::Data::BlinnPhongMaterial, and Ra::Engine::Data::SimpleMaterial.

Definition at line 94 of file Material.hpp.

◆ isDirty()

bool Ra::Engine::Data::Material::isDirty ( )
inlineprotected

Return dirty state.

Definition at line 118 of file Material.hpp.

◆ isTransparent()

virtual bool Ra::Engine::Data::Material::isTransparent ( ) const
inlinevirtual
Returns
true if the material is transparent.

Reimplemented in Ra::Engine::Data::BlinnPhongMaterial, and Ra::Engine::Data::VolumetricMaterial.

Definition at line 65 of file Material.hpp.

◆ needUpdate()

void Ra::Engine::Data::Material::needUpdate ( )
inline

Mark the Material as needing update before the next OpenGL call.

Definition at line 98 of file Material.hpp.

◆ setClean()

void Ra::Engine::Data::Material::setClean ( )
inlineprotected

Set dirty state to false.

Definition at line 124 of file Material.hpp.

◆ setColoredByVertexAttrib()

virtual void Ra::Engine::Data::Material::setColoredByVertexAttrib ( bool state)
inlinevirtual

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 in Ra::Engine::Data::BlinnPhongMaterial, and Ra::Engine::Data::SimpleMaterial.

Definition at line 90 of file Material.hpp.

◆ setDirty()

void Ra::Engine::Data::Material::setDirty ( )
inlineprotected

Set dirty state to true.

Definition at line 121 of file Material.hpp.

◆ setMaterialAspect()

void Ra::Engine::Data::Material::setMaterialAspect ( const MaterialAspect & aspect)
inline

set the aspect (MAT_OPAQUE or MAT_TRANSPARENT) of the material.

Parameters
aspect

Definition at line 55 of file Material.hpp.

◆ setMaterialName()

void Ra::Engine::Data::Material::setMaterialName ( std::string newName)
inlineprotected

Change the material name.

Note
This method should be used carefully as the name is a key for render technique factory

Definition at line 115 of file Material.hpp.

+ Here is the call graph for this function:

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