TexturePool Class Reference

#include <material.h>

Class Description

This is a container class for simple textures.

In Mudbox, textures are confined to a 0 to 1 UV space. If an object has texture coordinates that go outside this 0-1 space, then multiple texture tiles are used to represent the texture, one tile per unit region in texture space. This class is a container for all the tiles that comprise a texture.

Mudbox also uses paint layers (where each layer would have the same number of tiles). An instance of the TexturePool class can therefore also be a LayerContainer. In this case it is possible to cast a TexturePool pointer into a pointer to a LayerContainer instance, and use the LayerContainer pointer to determine the number of layers and get them. Each pointer to a layer object can then be cast into a TexturePool object again, which then will be the physical paint layer. See the Material class documentation for more details.

+ Examples:

Definition at line 467 of file material.h.

+ Inheritance diagram for TexturePool:

Classes

struct  TileDescriptor
 This structure describes the default texture parameters used when creating texture tiles for this TexturePool. More...
 

Public Types

enum  RenderMode { renderModeConstantColor, renderModeTexture, renderModeVertexColor }
 
enum  Location { locationUnknown, locationGPU, locationCPU, locationDisk }
 
enum  Usage {
  usagePaintLayer, usageLayerMask, usageAdjustmentLayer, usagePaintLayerGroup,
  usageUnknown
}
 
- Public Types inherited from Node
enum  DiagnosticLevel { dgnLevel1, dgnLevel2, dgnLevel3 }
 Indicates the level of validity checking that is performed in CheckValidity() More...
 

Public Member Functions

virtual const TileDescriptorDefaultTileDescriptor (void) const
 Returns the default parameters that are used to construct new texture tiles. More...
 
virtual void SetDefaultTileDescriptor (const TileDescriptor &pDesc)
 Sets the default parameters that are used to construct new texture tiles. More...
 
virtual enum Usage Usage () const
 A texture pool can have different usages. More...
 
virtual void SetUsage (enum Usage eUsage)
 Sets the desired usage type for this texture pool. See TexturePool::Usage(). More...
 
virtual QString Name (void) const
 Returns the name of the texturepool. More...
 
virtual void SetName (const QString &sName)
 Sets the name of the texture pool. More...
 
virtual unsigned int RenderMode (void) const
 Returns the render mode of the texture pool. 0=constant color, 1=texture, 2=vertex color. More...
 
virtual void SetRenderMode (unsigned int iMode)
 Sets the render mode for the texture pool. More...
 
virtual void SetLocation (unsigned int iLocation)
 Sets the location for the texture pool. More...
 
virtual unsigned int Location (void) const
 Gets the location for the texture pool. More...
 
virtual TexturePooloperator= (TexturePool &cT)
 
virtual int Width (void) const
 Returns the number of tiles in a row. More...
 
virtual void SetWidth (int iWidth)
 Sets the number of tiles in a row. More...
 
virtual void SetFileName (const QString &sFileName)
 Set the file name mask for the texture pool. More...
 
virtual const QStringFileName (void) const
 Returns the file name mask for the texture pool. More...
 
virtual void Save (const QString &sFileName="", const QString &sFormat="", Material *m=NULL, bool bForced=false)
 Saves the textures into files on the disk. More...
 
virtual void Export (const QString &sFileName, const QString &sFormat="", Material *m=NULL)
 Exports the textures into files on the disk. More...
 
virtual void SetDirty (bool bDirty)
 Sets the dirty status of the texture. More...
 
virtual bool IsDirty (void) const
 Gets the dirty status of the texture. More...
 
virtual void AddToDirtyArea (const Vector &cPoint)
 Adds a point to the dirty region of this texture pool. More...
 
virtual void SetTilesDirty (void)
 Sets all tiles dirty in the texture pool. More...
 
virtual void Reload (void)
 Reload the pool from the files based on the current file name mask. More...
 
virtual void SetContentChanged (void)
 Sets a flag to say that the texturepool has been modified. More...
 
virtual bool IsContentChanged (void)
 Returns true if the texturepool has been modified since the last file save. More...
 
virtual unsigned int TileCount (void) const
 Returns the number of created tiles so far. These tiles can overlap. More...
 
virtual class TextureTile (unsigned int iTileIndex)
 Returns a pointer to a specified tile. Do not delete this pointer. More...
 
virtual class TextureTile (const AxisAlignedBoundingBox &cTCArea, bool bAlloc=true)
 Returns a texture tile for a coordinate range. More...
 
virtual class TextureTile (float U, float V, bool bAlloc=true)
 Returns a texture tile for a coordinate. More...
 
