ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccMaterial Class Reference

Mesh (triangle) material. More...

#include <ecvMaterial.h>

Inheritance diagram for ccMaterial:
Collaboration diagram for ccMaterial:

Public Types

enum class  TextureMapType {
  DIFFUSE , AMBIENT , SPECULAR , NORMAL ,
  METALLIC , ROUGHNESS , SHININESS , EMISSIVE ,
  OPACITY , DISPLACEMENT , REFLECTION , SHEEN ,
  CLEARCOAT , CLEARCOAT_ROUGHNESS , ANISOTROPY
}
 Texture map types for PBR materials. More...
 
typedef QSharedPointer< const ccMaterialCShared
 Const + Shared type. More...
 
typedef QSharedPointer< ccMaterialShared
 Shared type. More...
 
- Public Types inherited from ccSerializableObject
enum  DeserializationFlags { DF_POINT_COORDS_64_BITS , DF_SCALAR_VAL_32_BITS = 2 }
 Deserialization flags (bit-field) More...
 
typedef QMultiMap< unsigned, unsigned > LoadedIDMap
 Map of loaded unique IDs (old ID --> new ID) More...
 

Public Member Functions

 ccMaterial (const QString &name=QString("default"))
 Default constructor. More...
 
 ccMaterial (const ccMaterial &mtl)
 Copy constructor. More...
 
const QString & getName () const
 Returns the material name. More...
 
const QString & getTextureFilename () const
 Returns the texture filename (if any) More...
 
void setName (QString name)
 Sets the material name. More...
 
void setDiffuse (const ecvColor::Rgbaf &color)
 Sets diffuse color (both front and back) More...
 
void setDiffuseFront (const ecvColor::Rgbaf &color)
 Sets diffuse color (front) More...
 
void setDiffuseBack (const ecvColor::Rgbaf &color)
 Sets diffuse color (back) More...
 
const ecvColor::RgbafgetDiffuseFront () const
 Returns front diffuse color. More...
 
const ecvColor::RgbafgetDiffuseBack () const
 Returns back diffuse color. More...
 
void setAmbient (const ecvColor::Rgbaf &color)
 Sets ambient color. More...
 
const ecvColor::RgbafgetAmbient () const
 Returns ambient color. More...
 
void setIllum (int illum)
 Sets illum mode. More...
 
int getIllum () const
 Returns illum mode. More...
 
void setSpecular (const ecvColor::Rgbaf &color)
 Sets specular color. More...
 
const ecvColor::RgbafgetSpecular () const
 Returns specular color. More...
 
void setEmission (const ecvColor::Rgbaf &color)
 Sets emission color. More...
 
const ecvColor::RgbafgetEmission () const
 Returns emission color. More...
 
void setShininess (float val)
 Sets shininess (both front - 100% - and back - 80%) More...
 
void setShininessFront (float val)
 Sets shininess (front) More...
 
void setShininessBack (float val)
 Sets shininess (back) More...
 
float getShininessFront () const
 Returns front shininess. More...
 
float getShininessBack () const
 Returns back shininess. More...
 
void setTransparency (float val)
 Sets transparency (all colors) More...
 
void setMetallic (float val)
 Sets metallic factor (PBR) More...
 
float getMetallic () const
 Returns metallic factor. More...
 
void setRoughness (float val)
 Sets roughness factor (PBR) More...
 
float getRoughness () const
 Returns roughness factor. More...
 
void setSheen (float val)
 Sets sheen factor (PBR) More...
 
float getSheen () const
 Returns sheen factor. More...
 
void setClearcoat (float val)
 Sets clearcoat factor (PBR) More...
 
float getClearcoat () const
 Returns clearcoat factor. More...
 
void setClearcoatRoughness (float val)
 Sets clearcoat roughness (PBR) More...
 
float getClearcoatRoughness () const
 Returns clearcoat roughness. More...
 
void setAnisotropy (float val)
 Sets anisotropy factor (PBR) More...
 
float getAnisotropy () const
 Returns anisotropy factor. More...
 
void setAmbientOcclusion (float val)
 Sets ambient occlusion factor (PBR) More...
 
float getAmbientOcclusion () const
 Returns ambient occlusion factor. More...
 
void applyGL (const QOpenGLContext *context, bool lightEnabled, bool skipDiffuse) const
 Apply parameters (OpenGL) More...
 
bool hasTexture () const
 Returns whether the material has an associated texture or not. More...
 
void setTexture (const QImage &image, const QString &absoluteFilename=QString(), bool mirrorImage=false)
 Sets texture. More...
 
