PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureMaterial Class Reference

Material class. More...

Detailed Description

Material class.

Definition at line 150 of file PureMaterialManager.h.

#include <PureMaterialManager.h>

+ Inheritance diagram for PureMaterial:

Classes

class  PureMaterialImpl
 

Public Member Functions

virtual ~PureMaterial ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
TPureBool allocateArrays (TPureUInt nColorCount, TPureUInt nTexcoordCount, TPureUInt nIndexCount, TPureUInt nIndexSize)
 Allocate color-, texture coordinate-, and index arrays on all available levels.
 
TPureUInt getIndicesCount () const
 Gets the number of indices.
 
TPureUInt getColorsCount (TPureUInt level=0) const
 Gets the number of colors on the specified level.
 
TRGBAFLOATgetColors (TPureUInt level=0)
 Gets the pointer to colors on the specified level.
 
const TRGBAFLOATgetColors (TPureUInt level=0) const
 Gets the pointer to colors on the specified level.
 
TPureUInt getTexcoordsCount (TPureUInt level=0) const
 Gets the number of texture coordinates on the specified level.
 
TUVWgetTexcoords (TPureUInt level=0)
 Gets the pointer to texture coordinates on the specified level.
 
const TUVWgetTexcoords (TPureUInt level=0) const
 Gets the pointer to texture coordinates on the specified level.
 
PureTexturegetTexture (TPureUInt level=0)
 Gets the texture of the material on the specified level.
 
const PureTexturegetTexture (TPureUInt level=0) const
 Gets the texture of the material on the specified level.
 
TPureBool setTexture (PureTexture *tex, TPureUInt level=0)
 Sets the texture of the material on the specified level.
 
TPureUInt getTextureCount () const
 Gets the number of textures assigned to this material.
 
TPureBool isTextured () const
 Gets whether the material has at least 1 textured layer.
 
TPureBool isSingleTextured () const
 Gets whether the material has only 1 textured layer.
 
TPureBool isMultiTextured () const
 Gets whether the material has at least 2 textured layers.
 
PureColorgetTextureEnvColor (TPureUInt level=0)
 Gets the texture environment color of the material on the specified level.
 
const PureColorgetTextureEnvColor (TPureUInt level=0) const
 Gets the texture environment color of the material on the specified level.
 
const TPureBoolisDecalOffsetEnabled () const
 Gets whether material is used as decal rendering.
 
void setDecalOffset (TPureBool state)
 Sets decal rendering for this material.
 
TPURE_BLENDFACTOR getSourceBlendFunc (TPureUInt level=0) const
 Gets the source blend factor on the specified level.
 
TPureBool setSourceBlendFunc (TPURE_BLENDFACTOR value, TPureUInt level=0)
 Sets the source blend factor on the specified level.
 
TPURE_BLENDFACTOR getDestinationBlendFunc (TPureUInt level=0) const
 Gets the destination blend factor on the specified level.
 
TPureBool setDestinationBlendFunc (TPURE_BLENDFACTOR value, TPureUInt level=0)
 Sets the destination blend factor on the specified level.
 
TPureBool setBlendFuncs (TPURE_BLENDFACTOR src, TPURE_BLENDFACTOR dst, TPureUInt level=0)
 Sets the blend factors on the specified level.
 
TPURE_BLENDMODE getBlendMode (TPureUInt level=0) const
 Gets the blend mode on the specified level.
 
TPureBool setBlendMode (TPURE_BLENDMODE mode, TPureUInt level=0)
 Sets the blend mode on the specified level.
 
TPureBool copyFromMaterial (PureMaterial &srcMat, TPureUInt dstLevel, TPureUInt srcLevel)
 Copies a layer of a material to a layer of this material.
 
virtual TPureUInt getUsedSystemMemory () const
 Gets the amount of allocated system memory.
 
- Public Member Functions inherited from PureFiledManaged
 PureFiledManaged ()
 
virtual ~PureFiledManaged ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
const std::string & getFilename () const
 Gets the filename.
 
- Public Member Functions inherited from PureManaged
 PureManaged ()
 