virtual AxisAlignedBoundingBox TileArea (unsigned int iTileIndex) const
 Returns the UV area associated with a tile. More...
 
TextureTileArraygetTextureTileArray ()
 
virtual TextureMixerMixer (void) const
 Returns a mixer object for the pool. More...
 
virtual int BlendMode (void) const
 Returns the blending mode of the pool. More...
 
virtual void SetBlendMode (int iMode)
 Sets the blending mode. More...
 
virtual void SetMaterial (Material *pMaterial)
 
virtual MaterialGetMaterial () const
 
virtual TexturePoolBuffer (void) const
 return the material associated with this texture pool. More...
 
virtual qint64 TileVideoMemoryUsage (const AxisAlignedBoundingBox &cArea, float fTCGrad=-1)
 Returns the estimated video memory usage for the specific tile, for the specific texture coordinate gradient. More...
 
- Public Member Functions inherited from Node
 Node (const QString &sStringID="", const QString &sDisplayName="")
 Standard constructor. More...
 
virtual ~Node (void)
 
virtual void Initialize (void)
 
void LoadTemplate (const QString &sFileName="", bool bStartEvent=false)
 Use an external XML file to initialize the attributes. More...
 
void SaveTemplate (const QString &sFileName="", bool bSaveOnlyVisible=false)
 Save current attributes as an XML template. More...
 
unsigned int Version (void) const
 Returns the current version of the node. This number increases when the content of the node changed (when ContentChanged() called). More...
 
void SetVersion (unsigned int iVersion)
 Sets the current version number for the node. More...
 
unsigned int ReferenceCount (void) const
 Returns the number of pointers referencing this node. More...
 
AttributeReferencePointer (unsigned int iIndex) const
 Returns the address of an attribute which refers to this node. The type of the attribute is always aptr. More...
 
NodeReferenceNode (unsigned int iIndex) const
 Returns the address of a node referencing this node. More...
 
virtual QString Name (const ClassDesc *pClass=0) const
 Deprecated. More...
 
virtual QString StringID (const ClassDesc *pClass=0) const
 Returns the string id of the node. More...
 
virtual void SetStringID (const QString &sStringID)
 Sets the string id of the node. More...
 
virtual QString DisplayName (void) const
 Returns the display name of the node. More...
 
virtual void SetDisplayName (const QString &sDisplayName)
 Sets the display name of the node. More...
 
virtual QString HelpID (void) const
 Returns the help entry id of the node. Can be overwritten in derived classes. More...
 
virtual void SetHelpID (const QString &sHelpID)
 Sets the help entry id of the node. More...
 
void Annex (Node *pSource, const QString &sCategory="")
 Relink all the attributes of the source node to this one. More...
 
virtual void Serialize (Stream &s)
 Serializes the node. More...
 
bool IsKindOf (const ClassDesc *pClass) const
 Returns true if this node is derived from the pClass class. More...
 
void ContentChanged (void) const
 This function must be called if the content of the node is changed. More...
 
virtual void CheckValidity (DiagnosticLevel iLevel=dgnLevel2) const
 Checks the validity of this node. More...
 
virtual void CopyTo (Node *pNode) const
 
virtual NodeDuplicate (void) const
 
virtual void OnNodeEvent (const Attribute &cAttribute, NodeEventType cType)
 This function is called if an event occurs with any of the attributes of the node. More...
 
virtual void OnEvent (const EventGate &cEvent)
 This function is called when a generic event occurs. See EventGate class. More...
 
void RequestDeferredEvent (Attribute &cAttribute)
 Request for a deferred event, which will occur only in the main loop. More...
 
unsigned int AttributeCount (void) const
 Returns the number of attributes owned by the node. More...
 
AttributeAttributeByIndex (int iIndex) const
 Returns a specified attribute (or 0 if iIndex is greater than the number of attributes). More...
 
AttributeAttributeByName (const QString &sName) const
 Returns a specified attribute by its name. Returns 0 if the attribute not found. More...
 
AttributeAttributeByID (const QString &sID) const
 Returns a specified attribute by its ID. Returns 0 if the attribute not found. More...
 
void SetAttributeValue (const QString &sAttributeID, const QString &sNewValue)
 Set the value of an attribute from a string. More...
 
QString AttributeValue (const QString &sAttributeID) const
 Returns the current value of an attribute as a string. More...
 
void LogAttributes (void) const
 Write all attributes into the log file. More...
 
virtual QWidgetCreatePropertiesWindow (QWidget *pParent)
 Create a window which displays the attributes of the node. Can be overriden to provide a custom interface. More...
 
AttributeAddAttribute (Attribute::AttributeType type, const QString &id)
 Allows SDK users to add attributes at runtime. More...
 
