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:
[legend]
Collaboration diagram for ccMaterial:
[legend]

Public Types

enum  TextureMapType {
  TextureMapType::DIFFUSE, TextureMapType::AMBIENT, TextureMapType::SPECULAR, TextureMapType::NORMAL,
  TextureMapType::METALLIC, TextureMapType::ROUGHNESS, TextureMapType::SHININESS, TextureMapType::EMISSIVE,
  TextureMapType::OPACITY, TextureMapType::DISPLACEMENT, TextureMapType::REFLECTION, TextureMapType::SHEEN,
  TextureMapType::CLEARCOAT, TextureMapType::CLEARCOAT_ROUGHNESS, TextureMapType::ANISOTROPY
}
 Texture map types for PBR materials. More...
 
typedef QSharedPointer< const ccMaterial > CShared
 Const + Shared type. More...
 
typedef QSharedPointer< ccMaterial > Shared
 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::Rgbaf & getDiffuseFront () const
 Returns front diffuse color. More...
 
const ecvColor::Rgbaf & getDiffuseBack () const
 Returns back diffuse color. More...
 
void setAmbient (const ecvColor::Rgbaf &color)
 Sets ambient color. More...
 
const ecvColor::Rgbaf & getAmbient () 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::Rgbaf & getSpecular () const
 Returns specular color. More...
 
void setEmission (const ecvColor::Rgbaf &color)
 Sets emission color. More...
 
const ecvColor::Rgbaf & getEmission () 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.

Member Typedef Documentation

◆ CShared

typedef QSharedPointer<const ccMaterial> ccMaterial::CShared

Const + Shared type.

◆ Shared

typedef QSharedPointer<ccMaterial> ccMaterial::Shared

Shared type.

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 

Constructor & Destructor Documentation

◆ ccMaterial() [1/2]

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

Default constructor.

References setShininess().

◆ ccMaterial() [2/2]

ccMaterial::ccMaterial ( const ccMaterial &  mtl)

Copy constructor.

Member Function Documentation

◆ AddTexture()

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

Adds a texture to the global texture DB.

References image, and s_textureDB.

Referenced by define_ccMaterial().

◆ applyGL()

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

Apply parameters (OpenGL)

References context.

◆ compare()

bool ccMaterial::compare ( const ccMaterial &  mtl) const

Compares this material with another one.

Returns
true if both materials are equivalent or false otherwise

References m_ambient, m_diffuseBack, m_diffuseFront, m_emission, m_illum, m_name, m_shininessBack, m_shininessFront, m_specular, and m_textureFilename.

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< ccMaterial::TextureMapType, QString > > ccMaterial::getAllTextureFilenames ( ) const

Get all texture map filenames.

Returns all textures including multiple textures of the same type

References m_textureFilenames, cloudViewer::core::make_pair(), and result.

◆ getAmbient()

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

◆ getAmbientOcclusion()

float ccMaterial::getAmbientOcclusion ( ) const
inline

Returns ambient occlusion factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getAnisotropy()

float ccMaterial::getAnisotropy ( ) const
inline

Returns anisotropy factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getClearcoat()

float ccMaterial::getClearcoat ( ) const
inline

Returns clearcoat factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getClearcoatRoughness()

float ccMaterial::getClearcoatRoughness ( ) const
inline

Returns clearcoat roughness.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getDiffuseBack()

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

Returns back diffuse color.

Referenced by define_ccMaterial().

◆ getDiffuseFront()

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

Returns front diffuse color.

Referenced by define_ccMaterial(), and PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getEmission()

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

◆ getIllum()

int ccMaterial::getIllum ( ) const
inline

Returns illum mode.

Referenced by define_ccMaterial().

◆ getMetallic()

float ccMaterial::getMetallic ( ) const
inline

Returns metallic factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getName()

const QString& ccMaterial::getName ( ) const
inline

◆ getRoughness()

float ccMaterial::getRoughness ( ) const
inline

Returns roughness factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getSheen()

float ccMaterial::getSheen ( ) const
inline

Returns sheen factor.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getShininessBack()

float ccMaterial::getShininessBack ( ) const
inline

Returns back shininess.

Referenced by define_ccMaterial().

◆ getShininessFront()

float ccMaterial::getShininessFront ( ) const
inline

◆ getSpecular()

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

◆ getTexture()

const QImage & ccMaterial::getTexture ( ) const

Returns the texture (if any)

References m_textureFilename, and s_textureDB.

Referenced by define_ccMaterial(), getTextureID(), and ccGenericMesh::updateTextures().

◆ GetTexture()

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

◆ getTextureFilename() [1/2]

const QString& ccMaterial::getTextureFilename ( ) const
inline

Returns the texture filename (if any)

Referenced by define_ccMaterial(), and PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getTextureFilename() [2/2]

QString ccMaterial::getTextureFilename ( TextureMapType  type) const

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

References m_textureFilenames, and type.

◆ 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)

References m_textureFilenames, and type.

Referenced by PclUtils::renders::MaterialConverter::FromCCMaterial().

◆ getTextureID()

GLuint ccMaterial::getTextureID ( ) const

Returns the texture ID (if any)

References getTexture(), and image.

Referenced by define_ccMaterial().

◆ getUniqueIdentifier()

QString ccMaterial::getUniqueIdentifier ( ) const
inline

Returns unique identifier (UUID)

Referenced by define_ccMaterial().

◆ hasTexture()

bool ccMaterial::hasTexture ( ) const

Returns whether the material has an associated texture or not.

References m_textureFilename, and s_textureDB.

Referenced by define_ccMaterial().

