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 bindAsCollection (const UT_StringRef &mat_prim_path, const UT_StringRef &collection_path, const UT_StringRef &binding_prim_path, const UT_StringRef &binding_name) 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 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, const UT_StringRef &refprimpath, const UT_StringRef &attrname, bool remove_attr, bool create_empty_materials) 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 setBindPrimPath (const UT_StringRef &p)
 
const UT_StringHoldergetBindPrimPath () const
 
void setBindName (const UT_StringRef &n)
 
const UT_StringHoldergetBindName () 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 31 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 104 of file HUSD_BindMaterial.h.

Enumeration of the material binding strength.

Enumerator
DEFAULT 
STRONG 
WEAK 

Definition at line 137 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,
const UT_StringRef refprimpath,
const UT_StringRef attrname,
bool  remove_attr,
bool  create_empty_materials 
) 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.

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::bindAsCollection ( const UT_StringRef mat_prim_path,
const UT_StringRef collection_path,
const UT_StringRef binding_prim_path,
const UT_StringRef binding_name 
) const

Performs a collection based binding with explicit values for the collection path, binding prim path, and binding name. The bind method and bind prim path set on this object are ignored.

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.

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 119 of file HUSD_BindMaterial.h.

BindMethod HUSD_BindMaterial::getBindMethod ( ) const
inline

Definition at line 113 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getBindName ( ) const
inline

Definition at line 133 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getBindPrimPath ( ) const
inline

Definition at line 126 of file HUSD_BindMaterial.h.

const UT_StringHolder& HUSD_BindMaterial::getPurpose ( ) const
inline

Definition at line 153 of file HUSD_BindMaterial.h.

Strength HUSD_BindMaterial::getStrength ( ) const
inline

Definition at line 147 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindCollectionExpand ( bool  expand)
inline

Sets the collection expansion option when defining collections.

Definition at line 117 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindMethod ( BindMethod  method)
inline

Sets the method of defining bindings.

Definition at line 111 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindName ( const UT_StringRef n)
inline

For collection-based bindings, sets the USD binding name. (If not set explicitly, the material name will be used).

Definition at line 131 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setBindPrimPath ( const UT_StringRef p)
inline

For collection-based bindings, sets the USD primitive path on which the collection-based binding is defined.

Definition at line 124 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setPurpose ( const UT_StringHolder purpose)
inline

Sets the purpose for material assignments.

Definition at line 151 of file HUSD_BindMaterial.h.

void HUSD_BindMaterial::setStrength ( Strength  strength)
inline

Sets the strength preference for material assignments.

Definition at line 145 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: