AGXDynamics  2.31.1.0
agxCollide::RenderMaterial Class Reference

Class for storing rendering material. More...

#include <RenderMaterial.h>

+ Inheritance diagram for agxCollide::RenderMaterial:

Public Types

enum  TextureMode {
  DIFFUSE_TEXTURE =0, NORMALMAP_TEXTURE = 1, HEIGHTMAP_TEXTURE = 2, SPECULARMAP_TEXTURE = 3,
  NUM_TEXTURE_MODES =4
}
 

Public Member Functions

 RenderMaterial ()
 Constructor. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
int compare (const RenderMaterial &other) const
 Slow string comparison function that uses the toString() method to convert each material to a string. More...
 
bool equal (const RenderMaterial &other) const
 
agx::Vec4f getAmbientColor () const
 
const char * getClassName () const override
 
agx::Vec4f getDiffuseColor () const
 
agx::Vec4f getEmissiveColor () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getHash () const
 
agx::UInt32 getIndex () const
 This index is given at creation of this object. More...
 
agx::String getMaterialSpecification () const
 
agx::String getName () const
 
int getReferenceCount () const
 
float getShininess () const
 
agx::Vec4f getSpecularColor () const
 
agxStream::StorageAgent * getStorageAgent () const override
 
agx::String getTexturePath (TextureMode mode=DIFFUSE_TEXTURE) const
 
float getTransparency () const
 
agx::Uuid getUuid () const
 
bool hasAmbientColor () const
 
bool hasDiffuseColor () const
 
bool hasEmissiveColor () const
 
bool hasMaterialSpecification () const
 
bool hasShininess () const
 
bool hasSpecularColor () const
 
bool hasTexturePath (TextureMode mode=DIFFUSE_TEXTURE) const
 
bool hasTransparency () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isFinished () const
 
bool operator== (const RenderMaterial &other) const
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void restore (agxStream::InputArchive &in) override
 
void setAmbientColor (const agx::Vec4f &color)
 Set the ambient color. More...
 
void setDiffuseColor (const agx::Vec4f &color)
 Set the diffuse color. More...
 
void setEmissiveColor (const agx::Vec4f &color)
 Set the emissive color. More...
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object. More...
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More...
 
void setMaterialSpecification (const agx::String &material)
 Store a string with a material specification, for example Keyshot material string. More...
 
void setName (const agx::String &name)
 Set the name of this material. More...
 
void setShininess (float shininess)
 Set the shininess of the material. More...
 
void setSpecularColor (const agx::Vec4f &color)
 Set the specular color. More...
 
void setTexturePath (const agx::String &path, TextureMode mode=DIFFUSE_TEXTURE)
 Set the path to a texture for the specified texturing mode (default DIFFUSE) More...
 
void setTransparency (float transparency)
 Set the transparency of the material 1 - transparent, 0 - opaque. More...
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object. More...
 
virtual void store (agxStream::OutputArchive &out) const override
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

static agxStream::Serializable * create ()
 
static agxStream::Serializable * create (agxStream::InputArchive &)
 
static const char * getConstructClassId ()
 
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~RenderMaterial ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
void generateUuid ()
 
agx::String toString () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

agx::Vec4f m_ambientColor
 
agx::Vec4f m_diffuseColor
 
agx::Vec4f m_emissiveColor
 
agx::String m_materialSpecification
 
Mutex m_mutex
 
agx::String m_name
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
float m_shininess
 
agx::Vec4f m_specularColor
 
agx::StringVector m_texturePaths
 
float m_transparency
 

Detailed Description

Class for storing rendering material.

Definition at line 32 of file RenderMaterial.h.

Member Enumeration Documentation

◆ TextureMode

Enumerator
DIFFUSE_TEXTURE 
NORMALMAP_TEXTURE 
HEIGHTMAP_TEXTURE 
SPECULARMAP_TEXTURE 
NUM_TEXTURE_MODES 

Definition at line 36 of file RenderMaterial.h.

Constructor & Destructor Documentation

◆ RenderMaterial()

agxCollide::RenderMaterial::RenderMaterial ( )

Constructor.

◆ ~RenderMaterial()

virtual agxCollide::RenderMaterial::~RenderMaterial ( )
protectedvirtual

Member Function Documentation

◆ allocateObserverVector()

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited

◆ as() [1/2]

template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().

◆ as() [2/2]

template<typename T >
const T* agx::Referenced::as ( ) const
inherited

◆ asSafe() [1/2]

template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

◆ asSafe() [2/2]

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited

◆ compare()

int agxCollide::RenderMaterial::compare ( const RenderMaterial &  other) const

Slow string comparison function that uses the toString() method to convert each material to a string.

Parameters
other- Material to compare to
Returns
0 if materials are equal, -1 if this is string wise larger, and 1 if other is string wise larger

◆ create() [1/2]

static agxStream::Serializable* agxCollide::RenderMaterial::create ( agxStream::InputArchive &  )
inlinestatic