NodeNext (void) const
 Returns the next node in the chain. Used to enumerate the current nodes. See also First(). More...
 
int ID (void) const
 Returns an ID for the node. The ID is unique in the whole application life. More...
 
bool SetID (int iID)
 Set ID for the node. More...
 

Protected Member Functions

 TexturePool (void)
 Constructor. More...
 

Protected Attributes

TextureTileArray m_TextureTileArray
 

Additional Inherited Members

- Static Public Member Functions inherited from Node
static void StartHashing ()
 This is called once in main once static ctors are done. More...
 
static NodeFirst (void)
 This function will return the first node in the memory. Used to enumerate all the current nodes. See also Next(). More...
 
static NodeByID (int iID)
 Returns the node with the specified ID, or zero if such a node does not exists. More...
 
static NodeByName (const QString &sClass, const QString &sName)
 Search for a node with the name sName. More...
 
- Public Attributes inherited from Node
AttributeThisPointer m_pThis
 
 DECLARE_CLASS
 

Member Enumeration Documentation

enum RenderMode
Enumerator
renderModeConstantColor 
renderModeTexture 
renderModeVertexColor 

Definition at line 504 of file material.h.

enum Location
Enumerator
locationUnknown 
locationGPU 
locationCPU 
locationDisk 

Definition at line 511 of file material.h.

enum Usage
Enumerator
usagePaintLayer 
usageLayerMask 
usageAdjustmentLayer 
usagePaintLayerGroup 
usageUnknown 

Definition at line 519 of file material.h.

Constructor & Destructor Documentation

TexturePool ( void  )
protected

Constructor.

Do not use it directly; Use CreateInstance() instead.

TexturePool *myTexturePool = CreateInstance<TexturePool>();

Member Function Documentation

virtual const TileDescriptor& DefaultTileDescriptor ( void  ) const
virtual

Returns the default parameters that are used to construct new texture tiles.

virtual void SetDefaultTileDescriptor ( const TileDescriptor pDesc)
virtual

Sets the default parameters that are used to construct new texture tiles.

virtual enum Usage Usage ( ) const
virtual

A texture pool can have different usages.

This flag indicates how this pool should be used.

Texture pools can be used for paint layers, paint layer masks, or adjustment layers. All pools are the same regardless of usage. However its useful to differentiate them for layer compositing operations and for UI display. For example, if the layer is being used as a mask (i.e. its usage type is TexturePool::usageLayerMask), the layer's parent is the layer that is affected by the mask.

virtual void SetUsage ( enum Usage  eUsage)
virtual

Sets the desired usage type for this texture pool. See TexturePool::Usage().

virtual QString Name ( void  ) const
virtual

Returns the name of the texturepool.

virtual void SetName ( const QString sName)
virtual

Sets the name of the texture pool.

Parameters
[in]sNameNew texture pool name. If the texture pool is a layer, this is the name of the layer seen in the UI.

Reimplemented from Node.

virtual unsigned int RenderMode ( void  ) const
virtual

Returns the render mode of the texture pool. 0=constant color, 1=texture, 2=vertex color.

virtual void SetRenderMode ( unsigned int  iMode)
virtual

Sets the render mode for the texture pool.

virtual void SetLocation ( unsigned int  iLocation)
virtual

Sets the location for the texture pool.

virtual unsigned int Location ( void  ) const
virtual

Gets the location for the texture pool.

virtual TexturePool& operator= ( TexturePool cT)
virtual
virtual int Width ( void  ) const
virtual

Returns the number of tiles in a row.

The number of tiles in a TexturePool depends on the texture coordinates of the meshes which are using the pool. If the mesh has texture coordinates only within the 0-1 range, then only a single tile will be used, so this function will return 1. But for example when the U texture coordinate is in the range of 0-3 and V is in the range of 0-2, then six tiles will be used, this function will return 3 (since there are 3 tiles horizontally)

virtual void SetWidth ( int  iWidth)
virtual

Sets the number of tiles in a row.

virtual void SetFileName ( const QString sFileName)
virtual

Set the file name mask for the texture pool.

If there is more than a single tile used in the pool, then the file name will be extended with a string indicating which tile it belongs to. The attached string has the format _uX_vY, where X is the horizontal, and Y is the vertical coordinate of the tile. For example if the given filename is texture.jpg, then the name for the third tile in the first row will be texutre_u3_v1.jpg

Parameters
[in]sFileNameThe base file name for the texture files in this pool
virtual const QString& FileName ( void  ) const
virtual

Returns the file name mask for the texture pool.

The name may contain tile wildcards (i, x, y).