◆ hasTextureMap()

bool ccMaterial::hasTextureMap ( TextureMapType  type) const

Check if a specific texture map type exists.

References m_textureFilenames, and type.

Referenced by PclUtils::renders::MaterialConverter::HasPBREncoding().

◆ isSerializable()

bool ccMaterial::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

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

References image, m_textureFilename, s_textureDB, setTexture(), CVTools::ToNativeSeparators(), and CVLog::Warning().

Referenced by define_ccMaterial(), and ccGenericMesh::updateTextures().

◆ loadAndSetTextureMap()

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

◆ 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!

References m_textureFilename, CVLog::Print(), and s_textureDB.

Referenced by define_ccMaterial().

◆ ReleaseTextures()

void ccMaterial::ReleaseTextures ( )
static

Release all texture objects.

Should be called BEFORE the global shared context is destroyed.

References s_textureDB.

Referenced by define_ccMaterial(), and ecvApplicationBase::ecvApplicationBase().

◆ setAmbient()

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

Sets ambient color.

References color.

Referenced by define_ccMaterial().

◆ setAmbientOcclusion()

void ccMaterial::setAmbientOcclusion ( float  val)
inline

Sets ambient occlusion factor (PBR)

◆ setAnisotropy()

void ccMaterial::setAnisotropy ( float  val)
inline

Sets anisotropy factor (PBR)

◆ setClearcoat()

void ccMaterial::setClearcoat ( float  val)
inline

Sets clearcoat factor (PBR)

◆ setClearcoatRoughness()

void ccMaterial::setClearcoatRoughness ( float  val)
inline

Sets clearcoat roughness (PBR)

◆ setDiffuse()

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

Sets diffuse color (both front and back)

References color, setDiffuseBack(), and setDiffuseFront().

Referenced by define_ccMaterial().

◆ setDiffuseBack()

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

Sets diffuse color (back)

References color.

Referenced by define_ccMaterial(), and setDiffuse().

◆ setDiffuseFront()

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

Sets diffuse color (front)

References color.

Referenced by define_ccMaterial(), and setDiffuse().

◆ setEmission()

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

Sets emission color.

References color.

Referenced by define_ccMaterial().

◆ setIllum()

void ccMaterial::setIllum ( int  illum)
inline

Sets illum mode.

Referenced by define_ccMaterial().

◆ setMetallic()

void ccMaterial::setMetallic ( float  val)
inline

Sets metallic factor (PBR)

◆ setName()

void ccMaterial::setName ( QString  name)
inline

Sets the material name.

References name.

Referenced by define_ccMaterial().

◆ setRoughness()

void ccMaterial::setRoughness ( float  val)
inline

Sets roughness factor (PBR)

◆ setSheen()

void ccMaterial::setSheen ( float  val)
inline

Sets sheen factor (PBR)

◆ setShininess()

void ccMaterial::setShininess ( float  val)

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

References setShininessBack(), and setShininessFront().

Referenced by ccMaterial(), and define_ccMaterial().

◆ setShininessBack()

void ccMaterial::setShininessBack ( float  val)
inline

Sets shininess (back)

Referenced by define_ccMaterial(), and setShininess().

◆ setShininessFront()

void ccMaterial::setShininessFront ( float  val)
inline

Sets shininess (front)

Referenced by define_ccMaterial(), and setShininess().

◆ setSpecular()

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

Sets specular color.

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.

References image, m_textureFilename, m_uniqueID, CVLog::PrintDebug(), s_textureDB, size, CVTools::ToNativeSeparators(), and CVLog::Warning().

Referenced by define_ccMaterial(), and loadAndSetTexture().

◆ setTransparency()

void ccMaterial::setTransparency ( float  val)

Sets transparency (all colors)

References ecvColor::RgbaTpl< Type >::a, m_ambient, m_diffuseBack, m_diffuseFront, m_emission, and m_specular.

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

Referenced by compare(), and setTransparency().

◆ m_ambientOcclusion

float ccMaterial::m_ambientOcclusion
protected

◆ m_anisotropy

float ccMaterial::m_anisotropy
protected

◆ m_clearcoat

float ccMaterial::m_clearcoat
protected

◆ m_clearcoatRoughness

float ccMaterial::m_clearcoatRoughness
protected

◆ m_diffuseBack

ecvColor::Rgbaf ccMaterial::m_diffuseBack
protected

Referenced by compare(), and setTransparency().

◆ m_diffuseFront

ecvColor::Rgbaf ccMaterial::m_diffuseFront
protected

Referenced by compare(), and setTransparency().

◆ m_emission

ecvColor::Rgbaf ccMaterial::m_emission
protected

Referenced by compare(), and setTransparency().

◆ m_illum

int ccMaterial::m_illum
protected

Referenced by compare().

◆ m_metallic

float ccMaterial::m_metallic
protected

◆ m_name

QString ccMaterial::m_name
protected

Referenced by compare().

◆ m_roughness

float ccMaterial::m_roughness
protected

◆ m_sheen

float ccMaterial::m_sheen
protected

◆ m_shininessBack

float ccMaterial::m_shininessBack
protected

Referenced by compare().

◆ m_shininessFront

float ccMaterial::m_shininessFront
protected

Referenced by compare().

◆ m_specular

ecvColor::Rgbaf ccMaterial::m_specular
protected

Referenced by compare(), and setTransparency().

◆ m_textureFilename

QString ccMaterial::m_textureFilename
protected

◆ m_textureFilenames

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

◆ m_uniqueID

QString ccMaterial::m_uniqueID
protected

Referenced by setTexture().


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