bool loadAndSetTexture (const QString &absoluteFilename)
 Loads texture from file (and set it if successful) More...
 
const QImage & getTexture () const
 Returns the texture (if any) More...
 
GLuint getTextureID () const
 Returns the texture ID (if any) More...
 
bool loadAndSetTextureMap (TextureMapType type, const QString &absoluteFilename)
 Load and set a specific texture map type. More...
 
QString getTextureFilename (TextureMapType type) const
 Get texture filename for a specific map type (returns first one) More...
 
std::vector< QString > getTextureFilenames (TextureMapType type) const
 Get all texture filenames for a specific map type. More...
 
bool hasTextureMap (TextureMapType type) const
 Check if a specific texture map type exists. More...
 
std::vector< std::pair< TextureMapType, QString > > getAllTextureFilenames () const
 Get all texture map filenames. More...
 
void releaseTexture ()
 Release the texture. More...
 
bool compare (const ccMaterial &mtl) const
 Compares this material with another one. More...
 
bool isSerializable () const override
 Returns whether object is serializable of not. More...
 
bool toFile (QFile &out, short dataVersion) const override
 
short minimumFileVersion () const override
 Returns the minimum file version required to save this instance. More...
 
bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
 Loads data from binary stream. More...
 
QString getUniqueIdentifier () const
 Returns unique identifier (UUID) More...
 
- Public Member Functions inherited from ccSerializableObject
virtual ~ccSerializableObject ()=default
 Destructor. More...
 

Static Public Member Functions

static QImage GetTexture (const QString &absoluteFilename)
 Returns the texture image associated to a given name. More...
 
static void AddTexture (const QImage &image, const QString &absoluteFilename)
 Adds a texture to the global texture DB. More...
 
static void ReleaseTextures ()
 Release all texture objects. More...
 
- Static Public Member Functions inherited from ccSerializableObject
static bool WriteError ()
 Sends a custom error message (write error) and returns 'false'. More...
 
static bool ReadError ()
 Sends a custom error message (read error) and returns 'false'. More...
 
static bool MemoryError ()
 Sends a custom error message (not enough memory) and returns 'false'. More...
 
static bool CorruptError ()
 Sends a custom error message (corrupted file) and returns 'false'. More...
 

Protected Attributes

QString m_name
 
QString m_textureFilename
 
QString m_uniqueID
 
int m_illum
 
ecvColor::Rgbaf m_diffuseFront
 
ecvColor::Rgbaf m_diffuseBack
 
ecvColor::Rgbaf m_ambient
 
ecvColor::Rgbaf m_specular
 
ecvColor::Rgbaf m_emission
 
float m_shininessFront
 
float m_shininessBack
 
float m_metallic
 
float m_roughness
 
float m_sheen
 
float m_clearcoat
 
float m_clearcoatRoughness
 
float m_anisotropy
 
float m_ambientOcclusion
 
std::map< TextureMapType, std::vector< QString > > m_textureFilenames
 

Detailed Description

Mesh (triangle) material.

Definition at line 28 of file ecvMaterial.h.

Member Typedef Documentation

◆ CShared

typedef QSharedPointer<const ccMaterial> ccMaterial::CShared

Const + Shared type.

Definition at line 31 of file ecvMaterial.h.

◆ Shared

typedef QSharedPointer<ccMaterial> ccMaterial::Shared

Shared type.

Definition at line 33 of file ecvMaterial.h.

Member Enumeration Documentation

◆ TextureMapType

Texture map types for PBR materials.

Enumerator
DIFFUSE 
AMBIENT 
SPECULAR 
NORMAL 
METALLIC 
ROUGHNESS 
SHININESS 
EMISSIVE 
OPACITY 
DISPLACEMENT 
REFLECTION 
SHEEN 
CLEARCOAT 
CLEARCOAT_ROUGHNESS 
ANISOTROPY 

Definition at line 176 of file ecvMaterial.h.

Constructor & Destructor Documentation

◆ ccMaterial() [1/2]

ccMaterial::ccMaterial ( const QString &  name = QString("default"))
explicit

Default constructor.

◆ ccMaterial() [2/2]

ccMaterial::ccMaterial ( const ccMaterial mtl)

Copy constructor.

Member Function Documentation

◆ AddTexture()

static void ccMaterial::AddTexture ( const QImage &  image,
const QString &  absoluteFilename 
)
static

Adds a texture to the global texture DB.

Referenced by define_ccMaterial().

