HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_BindMaterial Class Reference

#include <HUSD_BindMaterial.h>

Public Types

enum  BindMethod { BindMethod::DIRECT, BindMethod::COLLECTION }
 Enumeration of the ways in which a binding can be performed. More...
 
enum  Strength { Strength::DEFAULT, Strength::STRONG, Strength::WEAK }
 Enumeration of the material binding strength. More...
 

Public Member Functions

 HUSD_BindMaterial (HUSD_AutoWriteLock &lock)
 Standard constructor. More...
 
bool bind (const UT_StringRef &mat_prim_path, const UT_StringRef &geo_prim_path) const
 Assigns the given material to the given geometry primitive(s). More...
 
bool bind (const UT_StringRef &mat_prim_path, const HUSD_FindPrims &find_geo_prims) const
 
bool bindWithCollection (const UT_StringRef &mat_prim_path, const HUSD_FindPrims &include_geo_prims, const HUSD_FindPrims &exclude_geo_prims) const
 
bool bindWithPathExpression (const UT_StringRef &mat_prim_path, const UT_StringRef &path_expr) const
 
bool bindSubset (const UT_StringRef &mat_prim_path, const UT_StringRef &geo_prim_path, const UT_Array< exint > *face_indices, const HUSD_TimeCode &tc=HUSD_TimeCode()) const
 
HUSD_Path createSubset (const UT_StringRef &subset_name, const UT_StringRef &geo_prim_path, const UT_Array< exint > &face_indices, const HUSD_TimeCode &tc=HUSD_TimeCode()) const
 
bool isPrimWithoutBoundMaterial (const UT_StringRef &prim_path, const UT_Optional< UT_StringHolder > &purpose=std::nullopt)
 
bool unbindAll (const HUSD_FindPrims &find_prims) const
 
bool unbind (const HUSD_FindPrims &find_prims, const UT_StringHolder &purpose, int unbind_limit=1) const
 
bool assignMaterialsFromAttribute (const UT_StringRef &layername, const UT_StringMap< UT_StringHolder > &args, const UT_StringRef &primpath, bool loadasreference, const UT_StringRef &refprimpath, const UT_StringRef &attrname, bool remove_attr, bool create_empty_materials, const UT_StringRef &reffileattrname, const UT_StringRef &refprimattrname) const
 
void setBindMethod (BindMethod method)
 Sets the method of defining bindings. More...
 
BindMethod getBindMethod () const
 
void setBindCollectionExpand (bool expand)
 Sets the collection expansion option when defining collections. More...
 
bool getBindCollectionExpand () const
 
void setBindCollectionInfo (const UT_StringHolder &primpath, const UT_StringHolder &collectionname)
 
const UT_StringHoldergetBindCollectionPrimPath () const
 
const UT_StringHoldergetBindCollectionName () const
 
void setBindCollectionWarnUnspecifiedPrim (bool warn)
 
bool getBindCollectionWarnUnspecifiedPrim () const
 
void setStrength (Strength strength)
 Sets the strength preference for material assignments. More...
 
Strength getStrength () const
 
void setPurpose (const UT_StringHolder &purpose)
 Sets the purpose for material assignments. More...
 
const UT_StringHoldergetPurpose () const
 

Detailed Description

Definition at line 32 of file HUSD_BindMaterial.h.

Member Enumeration Documentation

Enumeration of the ways in which a binding can be performed.

Enumerator
DIRECT 
COLLECTION 

Definition at line 113 of file HUSD_BindMaterial.h.

Enumeration of the material binding strength.

Enumerator
DEFAULT 
STRONG 
WEAK 

Definition at line 155 of file HUSD_BindMaterial.h.

Constructor & Destructor Documentation

HUSD_BindMaterial::HUSD_BindMaterial ( HUSD_AutoWriteLock lock)

Standard constructor.

Member Function Documentation

bool HUSD_BindMaterial::assignMaterialsFromAttribute ( const UT_StringRef layername,
const UT_StringMap< UT_StringHolder > &  args,
const UT_StringRef primpath,
bool  loadasreference,
const UT_StringRef refprimpath,
const UT_StringRef attrname,
bool  remove_attr,
bool  create_empty_materials,
const UT_StringRef reffileattrname,
const UT_StringRef refprimattrname 
) const

Looks for the specified attrname on any prims in the named layer. This string attribute is turned into an SdfPath that is bound as the material to the primitive with the attribute. If the attribute string points to a geometry primitive, we assign the material bound to that geometry primitive. Return false if the operation fails in an unrecoverable way. An error will have been added to the error scope to explain the failure. Warnings may also be generated for more minor issues such as invalid material paths. If create_empty_materials is enabled, the reffileattrname and refprimattrname can be used to optionally author a reference to a file (and reference prim within that file) rather than an empty material.