virtual ~PureManaged ()
 
CConsole & getManagedConsole () const
 Returns access to console preset with logger module name as this class.
 
const PureManagedgetUtiliser () const
 Returns the managed that utilizes this managed.
 
PureManagedgetUtiliser ()
 Returns the managed that utilizes this managed.
 
void SetUtiliser (PureManaged *pUtiliser)
 Sets the managed that utilizes this managed.
 
void DetachFrom ()
 Removes the managed from its manager.
 
PureManagergetManager () const
 Gets the manager of the managed.
 
const std::string & getName () const
 Gets the name.
 
void SetName (const std::string &name)
 Sets the name.
 
virtual void FlushResources ()
 This can be used if the specialized managed object has some resources that may be released from memory when not needed anymore.
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
static TPureBool isBlendFuncReallyBlending (TPURE_BLENDFACTOR sfactor, TPURE_BLENDFACTOR dfactor)
 Gets whether the given source and destination factors really mean blending or not.
 
- Static Public Member Functions inherited from PureFiledManaged
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureManaged
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Protected Member Functions

 PureMaterial (TPureUInt nLayers=1)
 Only PureMaterialManager creates it.
 
 PureMaterial (const PureMaterial &)
 
PureMaterialoperator= (const PureMaterial &)
 
- Protected Member Functions inherited from PureFiledManaged
 PureFiledManaged (const PureFiledManaged &other)
 
PureFiledManagedoperator= (const PureFiledManaged &other)
 
void SetFilename (const std::string &filename)
 Sets the filename.
 
- Protected Member Functions inherited from PureManaged
 PureManaged (const PureManaged &other)
 
PureManagedoperator= (const PureManaged &other)
 

Private Attributes

PureMaterialImplpImpl
 

Friends

class PureMaterialManager
 

Constructor & Destructor Documentation

◆ ~PureMaterial()

PureMaterial::~PureMaterial ( )
virtual

Definition at line 518 of file PureMaterial.cpp.

◆ PureMaterial() [1/2]

PureMaterial::PureMaterial ( TPureUInt nLayers = 1)
explicitprotected

Only PureMaterialManager creates it.

Exceptions
std::bad_alloc- This class or its ancestor dynamically allocates memory with operator new, in case of failure the exception is not handled but propagated to caller.
Anyexception that might be thrown by std::vector::push_back(), in case of failure the exception is not handled but propagated to caller.

Definition at line 983 of file PureMaterial.cpp.

◆ PureMaterial() [2/2]

PureMaterial::PureMaterial ( const PureMaterial & )
protected

Definition at line 989 of file PureMaterial.cpp.

Member Function Documentation

◆ allocateArrays()

TPureBool PureMaterial::allocateArrays ( TPureUInt nColorCount,
TPureUInt nTexcoordCount,
TPureUInt nIndexCount,
TPureUInt nIndexSize )

Allocate color-, texture coordinate-, and index arrays on all available levels.

Although the size of color- and texture coordinate arrays may differ, the allocated color index arrays and texture coordinate index arrays will have same size since indexing is done per-vertex.

Parameters
nColorCountSize of required color array on each level.
nTexcoordCountSize of required texture coordinate array on each level.
nIndexCountSize of required index array on each level.
nIndexSizeSize of an index in Bytes. Should be greater than 0.
Returns
True if allocation succeeded or already allocated, false otherwise.

Definition at line 574 of file PureMaterial.cpp.

◆ copyFromMaterial()

TPureBool PureMaterial::copyFromMaterial ( PureMaterial & srcMat,
TPureUInt dstLevel,
TPureUInt srcLevel )

Copies a layer of a material to a layer of this material.

The array sizes of the 2 materials should match as array layout won't be changed by this method.

Parameters
srcMatMaterial where we are copying a layer from.
dstLevelWhich layer are we copying from the source material.
srcLevelWhich layer are we copying to in destination material.
Returns
True on success, false otherwise.

Definition at line 957 of file PureMaterial.cpp.

◆ getBlendMode()