◆ applyGL()

void ccMaterial::applyGL ( const QOpenGLContext *  context,
bool  lightEnabled,
bool  skipDiffuse 
) const

Apply parameters (OpenGL)

◆ compare()

bool ccMaterial::compare ( const ccMaterial mtl) const

Compares this material with another one.

Returns
true if both materials are equivalent or false otherwise

Referenced by define_ccMaterial().

◆ fromFile()

bool ccMaterial::fromFile ( QFile &  in,
short  dataVersion,
int  flags,
LoadedIDMap oldToNewIDMap 
)
overridevirtual

Loads data from binary stream.

Parameters
ininput file (already opened)
dataVersionfile version (for version-specific deserialization)
flagsdeserialization flags (see ccSerializableObject::DeserializationFlags)
oldToNewIDMapmap to link old IDs with new IDs
Returns
success
Note: When implementing, use dataVersion checks to handle different
versions:
  • if (dataVersion >= X) { read new field } else { use default value } This ensures forward compatibility with older file formats.

Reimplemented from ccSerializableObject.

Referenced by define_ccMaterial().

◆ getAllTextureFilenames()

std::vector<std::pair<TextureMapType, QString> > ccMaterial::getAllTextureFilenames ( ) const

Get all texture map filenames.

Returns all textures including multiple textures of the same type

◆ getAmbient()

const ecvColor::Rgbaf& ccMaterial::getAmbient ( ) const
inline

Returns ambient color.

Definition at line 72 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getAmbientOcclusion()

float ccMaterial::getAmbientOcclusion ( ) const
inline

Returns ambient occlusion factor.

Definition at line 140 of file ecvMaterial.h.

◆ getAnisotropy()

float ccMaterial::getAnisotropy ( ) const
inline

Returns anisotropy factor.

Definition at line 135 of file ecvMaterial.h.

◆ getClearcoat()

float ccMaterial::getClearcoat ( ) const
inline

Returns clearcoat factor.

Definition at line 125 of file ecvMaterial.h.

◆ getClearcoatRoughness()

float ccMaterial::getClearcoatRoughness ( ) const
inline

Returns clearcoat roughness.

Definition at line 130 of file ecvMaterial.h.

◆ getDiffuseBack()

const ecvColor::Rgbaf& ccMaterial::getDiffuseBack ( ) const
inline

Returns back diffuse color.

Definition at line 65 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getDiffuseFront()

const ecvColor::Rgbaf& ccMaterial::getDiffuseFront ( ) const
inline

Returns front diffuse color.

Definition at line 61 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getEmission()

const ecvColor::Rgbaf& ccMaterial::getEmission ( ) const
inline

Returns emission color.

Definition at line 91 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getIllum()

int ccMaterial::getIllum ( ) const
inline

Returns illum mode.

Definition at line 77 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getMetallic()

float ccMaterial::getMetallic ( ) const
inline

Returns metallic factor.

Definition at line 110 of file ecvMaterial.h.

◆ getName()

const QString& ccMaterial::getName ( ) const
inline

Returns the material name.

Definition at line 42 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getRoughness()

float ccMaterial::getRoughness ( ) const
inline

Returns roughness factor.

Definition at line 115 of file ecvMaterial.h.

◆ getSheen()

float ccMaterial::getSheen ( ) const
inline

Returns sheen factor.

Definition at line 120 of file ecvMaterial.h.

◆ getShininessBack()

float ccMaterial::getShininessBack ( ) const
inline

Returns back shininess.

Definition at line 102 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getShininessFront()

float ccMaterial::getShininessFront ( ) const
inline

Returns front shininess.

Definition at line 100 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getSpecular()

const ecvColor::Rgbaf& ccMaterial::getSpecular ( ) const
inline

Returns specular color.

Definition at line 84 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getTexture()

const QImage& ccMaterial::getTexture ( ) const

Returns the texture (if any)

Referenced by define_ccMaterial().

◆ GetTexture()

static QImage ccMaterial::GetTexture ( const QString &  absoluteFilename)
static

Returns the texture image associated to a given name.

Referenced by define_ccMaterial(), and ToFbxMesh().

◆ getTextureFilename() [1/2]

const QString& ccMaterial::getTextureFilename ( ) const
inline

Returns the texture filename (if any)

Definition at line 44 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ getTextureFilename() [2/2]

QString ccMaterial::getTextureFilename ( TextureMapType  type) const

Get texture filename for a specific map type (returns first one)

◆ getTextureFilenames()