virtual void Save ( const QString sFileName = "",
const QString sFormat = "",
Material m = NULL,
bool  bForced = false 
)
virtual

Saves the textures into files on the disk.

If the file format is PSD and the material is not null, the uv mesh is drawn in a layer above the image layer saved by this function.

Parameters
[in]sFileNameThe file name to save
[in]sFormatThe file format in the form "bitDepth,dataType", i.e. "8,i" for 8bit/channel integer. 8, 16, 32 are valid for bitdepth and i and fp are valid for dataType.
[in]mThe material assciated with this texture pool.
[in]bForcedIf the save should happen regardless if the texture is dirty
virtual void Export ( const QString sFileName,
const QString sFormat = "",
Material m = NULL 
)
virtual

Exports the textures into files on the disk.

Unlike Save(), this method does not modify the state of the texture pool.

Parameters
[in]sFileNameThe file name to save
[in]sFormatThe file format in the form "bitDepth,dataType",
mi.e. "8,i" for 8bit/channel integer. 8, 16, 32 are valid for bitdepth and i and fp are valid for dataType. [in] The material assciated with this texture pool.
virtual void SetDirty ( bool  bDirty)
virtual

Sets the dirty status of the texture.

This function must be called after the texture content is changed

Parameters
[in]bDirtySet to true to mark the texture dirty.
virtual bool IsDirty ( void  ) const
virtual

Gets the dirty status of the texture.

virtual void AddToDirtyArea ( const Vector cPoint)
virtual

Adds a point to the dirty region of this texture pool.

Parameters
[in]cPointthe area of the texture pool to mark as dirty
virtual void SetTilesDirty ( void  )
virtual

Sets all tiles dirty in the texture pool.

virtual void Reload ( void  )
virtual

Reload the pool from the files based on the current file name mask.

virtual void SetContentChanged ( void  )
virtual

Sets a flag to say that the texturepool has been modified.

virtual bool IsContentChanged ( void  )
virtual

Returns true if the texturepool has been modified since the last file save.

virtual unsigned int TileCount ( void  ) const
virtual

Returns the number of created tiles so far. These tiles can overlap.

virtual class Texture* Tile ( unsigned int  iTileIndex)
virtual

Returns a pointer to a specified tile. Do not delete this pointer.

Parameters
[in]iTileIndexIndex of the tile to be returned
virtual class Texture* Tile ( const AxisAlignedBoundingBox cTCArea,
bool  bAlloc = true 
)
virtual

Returns a texture tile for a coordinate range.

Attempts to create the texture if it does not yet exist.

Parameters
[in]cTCAreaThe UV area that corresponds to the desired texture.
[in]bAllocSet this to true to guarantee the returned Texture is loaded onto the GPU.
virtual class Texture* Tile ( float  U,
float  V,
bool  bAlloc = true 
)
virtual

Returns a texture tile for a coordinate.

Attempts to create the texture if it does not yet exist. Use this instead of the one taking a AABB. This one is faster.

virtual AxisAlignedBoundingBox TileArea ( unsigned int  iTileIndex) const
virtual

Returns the UV area associated with a tile.

Parameters
[in]iTileIndexIndex of the tile
TextureTileArray* getTextureTileArray ( )
inline

Definition at line 676 of file material.h.

676 { return &m_TextureTileArray; }
TextureTileArray m_TextureTileArray
Definition: material.h:479
virtual TextureMixer* Mixer ( void  ) const
virtual

Returns a mixer object for the pool.

virtual int BlendMode ( void  ) const
virtual

Returns the blending mode of the pool.

virtual void SetBlendMode ( int  iMode)
virtual

Sets the blending mode.

Parameters
[in]iModeThe index of the desired blending mode (see TextureMixer::BlendModeCount() and TextureMixer::BlendModeName() )
virtual void SetMaterial ( Material pMaterial)
virtual
Parameters
[in]pMaterialSet the material associated with this TexturePool.
virtual Material* GetMaterial ( ) const
virtual
virtual TexturePool* Buffer ( void  ) const
virtual

return the material associated with this texture pool.

virtual qint64 TileVideoMemoryUsage ( const AxisAlignedBoundingBox cArea,
float  fTCGrad = -1 
)
virtual

Returns the estimated video memory usage for the specific tile, for the specific texture coordinate gradient.

If no gradient is specified, the actual video memory usage is returned. See Texture::ProxyLevel for a description of the gradient parameter, and how it is used to compute a proxy level.

Parameters
[in]cAreaThe UV tile to query
[in]fTCGradThe texture coordinate gradient, if none specified, the current LOD level is used.

Member Data Documentation

TextureTileArray m_TextureTileArray
protected

Definition at line 479 of file material.h.


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