Definition at line 136 of file RenderMaterial.h.

◆ create() [2/2]

static agxStream::Serializable* agxCollide::RenderMaterial::create ( )
inlinestatic

Definition at line 136 of file RenderMaterial.h.

◆ deleteUsingDeleteHandler()

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited

◆ equal()

bool agxCollide::RenderMaterial::equal ( const RenderMaterial &  other) const
Parameters
other- Material to compare to
Returns
true if the two materials are content wise equal to each other. Fast comparison

◆ generateUuid()

void agxStream::Serializable::generateUuid ( )
protectedinherited

◆ getAmbientColor()

agx::Vec4f agxCollide::RenderMaterial::getAmbientColor ( ) const
Returns
the current ambient color

◆ getClassName()

const char* agxCollide::RenderMaterial::getClassName ( ) const
inlineoverridevirtual
Returns
the class name of this class.

Reimplemented from agxStream::Serializable.

Definition at line 136 of file RenderMaterial.h.

◆ getConstructClassId()

static const char* agxCollide::RenderMaterial::getConstructClassId ( )
inlinestatic

Definition at line 136 of file RenderMaterial.h.

◆ getDeleteHandler()

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.

◆ getDiffuseColor()

agx::Vec4f agxCollide::RenderMaterial::getDiffuseColor ( ) const
Returns
the current diffuse color

◆ getEmissiveColor()

agx::Vec4f agxCollide::RenderMaterial::getEmissiveColor ( ) const
Returns
the current emissive color

◆ getEnableSerialization()

bool agxStream::Serializable::getEnableSerialization ( ) const
inherited
Returns
true if serialization is enabled for this object

Definition at line 273 of file Serializable.h.

◆ getEnableUuidGeneration()

bool agxStream::Serializable::getEnableUuidGeneration ( )
inherited
Returns
true if Uuid:s should be generated for each new Serializable object

◆ getHash()

agx::UInt32 agxCollide::RenderMaterial::getHash ( ) const
Returns
Hash value calculated from the string where all attributes are concatenated.

◆ getIndex()

agx::UInt32 agxStream::Serializable::getIndex ( ) const
inherited

This index is given at creation of this object.

It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.

Returns
an instance index of this object. This is unique for the lifetime of this library instance.

Definition at line 247 of file Serializable.h.

◆ getMaterialSpecification()

agx::String agxCollide::RenderMaterial::getMaterialSpecification ( ) const
Returns
a stored material specification

◆ getName()

agx::String agxCollide::RenderMaterial::getName ( ) const
Returns
the name of the material

◆ getReferenceCount()

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.

◆ getShininess()

float agxCollide::RenderMaterial::getShininess ( ) const
Returns
the shininess

◆ getSpecularColor()

agx::Vec4f agxCollide::RenderMaterial::getSpecularColor ( ) const
Returns
the current diffuse color

◆ getStorageAgent()

agxStream::StorageAgent* agxCollide::RenderMaterial::getStorageAgent ( ) const
inlineoverridevirtual
Returns
the storage agent

Implements agxStream::Serializable.

Definition at line 136 of file RenderMaterial.h.

◆ getTexturePath()

agx::String agxCollide::RenderMaterial::getTexturePath ( TextureMode  mode = DIFFUSE_TEXTURE) const
Returns
the path to a texture for the specified texturing mode (default DIFFUSE)

◆ getTransparency()

float agxCollide::RenderMaterial::getTransparency ( ) const
Returns
transparency of material

◆ getUuid()

agx::Uuid agxStream::Serializable::getUuid ( ) const
inherited
Returns
a unique id for this instance.

Definition at line 268 of file Serializable.h.

Referenced by agxSDK::UuidHashCollisionFilter::match().

◆ hasAmbientColor()

bool agxCollide::RenderMaterial::hasAmbientColor ( ) const
Returns
true if the ambient color is different from -1,-1,-1 (which is default)

◆ hasDiffuseColor()

bool agxCollide::RenderMaterial::hasDiffuseColor ( ) const
Returns
true if the diffuse color is different from -1,-1,-1 (which is default)

◆ hasEmissiveColor()

bool agxCollide::RenderMaterial::hasEmissiveColor ( ) const
Returns
true if the emissive color is different from -1,-1,-1 (which is default)

◆ hasMaterialSpecification()

bool agxCollide::RenderMaterial::hasMaterialSpecification ( ) const
Returns
true if a material specification is specified

◆ hasShininess()

bool agxCollide::RenderMaterial::hasShininess ( ) const
Returns
true if shininess != -1, which is default

◆ hasSpecularColor()

bool agxCollide::RenderMaterial::hasSpecularColor ( ) const
Returns
true if the diffuse color is different from -1,-1,-1 (which is default)

◆ hasTexturePath()