std::vector<QString> ccMaterial::getTextureFilenames ( TextureMapType  type) const

Get all texture filenames for a specific map type.

Returns all textures of the specified type (e.g., all map_Kd textures)

◆ getTextureID()

GLuint ccMaterial::getTextureID ( ) const

Returns the texture ID (if any)

Referenced by define_ccMaterial().

◆ getUniqueIdentifier()

QString ccMaterial::getUniqueIdentifier ( ) const
inline

Returns unique identifier (UUID)

Definition at line 246 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ hasTexture()

bool ccMaterial::hasTexture ( ) const

Returns whether the material has an associated texture or not.

Referenced by define_ccMaterial().

◆ hasTextureMap()

bool ccMaterial::hasTextureMap ( TextureMapType  type) const

Check if a specific texture map type exists.

◆ isSerializable()

bool ccMaterial::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

Definition at line 235 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ loadAndSetTexture()

bool ccMaterial::loadAndSetTexture ( const QString &  absoluteFilename)

Loads texture from file (and set it if successful)

If the filename is not already in DB, the corresponding file will be loaded.

Returns
whether the file could be loaded (or is already in DB) or not

Referenced by define_ccMaterial().

◆ loadAndSetTextureMap()

bool ccMaterial::loadAndSetTextureMap ( TextureMapType  type,
const QString &  absoluteFilename 
)

Load and set a specific texture map type.

◆ minimumFileVersion()

short ccMaterial::minimumFileVersion ( ) const
overridevirtual

Returns the minimum file version required to save this instance.

To be overridden by subclasses to indicate their minimum required version. This enables the system to determine:

  • Forward compatibility: newer software can read older files (dataVersion check in fromFile)
  • Backward compatibility: determine minimum version needed to save current data
    Returns
    minimum file version required for this object

Implements ccSerializableObject.

Referenced by define_ccMaterial().

◆ releaseTexture()

void ccMaterial::releaseTexture ( )

Release the texture.

Warning
Make sure no more materials are using this texture!

Referenced by define_ccMaterial().

◆ ReleaseTextures()

static void ccMaterial::ReleaseTextures ( )
static

Release all texture objects.

Should be called BEFORE the global shared context is destroyed.

Referenced by define_ccMaterial().

◆ setAmbient()

void ccMaterial::setAmbient ( const ecvColor::Rgbaf color)
inline

Sets ambient color.

Definition at line 70 of file ecvMaterial.h.

References color.

Referenced by define_ccMaterial().

◆ setAmbientOcclusion()

void ccMaterial::setAmbientOcclusion ( float  val)
inline

Sets ambient occlusion factor (PBR)

Definition at line 138 of file ecvMaterial.h.

◆ setAnisotropy()

void ccMaterial::setAnisotropy ( float  val)
inline

Sets anisotropy factor (PBR)

Definition at line 133 of file ecvMaterial.h.

◆ setClearcoat()

void ccMaterial::setClearcoat ( float  val)
inline

Sets clearcoat factor (PBR)

Definition at line 123 of file ecvMaterial.h.

◆ setClearcoatRoughness()

void ccMaterial::setClearcoatRoughness ( float  val)
inline

Sets clearcoat roughness (PBR)

Definition at line 128 of file ecvMaterial.h.

◆ setDiffuse()

void ccMaterial::setDiffuse ( const ecvColor::Rgbaf color)

Sets diffuse color (both front and back)

Referenced by define_ccMaterial().

◆ setDiffuseBack()

void ccMaterial::setDiffuseBack ( const ecvColor::Rgbaf color)
inline

Sets diffuse color (back)

Definition at line 57 of file ecvMaterial.h.

References color.

Referenced by define_ccMaterial().

◆ setDiffuseFront()

void ccMaterial::setDiffuseFront ( const ecvColor::Rgbaf color)
inline

Sets diffuse color (front)

Definition at line 53 of file ecvMaterial.h.

References color.

Referenced by define_ccMaterial().

◆ setEmission()

void ccMaterial::setEmission ( const ecvColor::Rgbaf color)
inline

Sets emission color.

Definition at line 87 of file ecvMaterial.h.

References color.

Referenced by define_ccMaterial().

◆ setIllum()

void ccMaterial::setIllum ( int  illum)
inline

Sets illum mode.

Definition at line 75 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ setMetallic()

void ccMaterial::setMetallic ( float  val)
inline

Sets metallic factor (PBR)

Definition at line 108 of file ecvMaterial.h.

◆ setName()

