Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::geometry::MeshMaterial Class Reference

Represents material information extracted from a mesh file. More...

#include <mesh_material.h>

Public Types

using Ptr = std::shared_ptr<MeshMaterial>
using ConstPtr = std::shared_ptr<const MeshMaterial>

Public Member Functions

 MeshMaterial (const Eigen::Vector4d &base_color_factor, double metallic_factor, double roughness_factor, const Eigen::Vector4d &emissive_factor)
 Construct a new MeshMaterial.
Eigen::Vector4d getBaseColorFactor () const
 Get the base color of the mesh.
double getMetallicFactor () const
 Get the Metallic Factor of the mesh (PBR parameter).
double getRoughnessFactor () const
 Get the Roughness Factor of the mesh (PBR parameter).
Eigen::Vector4d getEmissiveFactor () const
 Get the emissive factor of the mesh.
MeshMaterialAlphaMode getAlphaMode () const
 Get the alpha mode, which controls how the base color alpha is interpreted.
double getAlphaCutoff () const
 Get the alpha cutoff, used only when the alpha mode is MASK.
bool getDoubleSided () const
 Get whether back faces should be rendered (back-face culling disabled).
double getEmissiveStrength () const
 Get the emissive strength multiplier (KHR_materials_emissive_strength).
double getNormalScale () const
 Get the scale applied to the normal texture's X and Y components.
double getOcclusionStrength () const
 Get the strength of the occlusion texture, between 0 (no occlusion) and 1 (full occlusion).
void setBaseColorFactor (const Eigen::Vector4d &base_color_factor)
 Set the base color in RGBA.
void setMetallicFactor (double metallic_factor)
 Set the metallic factor, between 0 and 1.
void setRoughnessFactor (double roughness_factor)
 Set the roughness factor, between 0 and 1.
void setEmissiveFactor (const Eigen::Vector4d &emissive_factor)
 Set the emissive factor in RGBA.
void setAlphaMode (MeshMaterialAlphaMode alpha_mode)
 Set the alpha mode.
void setAlphaCutoff (double alpha_cutoff)
 Set the alpha cutoff, used only when the alpha mode is MASK.
void setDoubleSided (bool double_sided)
 Set whether the material is double sided.
void setEmissiveStrength (double emissive_strength)
 Set the emissive strength multiplier.
void setNormalScale (double normal_scale)
 Set the normal texture scale.
void setOcclusionStrength (double occlusion_strength)
 Set the occlusion texture strength.
bool operator== (const MeshMaterial &rhs) const
bool operator!= (const MeshMaterial &rhs) const

Friends

template<class Archive>
friend void::tesseract::geometry::serialize (Archive &ar, MeshMaterial &obj)

Detailed Description

Represents material information extracted from a mesh file.

Mesh files contain material information. The mesh parser will extract the material information and store it in a MeshMaterial instance. The MeshMaterial class follows the PBR metallic-roughness workflow specified in the glTF 2.0 file format standard. The parameters supported are:

  • baseColorFactor, metallicFactor, roughnessFactor and emissiveFactor (the core factors)
  • alphaMode and alphaCutoff
  • doubleSided
  • the normal texture scale and the occlusion texture strength
  • the emissive strength from the KHR_materials_emissive_strength extension

Texture images are stored separately in MeshTexture instances, one per texture slot (base color, metallic-roughness, normal, occlusion and emissive). The scalar parameters here apply to those textures as specified by glTF 2.0.

The MeshMaterial favors PBR materials extracted from glTF 2.0 files. COLLADA does not support PBR. Only "Diffuse" and "Emissive" are read. "Specular" and "Ambient" are ignored.

Constructor & Destructor Documentation

◆ MeshMaterial()

tesseract::geometry::MeshMaterial::MeshMaterial ( const Eigen::Vector4d & base_color_factor,
double metallic_factor,
double roughness_factor,
const Eigen::Vector4d & emissive_factor )

Construct a new MeshMaterial.

Parameters
base_color_factorThe base color of the mesh
metallic_factorThe metallic factor parameter (PBR parameter)
roughness_factorThe roughness factor parameter (PBR parameter)
emissive_factorThe emissivity of the mesh

Member Function Documentation

◆ getBaseColorFactor()

Eigen::Vector4d tesseract::geometry::MeshMaterial::getBaseColorFactor ( ) const

Get the base color of the mesh.

Returns
The base color in RGBA

◆ getMetallicFactor()

double tesseract::geometry::MeshMaterial::getMetallicFactor ( ) const

Get the Metallic Factor of the mesh (PBR parameter).

Returns
The metallic factor, between 0 and 1

◆ getRoughnessFactor()

double tesseract::geometry::MeshMaterial::getRoughnessFactor ( ) const

Get the Roughness Factor of the mesh (PBR parameter).

Returns
The roughness factor, between 0 and 1

◆ getEmissiveFactor()

Eigen::Vector4d tesseract::geometry::MeshMaterial::getEmissiveFactor ( ) const

Get the emissive factor of the mesh.

"Emissive factor" is used to make the mesh "glow". How this is interpreted depends on the rendering engine.

Returns
The emissive factor in RGBA

◆ getAlphaMode()

MeshMaterialAlphaMode tesseract::geometry::MeshMaterial::getAlphaMode ( ) const

Get the alpha mode, which controls how the base color alpha is interpreted.

Returns
The alpha mode. The default is OPAQUE.

◆ getAlphaCutoff()

double tesseract::geometry::MeshMaterial::getAlphaCutoff ( ) const

Get the alpha cutoff, used only when the alpha mode is MASK.

Returns
The alpha cutoff. The default is 0.5.

◆ getDoubleSided()

bool tesseract::geometry::MeshMaterial::getDoubleSided ( ) const

Get whether back faces should be rendered (back-face culling disabled).

Returns
True if the material is double sided. The default is false.

◆ getEmissiveStrength()

double tesseract::geometry::MeshMaterial::getEmissiveStrength ( ) const

Get the emissive strength multiplier (KHR_materials_emissive_strength).

Returns
The emissive strength. The default is 1.0.

◆ getNormalScale()

double tesseract::geometry::MeshMaterial::getNormalScale ( ) const

Get the scale applied to the normal texture's X and Y components.

Returns
The normal scale. The default is 1.0.

◆ getOcclusionStrength()

double tesseract::geometry::MeshMaterial::getOcclusionStrength ( ) const

Get the strength of the occlusion texture, between 0 (no occlusion) and 1 (full occlusion).

Returns
The occlusion strength. The default is 1.0.