bool HUSD_BindMaterial::bind ( const UT_StringRef mat_prim_path,
const UT_StringRef geo_prim_path 
) const

Assigns the given material to the given geometry primitive(s).

bool HUSD_BindMaterial::bind ( const UT_StringRef mat_prim_path,
const HUSD_FindPrims find_geo_prims 
) const
bool HUSD_BindMaterial::bindSubset ( const UT_StringRef mat_prim_path,
const UT_StringRef geo_prim_path,
const UT_Array< exint > *  face_indices,
const HUSD_TimeCode tc = HUSD_TimeCode() 
) const

Assigns the given material to a subset of the geometry primitive. This method creates the geometry subset. If a geometry subset already exists, it can be bound using the regular bind methods above.

bool HUSD_BindMaterial::bindWithCollection ( const UT_StringRef mat_prim_path,
const HUSD_FindPrims include_geo_prims,
const HUSD_FindPrims exclude_geo_prims 
) const
bool HUSD_BindMaterial::bindWithPathExpression ( const UT_StringRef mat_prim_path,
const UT_StringRef path_expr 
) const
HUSD_Path HUSD_BindMaterial::createSubset ( const UT_StringRef subset_name,
const UT_StringRef geo_prim_path,
const UT_Array< exint > &  face_indices,
const HUSD_TimeCode tc = HUSD_TimeCode() 
) const

Creates a geometry subset for material binding, but does not actually bind any material to the prim.

bool HUSD_BindMaterial::getBindCollectionExpand ( ) const
inline

Definition at line 128 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getBindCollectionName ( ) const
inline

Definition at line 143 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getBindCollectionPrimPath ( ) const
inline

Definition at line 141 of file HUSD_BindMaterial.h.

bool HUSD_BindMaterial::getBindCollectionWarnUnspecifiedPrim ( ) const
inline

Definition at line 151 of file HUSD_BindMaterial.h.

BindMethod HUSD_BindMaterial::getBindMethod ( ) const
inline

Definition at line 122 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getPurpose ( ) const
inline

Definition at line 171 of file HUSD_BindMaterial.h.

Strength HUSD_BindMaterial::getStrength ( ) const
inline

Definition at line 165 of file HUSD_BindMaterial.h.

bool HUSD_BindMaterial::isPrimWithoutBoundMaterial ( const UT_StringRef prim_path,
const UT_Optional< UT_StringHolder > &  purpose = std::nullopt 
)

Returns true if the given path points to a primitive, and that primitive does not have any material bound to it.

void HUSD_BindMaterial::setBindCollectionExpand ( bool  expand)
inline

Sets the collection expansion option when defining collections.

Definition at line 126 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindCollectionInfo ( const UT_StringHolder primpath,
const UT_StringHolder collectionname 
)
inline

For collection-based bindings, sets the USD primitive path on which the collection-based binding is defined, and the collection name. If these are not supplied, we'll do a best guess for these values.

Definition at line 134 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindCollectionWarnUnspecifiedPrim ( bool  warn)
inline

Indicates whether a warning should be generated if we are asked to create a collection binding, but are not explicitly given a prim on which to author the binding (and we have to calculate one instead).

Definition at line 149 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindMethod ( BindMethod  method)
inline

Sets the method of defining bindings.

Definition at line 120 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setPurpose ( const UT_StringHolder purpose)
inline

Sets the purpose for material assignments.

Definition at line 169 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setStrength ( Strength  strength)
inline

Sets the strength preference for material assignments.

Definition at line 163 of file HUSD_BindMaterial.h.

bool HUSD_BindMaterial::unbind ( const HUSD_FindPrims find_prims,
const UT_StringHolder purpose,
int  unbind_limit = 1 
) const

Removes the material binding from the geometry primitive(s). The unbind_limit determines how many material bindings are blocked. The binding limit of 1 unassigns the currently bound material, allowing any other candidate moaterial to take over.

The binding limit of 2 unassigns the currently bound material (if any), and the second candidate material (if any), allowing the next candidate material to take effect.

bool HUSD_BindMaterial::unbindAll ( const HUSD_FindPrims find_prims) const

Makes sure the primitives are not bound to any material. I.e, if there is any direct material binding (on the given prim or its ancestor), authors a binding block on the given prim, and if there is any collection-based assignment on the prim or ancestor, removes the given prim from the collection.


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