void ccMaterial::setName ( QString  name)
inline

Sets the material name.

Definition at line 48 of file ecvMaterial.h.

References name.

Referenced by define_ccMaterial().

◆ setRoughness()

void ccMaterial::setRoughness ( float  val)
inline

Sets roughness factor (PBR)

Definition at line 113 of file ecvMaterial.h.

◆ setSheen()

void ccMaterial::setSheen ( float  val)
inline

Sets sheen factor (PBR)

Definition at line 118 of file ecvMaterial.h.

◆ setShininess()

void ccMaterial::setShininess ( float  val)

Sets shininess (both front - 100% - and back - 80%)

Referenced by define_ccMaterial().

◆ setShininessBack()

void ccMaterial::setShininessBack ( float  val)
inline

Sets shininess (back)

Definition at line 98 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ setShininessFront()

void ccMaterial::setShininessFront ( float  val)
inline

Sets shininess (front)

Definition at line 96 of file ecvMaterial.h.

Referenced by define_ccMaterial().

◆ setSpecular()

void ccMaterial::setSpecular ( const ecvColor::Rgbaf color)
inline

Sets specular color.

Definition at line 80 of file ecvMaterial.h.

References color.

Referenced by define_ccMaterial().

◆ setTexture()

void ccMaterial::setTexture ( const QImage &  image,
const QString &  absoluteFilename = QString(),
bool  mirrorImage = false 
)

Sets texture.

If no filename is provided, a random one will be generated.

Referenced by define_ccMaterial().

◆ setTransparency()

void ccMaterial::setTransparency ( float  val)

Sets transparency (all colors)

Referenced by define_ccMaterial().

◆ toFile()

bool ccMaterial::toFile ( QFile &  out,
short  dataVersion 
) const
overridevirtual
Warning
Doesn't save the texture image!

Reimplemented from ccSerializableObject.

Referenced by define_ccMaterial().

Member Data Documentation

◆ m_ambient

ecvColor::Rgbaf ccMaterial::m_ambient
protected

Definition at line 256 of file ecvMaterial.h.

◆ m_ambientOcclusion

float ccMaterial::m_ambientOcclusion
protected

Definition at line 269 of file ecvMaterial.h.

◆ m_anisotropy

float ccMaterial::m_anisotropy
protected

Definition at line 268 of file ecvMaterial.h.

◆ m_clearcoat

float ccMaterial::m_clearcoat
protected

Definition at line 266 of file ecvMaterial.h.

◆ m_clearcoatRoughness

float ccMaterial::m_clearcoatRoughness
protected

Definition at line 267 of file ecvMaterial.h.

◆ m_diffuseBack

ecvColor::Rgbaf ccMaterial::m_diffuseBack
protected

Definition at line 255 of file ecvMaterial.h.

◆ m_diffuseFront

ecvColor::Rgbaf ccMaterial::m_diffuseFront
protected

Definition at line 254 of file ecvMaterial.h.

◆ m_emission

ecvColor::Rgbaf ccMaterial::m_emission
protected

Definition at line 258 of file ecvMaterial.h.

◆ m_illum

int ccMaterial::m_illum
protected

Definition at line 252 of file ecvMaterial.h.

◆ m_metallic

float ccMaterial::m_metallic
protected

Definition at line 263 of file ecvMaterial.h.

◆ m_name

QString ccMaterial::m_name
protected

Definition at line 249 of file ecvMaterial.h.

◆ m_roughness

float ccMaterial::m_roughness
protected

Definition at line 264 of file ecvMaterial.h.

◆ m_sheen

float ccMaterial::m_sheen
protected

Definition at line 265 of file ecvMaterial.h.

◆ m_shininessBack

float ccMaterial::m_shininessBack
protected

Definition at line 260 of file ecvMaterial.h.

◆ m_shininessFront

float ccMaterial::m_shininessFront
protected

Definition at line 259 of file ecvMaterial.h.

◆ m_specular

ecvColor::Rgbaf ccMaterial::m_specular
protected

Definition at line 257 of file ecvMaterial.h.

◆ m_textureFilename

QString ccMaterial::m_textureFilename
protected

Definition at line 250 of file ecvMaterial.h.

◆ m_textureFilenames

std::map<TextureMapType, std::vector<QString> > ccMaterial::m_textureFilenames
protected

Definition at line 273 of file ecvMaterial.h.

◆ m_uniqueID

QString ccMaterial::m_uniqueID
protected

Definition at line 251 of file ecvMaterial.h.


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