bool agxCollide::RenderMaterial::hasTexturePath ( TextureMode  mode = DIFFUSE_TEXTURE) const
Returns
true if the specified mode has a texture specified

◆ hasTransparency()

bool agxCollide::RenderMaterial::hasTransparency ( ) const
Returns
true if transparency != -1

◆ is()

template<typename T >
bool agx::Referenced::is ( ) const
inherited

◆ isFinished()

bool agxStream::Serializable::isFinished ( ) const
inherited
Returns
true if this class is restored correctly and should not be deleted during destruction of an Archive.

Definition at line 252 of file Serializable.h.

References AGX_FORCE_INLINE.

◆ operator==()

bool agxCollide::RenderMaterial::operator== ( const RenderMaterial &  other) const
Returns
true if the materials has equal value (uses equal method)

◆ reference()

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

◆ restore()

virtual void agxCollide::RenderMaterial::restore ( agxStream::InputArchive &  in)
overridevirtual

◆ setAmbientColor()

void agxCollide::RenderMaterial::setAmbientColor ( const agx::Vec4f &  color)

Set the ambient color.

◆ setDeleteHandler()

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

◆ setDiffuseColor()

void agxCollide::RenderMaterial::setDiffuseColor ( const agx::Vec4f &  color)

Set the diffuse color.

◆ setEmissiveColor()

void agxCollide::RenderMaterial::setEmissiveColor ( const agx::Vec4f &  color)

Set the emissive color.

◆ setEnableSerialization()

void agxStream::Serializable::setEnableSerialization ( bool  flag)
inherited

Set to false to disable serialization of this object.

It will just be ignored during serialization (writing). It is still possible to restore TO this object.

◆ setEnableUuidGeneration()

static void agxStream::Serializable::setEnableUuidGeneration ( bool  flag)
staticinherited

Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.

◆ setFinished()

void agxStream::Serializable::setFinished ( )
inherited

Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.

◆ setMaterialSpecification()

void agxCollide::RenderMaterial::setMaterialSpecification ( const agx::String &  material)

Store a string with a material specification, for example Keyshot material string.

◆ setName()

void agxCollide::RenderMaterial::setName ( const agx::String &  name)

Set the name of this material.

◆ setShininess()

void agxCollide::RenderMaterial::setShininess ( float  shininess)

Set the shininess of the material.

◆ setSpecularColor()

void agxCollide::RenderMaterial::setSpecularColor ( const agx::Vec4f &  color)

Set the specular color.

◆ setTexturePath()

void agxCollide::RenderMaterial::setTexturePath ( const agx::String &  path,
TextureMode  mode = DIFFUSE_TEXTURE 
)

Set the path to a texture for the specified texturing mode (default DIFFUSE)

Parameters
path- path to the texture
mode- texturing mode

◆ setTransparency()

void agxCollide::RenderMaterial::setTransparency ( float  transparency)

Set the transparency of the material 1 - transparent, 0 - opaque.

◆ setUuid()

void agxStream::Serializable::setUuid ( const agx::Uuid &  uuid)
inherited

Explicitly set a Uuid on a serializable object.

Use this method with great care, as it can result in non-unique identifiers in the system!

◆ store()

virtual void agxCollide::RenderMaterial::store ( agxStream::OutputArchive &  out) const
overridevirtual

◆ toString()

agx::String agxCollide::RenderMaterial::toString ( ) const
protected
Returns
a concatenated string of all attributes of this class

◆ unreference()

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().

◆ unreference_nodelete()

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

◆ ValidateCast()

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

◆ m_ambientColor

agx::Vec4f agxCollide::RenderMaterial::m_ambientColor
protected

Definition at line 174 of file RenderMaterial.h.

◆ m_diffuseColor

agx::Vec4f agxCollide::RenderMaterial::m_diffuseColor
protected

Definition at line 172 of file RenderMaterial.h.

◆ m_emissiveColor

agx::Vec4f agxCollide::RenderMaterial::m_emissiveColor
protected

Definition at line 175 of file RenderMaterial.h.

◆ m_materialSpecification

agx::String agxCollide::RenderMaterial::m_materialSpecification
protected

Definition at line 171 of file RenderMaterial.h.

◆ m_mutex

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

◆ m_name

agx::String agxCollide::RenderMaterial::m_name
protected

Definition at line 178 of file RenderMaterial.h.

◆ m_observers

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

◆ m_refCount

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

◆ m_shininess

float agxCollide::RenderMaterial::m_shininess
protected

Definition at line 177 of file RenderMaterial.h.

◆ m_specularColor

agx::Vec4f agxCollide::RenderMaterial::m_specularColor
protected

Definition at line 173 of file RenderMaterial.h.

◆ m_texturePaths

agx::StringVector agxCollide::RenderMaterial::m_texturePaths
protected

Definition at line 179 of file RenderMaterial.h.

◆ m_transparency

float agxCollide::RenderMaterial::m_transparency
protected

Definition at line 176 of file RenderMaterial.h.


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