TPURE_BLENDMODE PureMaterial::getBlendMode ( TPureUInt level = 0) const

Gets the blend mode on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Blend mode. It is PURE_BM_MANUAL if source and destination blend factor combination doesn't match any predefined blend mode. In case of invalid level, PURE_BM_NONE is returned.

Definition at line 925 of file PureMaterial.cpp.

◆ getColors() [1/2]

TRGBAFLOAT * PureMaterial::getColors ( TPureUInt level = 0)

Gets the pointer to colors on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to colors on the specified layer, PGENULL on error.

Definition at line 606 of file PureMaterial.cpp.

◆ getColors() [2/2]

const TRGBAFLOAT * PureMaterial::getColors ( TPureUInt level = 0) const

Gets the pointer to colors on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to colors on the specified layer, PGENULL on error.

Definition at line 620 of file PureMaterial.cpp.

◆ getColorsCount()

TPureUInt PureMaterial::getColorsCount ( TPureUInt level = 0) const

Gets the number of colors on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Number of colors on the specified layer, 0 on error.

Definition at line 592 of file PureMaterial.cpp.

◆ getDestinationBlendFunc()

TPURE_BLENDFACTOR PureMaterial::getDestinationBlendFunc ( TPureUInt level = 0) const

Gets the destination blend factor on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Destination blend factor on the specified level. If level is invalid, then the destination blend factor on the lowest level is returned.

Definition at line 870 of file PureMaterial.cpp.

◆ getIndicesCount()

TPureUInt PureMaterial::getIndicesCount ( ) const

Gets the number of indices.

Returns
Number of indices.

Definition at line 631 of file PureMaterial.cpp.

◆ getLoggerModuleName()

const char * PureMaterial::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Intentionally not virtual, so derived class should hide this instead of overriding. Not even private, so user can also access this from outside, for any reason like controlling log filtering per logger module name.

Returns
The logger module name of this class.

Definition at line 544 of file PureMaterial.cpp.

◆ getManagedConsole()

CConsole & PureMaterial::getManagedConsole ( ) const

Returns access to console preset with logger module name as this class.

Intentionally not virtual, so the getConsole() in derived class should hide this instead of overriding.

Returns
Console instance used by this class.

Definition at line 531 of file PureMaterial.cpp.

◆ getSourceBlendFunc()

TPURE_BLENDFACTOR PureMaterial::getSourceBlendFunc ( TPureUInt level = 0) const

Gets the source blend factor on the specified level.

0 is the default level.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Source blend factor on the specified level. If level is invalid, then the source blend factor on the lowest level is returned.

Definition at line 840 of file PureMaterial.cpp.

◆ getTexcoords() [1/2]

TUVW * PureMaterial::getTexcoords ( TPureUInt level = 0)

Gets the pointer to texture coordinates on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to texture coordinates on the specified layer, PGENULL on error.

Definition at line 659 of file PureMaterial.cpp.

◆ getTexcoords() [2/2]

const TUVW * PureMaterial::getTexcoords ( TPureUInt level = 0) const

Gets the pointer to texture coordinates on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to texture coordinates on the specified layer, PGENULL on error.

Definition at line 673 of file PureMaterial.cpp.

◆ getTexcoordsCount()

TPureUInt PureMaterial::getTexcoordsCount ( TPureUInt level = 0) const

Gets the number of texture coordinates on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Number of texture coordinates on the specified layer, 0 on error.

Definition at line 645 of file PureMaterial.cpp.

◆ getTexture() [1/2]

PureTexture * PureMaterial::getTexture ( TPureUInt level = 0)

Gets the texture of the material on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to texture on the specified level, PGENULL on error or if no texture is assigned to this level.

Definition at line 687 of file PureMaterial.cpp.

◆ getTexture() [2/2]

const PureTexture * PureMaterial::getTexture ( TPureUInt level = 0) const

Gets the texture of the material on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
Pointer to texture on the specified level, PGENULL on error or if no texture is assigned to this level.

Definition at line 701 of file PureMaterial.cpp.

◆ getTextureCount()

TPureUInt PureMaterial::getTextureCount ( ) const

