qCC_db version 2.13.alpha (Qt) - 31 May 2022
CloudCompare 3D entities
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ccMaterial Class Reference

Mesh (triangle) material. More...

#include <ccMaterial.h>

Inheritance diagram for ccMaterial:
Inheritance graph
[legend]
Collaboration diagram for ccMaterial:
Collaboration graph
[legend]

Public Types

using CShared = QSharedPointer< const ccMaterial >
 Const + Shared type.
 
using Shared = QSharedPointer< ccMaterial >
 Shared type.
 
- Public Types inherited from ccSerializableObject
enum  DeserializationFlags { DF_POINT_COORDS_64_BITS = 1 , 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)
 

Public Member Functions

 ccMaterial (const QString &name=QString("default"))
 Default constructor.
 
 ccMaterial (const ccMaterial &mtl)
 Copy constructor.
 
 ~ccMaterial ()
 Destructor.
 
const QString & getName () const
 Returns the material name.
 
const QString & getTextureFilename () const
 Returns the texture filename (if any)
 
void setName (const QString &name)
 Sets the material name.
 
void setDiffuse (const ccColor::Rgbaf &color)
 Sets diffuse color (both front and back)
 
void setDiffuseFront (const ccColor::Rgbaf &color)
 Sets diffuse color (front)
 
void setDiffuseBack (const ccColor::Rgbaf &color)
 Sets diffuse color (back)
 
const ccColor::RgbafgetDiffuseFront () const
 Returns front diffuse color.
 
const ccColor::RgbafgetDiffuseBack () const
 Returns back diffuse color.
 
void setAmbient (const ccColor::Rgbaf &color)
 Sets ambient color.
 
const ccColor::RgbafgetAmbient () const
 Returns ambient color.
 
void setSpecular (const ccColor::Rgbaf &color)
 Sets specular color.
 
const ccColor::RgbafgetSpecular () const
 Returns specular color.
 
void setEmission (const ccColor::Rgbaf &color)
 Sets emission color.
 
const ccColor::RgbafgetEmission () const
 Returns emission color.
 
void setShininess (float val)
 Sets shininess (both front - 100% - and back - 80%)
 
void setShininessFront (float val)
 Sets shininess (front)
 
void setShininessBack (float val)
 Sets shininess (back)
 
float getShininessFront () const
 Returns front shininess.
 
float getShininessBack () const
 Returns back shininess.
 
void setTransparency (float val)
 Sets transparency (all colors)
 
void applyGL (const QOpenGLContext *context, bool lightEnabled, bool skipDiffuse) const
 Apply parameters (OpenGL)
 
bool hasTexture () const
 Returns whether the material has an associated texture or not.
 
void setTexture (QImage image, QString absoluteFilename=QString(), bool mirrorImage=true)
 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)
 
GLuint getTextureID () const
 Returns the texture ID (if any)
 
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) const override
 
bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
 Loads data from binary stream. More...
 
QString getUniqueIdentifier () const
 Returns unique identifier (UUID)
 
void setTextureMinMagFilters (QOpenGLTexture::Filter minificationFilter, QOpenGLTexture::Filter magnificationFilter)
 Sets the texture minification and magnification filters.
 
- Public Member Functions inherited from ccSerializableObject
virtual ~ccSerializableObject ()=default
 Destructor.
 
virtual bool isSerializable () const
 Returns whether object is serializable of not. More...
 
virtual bool toFile (QFile &out) const
 Saves data to binary stream. More...
 
virtual bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap)
 Loads data from binary stream. More...
 

Static Public Member Functions

static void MakeLightsNeutral (const QOpenGLContext *context)
 Helper: makes all active GL light sources neutral (i.e. 'gray') More...
 
static QImage GetTexture (const QString &absoluteFilename)
 Returns the texture image associated to a given name.
 
static void AddTexture (QImage image, const QString &absoluteFilename)
 Adds a texture to the global texture DB.
 
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
 
ccColor::Rgbaf m_diffuseFront
 
ccColor::Rgbaf m_diffuseBack
 
ccColor::Rgbaf m_ambient
 
ccColor::Rgbaf m_specular
 
ccColor::Rgbaf m_emission
 
float m_shininessFront
 
float m_shininessBack
 
QOpenGLTexture::Filter m_texMinificationFilter
 
QOpenGLTexture::Filter m_texMagnificationFilter
 

Detailed Description

Mesh (triangle) material.

Member Function Documentation

◆ compare()

bool ccMaterial::compare ( const ccMaterial mtl) const

Compares this material with another one.

Returns
true if both materials are equivalent or false otherwise

◆ 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
flagsdeserialization flags (see ccSerializableObject::DeserializationFlags)
oldToNewIDMapmap to link old IDs with new IDs
Returns
success

Reimplemented from ccSerializableObject.

◆ isSerializable()

bool ccMaterial::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

◆ 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

◆ MakeLightsNeutral()

void ccMaterial::MakeLightsNeutral ( const QOpenGLContext *  context)
static

Helper: makes all active GL light sources neutral (i.e. 'gray')

Warning
an OpenGL context must be active!

◆ releaseTexture()

void ccMaterial::releaseTexture ( )

Release the texture.

Warning
Make sure no more materials are using this texture!

◆ ReleaseTextures()

void ccMaterial::ReleaseTextures ( )
static

Release all texture objects.

Should be called BEFORE the global shared context is destroyed.

◆ setTexture()

void ccMaterial::setTexture ( QImage  image,
QString  absoluteFilename = QString(),
bool  mirrorImage = true 
)

Sets texture.

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

◆ toFile()

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

Reimplemented from ccSerializableObject.


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