HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.h File Reference
#include "pxr/pxr.h"
#include "pxr/usd/usdMtlx/api.h"
#include "pxr/usd/ndr/declare.h"
#include "pxr/usd/sdf/valueTypeName.h"
#include "pxr/base/tf/staticTokens.h"
#include "pxr/base/vt/value.h"
#include <MaterialXCore/Document.h>
#include <string>
#include <vector>
+ Include dependency graph for utils.h:

Go to the source code of this file.

Classes

struct  UsdMtlxUsdTypeInfo
 Result of UsdMtlxGetUsdType(). More...
 

Macros

#define USD_MTLX_TOKENS   ((DefaultOutputName, "out"))
 

Functions

 TF_DECLARE_PUBLIC_TOKENS (UsdMtlxTokens, USDMTLX_API, USD_MTLX_TOKENS)
 
USDMTLX_API const NdrStringVecUsdMtlxStandardLibraryPaths ()
 
USDMTLX_API const NdrStringVecUsdMtlxCustomSearchPaths ()
 
USDMTLX_API const NdrStringVecUsdMtlxSearchPaths ()
 
USDMTLX_API NdrStringVec UsdMtlxStandardFileExtensions ()
 Return the MaterialX standard file extensions. More...
 
USDMTLX_API MaterialX::DocumentPtr UsdMtlxReadDocument (const std::string &resolvedPath)
 
USDMTLX_API
MaterialX::ConstDocumentPtr 
UsdMtlxGetDocument (const std::string &resolvedUri)
 
USDMTLX_API
MaterialX::ConstDocumentPtr 
UsdMtlxGetDocumentFromString (const std::string &mtlxXml)
 
USDMTLX_API NdrVersion UsdMtlxGetVersion (const MaterialX::ConstInterfaceElementPtr &mtlx, bool *implicitDefault=nullptr)
 
USDMTLX_API const std::stringUsdMtlxGetSourceURI (const MaterialX::ConstElementPtr &element)
 
USDMTLX_API UsdMtlxUsdTypeInfo UsdMtlxGetUsdType (const std::string &mtlxTypeName)
 Convert a (standard) MaterialX type name. More...
 
USDMTLX_API VtValue UsdMtlxGetUsdValue (const MaterialX::ConstElementPtr &mtlx, bool getDefaultValue=false)
 
USDMTLX_API std::vector< VtValueUsdMtlxGetPackedUsdValues (const std::string &values, const std::string &type)
 
USDMTLX_API std::vector
< std::string
UsdMtlxSplitStringArray (const std::string &s)
 

Macro Definition Documentation

#define USD_MTLX_TOKENS   ((DefaultOutputName, "out"))

Definition at line 40 of file utils.h.

Function Documentation

TF_DECLARE_PUBLIC_TOKENS ( UsdMtlxTokens  ,
USDMTLX_API  ,
USD_MTLX_TOKENS   
)
USDMTLX_API const NdrStringVec& UsdMtlxCustomSearchPaths ( )

Return the paths to directories containing custom MaterialX files, set in the environment variable 'PXR_MTLX_PLUGIN_SEARCH_PATHS'

USDMTLX_API MaterialX::ConstDocumentPtr UsdMtlxGetDocument ( const std::string resolvedUri)

Return the (possibly cached) MaterialX document at resolvedUri. Return null if the document could not be read and report a warning (once per uri). resolvedUri may be empty to indicate the MaterialX standard library documents all rolled into one.

USDMTLX_API MaterialX::ConstDocumentPtr UsdMtlxGetDocumentFromString ( const std::string mtlxXml)

Returns the (possibly cached) MaterialX document created from the given string containing the source MaterialX XML.

USDMTLX_API std::vector<VtValue> UsdMtlxGetPackedUsdValues ( const std::string values,
const std::string type 
)

Return the MaterialX values in values assuming it contains an array of values of MaterialX type type as a vector of VtValue.

USDMTLX_API const std::string& UsdMtlxGetSourceURI ( const MaterialX::ConstElementPtr element)

Return the source URI for a MaterialX element. If the element doesn't have a non-empty URI then return the source URI of the closest element up the element hierarchy that does have one. Return the empty string if no element has a source URI.

USDMTLX_API UsdMtlxUsdTypeInfo UsdMtlxGetUsdType ( const std::string mtlxTypeName)

Convert a (standard) MaterialX type name.

USDMTLX_API VtValue UsdMtlxGetUsdValue ( const MaterialX::ConstElementPtr mtlx,
bool  getDefaultValue = false 
)

Return the value in mtlx as a VtValue. Returns an empty VtValue and reports an error if the conversion cannot be applied. If getDefaultValue is true then converts the default value. It is not an error if the value doesn't exist; that silently returns an empty VtValue.

USDMTLX_API NdrVersion UsdMtlxGetVersion ( const MaterialX::ConstInterfaceElementPtr mtlx,
bool *  implicitDefault = nullptr 
)
USDMTLX_API MaterialX::DocumentPtr UsdMtlxReadDocument ( const std::string resolvedPath)

Return the MaterialX document at resolvedPath. Return null if the document could not be read and report a runtime error.

Unlike UsdMtlxGetDocument, this function does not implement any caching or special behavior for MaterialX standard library documents.

USDMTLX_API const NdrStringVec& UsdMtlxSearchPaths ( )

Return the MaterialX search paths. In order, this includes:

  • directories containing custom MaterialX files set in the env var 'PXR_MTLX_PLUGIN_SEARCH_PATHS'
  • standard library paths set in the env var 'PXR_MTLX_STDLIB_SEARCH_PATHS'
  • path to the MaterialX standard library discovered at build time.
USDMTLX_API std::vector<std::string> UsdMtlxSplitStringArray ( const std::string s)

Split a MaterialX string array into a vector of strings.

The MaterialX specification says:

Individual string values within stringarrays may not contain commas or semicolons, and any leading and trailing whitespace characters in them is ignored.

These restrictions do not apply to the string type.

USDMTLX_API NdrStringVec UsdMtlxStandardFileExtensions ( )

Return the MaterialX standard file extensions.

USDMTLX_API const NdrStringVec& UsdMtlxStandardLibraryPaths ( )

Return the MaterialX standard library paths. All standard library files (and only standard library files) should be found on these paths.