Gets the number of textures assigned to this material.

Returns
Number of textures assigned to this material on all levels.

Definition at line 726 of file PureMaterial.cpp.

◆ getTextureEnvColor() [1/2]

PureColor & PureMaterial::getTextureEnvColor ( TPureUInt level = 0)

Gets the texture environment color of the material on the specified level.

Texture environment color is used by the texture environment mode / function in producing fragment color and alpha values. The default texture environment color is white [255, 255, 255, 255].

Texture environment mode / function is currently cannot be changed, it is PURE_TEX_FUNC_MODULATE by default, hence even setting texture environment color has no effect at all.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
The texture environment color of the material on the specified level. If level is invalid, then the color on the lowest level is returned.

Definition at line 779 of file PureMaterial.cpp.

◆ getTextureEnvColor() [2/2]

const PureColor & PureMaterial::getTextureEnvColor ( TPureUInt level = 0) const

Gets the texture environment color of the material on the specified level.

Texture environment color is used by the texture environment mode / function in producing fragment color and alpha values. The default texture environment color is white [255, 255, 255, 255].

Texture environment mode / function is currently cannot be changed, it is PURE_TEX_FUNC_MODULATE by default, hence even setting texture environment color has no effect at all.

0 is the default level, always used for single-textured materials.

Parameters
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
The texture environment color of the material on the specified level. If level is invalid, then the color on the lowest level is returned.

Definition at line 798 of file PureMaterial.cpp.

◆ getUsedSystemMemory()

TPureUInt PureMaterial::getUsedSystemMemory ( ) const
virtual

Gets the amount of allocated system memory.

Returns
Amount of allocated system memory in Bytes.

Reimplemented from PureFiledManaged.

Definition at line 968 of file PureMaterial.cpp.

◆ isBlendFuncReallyBlending()

TPureBool PureMaterial::isBlendFuncReallyBlending ( TPURE_BLENDFACTOR sfactor,
TPURE_BLENDFACTOR dfactor )
static

Gets whether the given source and destination factors really mean blending or not.

Gets whether the given source and destination blend factors really mean blending or not.

If source factor is PURE_ONE and destination factor is PURE_ZERO, there's no blending even if blending is enabled.

Returns
True if the given blend factors really mean blending, false otherwise.

Definition at line 556 of file PureMaterial.cpp.

◆ isDecalOffsetEnabled()

const TPureBool & PureMaterial::isDecalOffsetEnabled ( ) const

Gets whether material is used as decal rendering.

See details at setDecalOffset().

Returns
True if decal / polygon offseting is enabled, false otherwise.

Definition at line 810 of file PureMaterial.cpp.

◆ isMultiTextured()

TPureBool PureMaterial::isMultiTextured ( ) const

Gets whether the material has at least 2 textured layers.

Returns
True if there is at least 2 textured layers, false otherwise.

Definition at line 759 of file PureMaterial.cpp.

◆ isSingleTextured()

TPureBool PureMaterial::isSingleTextured ( ) const

Gets whether the material has only 1 textured layer.

Returns
True if there is only 1 textured layer, false otherwise.

Definition at line 748 of file PureMaterial.cpp.

◆ isTextured()

TPureBool PureMaterial::isTextured ( ) const

Gets whether the material has at least 1 textured layer.

Returns
True if there is at least 1 textured layer, false otherwise.

Definition at line 737 of file PureMaterial.cpp.

◆ operator=()

PureMaterial & PureMaterial::operator= ( const PureMaterial & )
protected

Definition at line 995 of file PureMaterial.cpp.

◆ setBlendFuncs()

TPureBool PureMaterial::setBlendFuncs ( TPURE_BLENDFACTOR src,
TPURE_BLENDFACTOR dst,
TPureUInt level = 0 )

Sets the blend factors on the specified level.

0 is the default level. Equivalent to calling setSourceBlendFunc(src, level) and setDestinationBlendFunc(dst, level), so check their documentation as well for accepted values. See the description of those functions for more details about the cases when there is no effect when calling them.

