Loading...
Searching...
No Matches
utils.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_USDMTLX_UTILS_H
9#define PXR_USD_USDMTLX_UTILS_H
10
11#include "pxr/pxr.h"
12#include "pxr/usd/usdMtlx/api.h"
13#include "pxr/usd/ndr/declare.h"
14#include "pxr/usd/sdf/valueTypeName.h"
16#include "pxr/base/vt/value.h"
17#include <MaterialXCore/Document.h>
18#include <string>
19#include <vector>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23#define USD_MTLX_TOKENS \
24 ((DefaultOutputName, "out"))
25
26TF_DECLARE_PUBLIC_TOKENS(UsdMtlxTokens, USDMTLX_API, USD_MTLX_TOKENS);
27
31USDMTLX_API
32const NdrStringVec&
33UsdMtlxStandardLibraryPaths();
34
37USDMTLX_API
38const NdrStringVec&
39UsdMtlxCustomSearchPaths();
40
46USDMTLX_API
47const NdrStringVec&
48UsdMtlxSearchPaths();
49
51USDMTLX_API
52NdrStringVec
53UsdMtlxStandardFileExtensions();
54
60USDMTLX_API
61MaterialX::DocumentPtr
62UsdMtlxReadDocument(const std::string& resolvedPath);
63
68USDMTLX_API
69MaterialX::ConstDocumentPtr
70UsdMtlxGetDocument(const std::string& resolvedUri);
71
74USDMTLX_API
75MaterialX::ConstDocumentPtr
76UsdMtlxGetDocumentFromString(const std::string &mtlxXml);
77
78// Return the version of the mtlx element. If the version cannot be
79// found then return an invalid default version. If implicitDefault
80// isn't null then we do to two things: we set implicitDefault to
81// false iff the isdefaultversion attribute exists and isn't empty,
82// otherwise we set it to true; and we return the version as a
83// default if isdefaultversion exists and is set to "true".
84USDMTLX_API
85NdrVersion
86UsdMtlxGetVersion(const MaterialX::ConstInterfaceElementPtr& mtlx,
87 bool* implicitDefault = nullptr);
88
93USDMTLX_API
94const std::string&
95UsdMtlxGetSourceURI(const MaterialX::ConstElementPtr& element);
96
103 int arraySize=0)
108 { }
109
114
118
122
126};
127
129USDMTLX_API
131UsdMtlxGetUsdType(const std::string& mtlxTypeName);
132
138USDMTLX_API
140UsdMtlxGetUsdValue(const MaterialX::ConstElementPtr& mtlx,
141 bool getDefaultValue = false);
142
145USDMTLX_API
146std::vector<VtValue>
147UsdMtlxGetPackedUsdValues(const std::string& values, const std::string& type);
148
158USDMTLX_API
159std::vector<std::string>
160UsdMtlxSplitStringArray(const std::string& s);
161
162PXR_NAMESPACE_CLOSE_SCOPE
163
164#endif // PXR_USD_USDMTLX_UTILS_H
Represents a value type name, i.e.
Definition: valueTypeName.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81
Result of UsdMtlxGetUsdType().
Definition: utils.h:98
TfToken shaderPropertyType
The exact SdrShaderProperty type name.
Definition: utils.h:117
int arraySize
If the value type is a fixed-size array/tuple, this will be greater then zero.
Definition: utils.h:121
bool valueTypeNameIsExact
true iff the value type name is an exact match to the MaterialX type.
Definition: utils.h:125
SdfValueTypeName valueTypeName
The value type name that most closely matches the MaterialX type.
Definition: utils.h:113
Common typedefs that are used throughout the NDR library.