If you want to utilize transparency of a loaded 32 bit color depth bitmap, you have to make sure the bitmap has proper alpha values. Some image editing applications don't save proper alpha values, as explained at PureImageManager::createFromFile().

For bitmaps not having proper alpha bits use (PURE_SRC_ALPHA, PURE_ONE) for src and dst respectively. For bitmaps having proper alpha bits use (PURE_SRC_ALPHA, PURE_ONE_MINUS_SRC_ALPHA) for src and dst respectively to utilize real alpha.

Parameters
srcSource blend factor to be set on the specified level.
dstDestination blend factor to be set on the specified level.
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
True on success, false otherwise.

Definition at line 910 of file PureMaterial.cpp.

◆ setBlendMode()

TPureBool PureMaterial::setBlendMode ( TPURE_BLENDMODE mode,
TPureUInt level = 0 )

Sets the blend mode on the specified level.

0 is the default level. PURE_BM_MANUAL input is ignored, it is set by the engine when the blend factors do not match with a predefined blend mode. No effect if the material doesn't have an utiliser entity (e.g. PureObject3D instance) or if the utiliser doesn't have its parent set (e.g. PureObject3DManager).

Parameters
modeThe requested blend mode.
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
True on success, false otherwise.

Definition at line 941 of file PureMaterial.cpp.

◆ setDecalOffset()

void PureMaterial::setDecalOffset ( TPureBool state)

Sets decal rendering for this material.

Useful when you have coplanar overlaying surfaces, to avoid Z-fighting/bleeding: enable this for the decal surface which supposed to be on top of the other surface. If enabled, the calculated depth values of the fragments will be offset enough to make the fragments appear on top of the fragments of the other surface. Basically this controls glPolygonOffset() behind the scene. By default it is disabled.

Parameters
stateTrue for enabling decal / polygon offseting, false for disabling it.

Definition at line 826 of file PureMaterial.cpp.

◆ setDestinationBlendFunc()

TPureBool PureMaterial::setDestinationBlendFunc ( TPURE_BLENDFACTOR value,
TPureUInt level = 0 )

Sets the destination blend factor on the specified level.

0 is the default level. No effect if the given value is one of the following: PURE_DST_COLOR, PURE_ONE_MINUS_DST_COLOR, PURE_SRC_ALPHA_SATURATE. No effect if the material doesn't have an utiliser entity (e.g. PureObject3D instance) or if the utiliser doesn't have its parent set (e.g. PureObject3DManager).

Parameters
valueDestination blend factor to be set on the specified level.
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
True on success, false otherwise.

Definition at line 887 of file PureMaterial.cpp.

◆ setSourceBlendFunc()

TPureBool PureMaterial::setSourceBlendFunc ( TPURE_BLENDFACTOR value,
TPureUInt level = 0 )

Sets the source blend factor on the specified level.

0 is the default level. No effect if the given value is PURE_SRC_COLOR or PURE_ONE_MINUS_SRC_COLOR. No effect if the material doesn't have an utiliser entity (e.g. PureObject3D instance) or if the utiliser doesn't have its parent set (e.g. PureObject3DManager).

Parameters
valueSource blend factor to be set on the specified level.
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
True on success, false otherwise.

Definition at line 856 of file PureMaterial.cpp.

◆ setTexture()

TPureBool PureMaterial::setTexture ( PureTexture * tex,
TPureUInt level = 0 )

Sets the texture of the material on the specified level.

0 is the default level, always used for single-textured materials.

Parameters
texTexture we are defining for the specified level. Texture can be unassigned from the specified level by specifying NULL here.
levelThe material level/layer we are interested in. Should be less than MaterialManager::getMaximumLayerCount().
Returns
True on success, false otherwise.

Definition at line 715 of file PureMaterial.cpp.

Friends And Related Symbol Documentation

◆ PureMaterialManager

friend class PureMaterialManager
friend

Definition at line 241 of file PureMaterialManager.h.

Member Data Documentation

◆ pImpl

PureMaterialImpl* PureMaterial::pImpl
private

Definition at line 239 of file PureMaterialManager.h.


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