Loading...
Searching...
No Matches
utils.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24
25#ifndef PXR_USD_USDMTLX_UTILS_H
26#define PXR_USD_USDMTLX_UTILS_H
27
28#include "pxr/pxr.h"
29#include "pxr/usd/usdMtlx/api.h"
30#include "pxr/usd/ndr/declare.h"
31#include "pxr/usd/sdf/valueTypeName.h"
33#include "pxr/base/vt/value.h"
34#include <MaterialXCore/Document.h>
35#include <string>
36#include <vector>
37
38PXR_NAMESPACE_OPEN_SCOPE
39
40#define USD_MTLX_TOKENS \
41 ((DefaultOutputName, "out"))
42
43TF_DECLARE_PUBLIC_TOKENS(UsdMtlxTokens, USDMTLX_API, USD_MTLX_TOKENS);
44
48USDMTLX_API
49const NdrStringVec&
50UsdMtlxStandardLibraryPaths();
51
54USDMTLX_API
55const NdrStringVec&
56UsdMtlxCustomSearchPaths();
57
63USDMTLX_API
64const NdrStringVec&
65UsdMtlxSearchPaths();
66
68USDMTLX_API
69NdrStringVec
70UsdMtlxStandardFileExtensions();
71
77USDMTLX_API
78MaterialX::DocumentPtr
79UsdMtlxReadDocument(const std::string& resolvedPath);
80
85USDMTLX_API
86MaterialX::ConstDocumentPtr
87UsdMtlxGetDocument(const std::string& resolvedUri);
88
91USDMTLX_API
92MaterialX::ConstDocumentPtr
93UsdMtlxGetDocumentFromString(const std::string &mtlxXml);
94
95// Return the version of the mtlx element. If the version cannot be
96// found then return an invalid default version. If implicitDefault
97// isn't null then we do to two things: we set implicitDefault to
98// false iff the isdefaultversion attribute exists and isn't empty,
99// otherwise we set it to true; and we return the version as a
100// default if isdefaultversion exists and is set to "true".
101USDMTLX_API
102NdrVersion
103UsdMtlxGetVersion(const MaterialX::ConstInterfaceElementPtr& mtlx,
104 bool* implicitDefault = nullptr);
105
110USDMTLX_API
111const std::string&
112UsdMtlxGetSourceURI(const MaterialX::ConstElementPtr& element);
113
120 int arraySize=0)
125 { }
126
131
135
139
143};
144
146USDMTLX_API
148UsdMtlxGetUsdType(const std::string& mtlxTypeName);
149
155USDMTLX_API
157UsdMtlxGetUsdValue(const MaterialX::ConstElementPtr& mtlx,
158 bool getDefaultValue = false);
159
162USDMTLX_API
163std::vector<VtValue>
164UsdMtlxGetPackedUsdValues(const std::string& values, const std::string& type);
165
175USDMTLX_API
176std::vector<std::string>
177UsdMtlxSplitStringArray(const std::string& s);
178
179PXR_NAMESPACE_CLOSE_SCOPE
180
181#endif // PXR_USD_USDMTLX_UTILS_H
Represents a value type name, i.e.
Definition: valueTypeName.h:88
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
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:98
Result of UsdMtlxGetUsdType().
Definition: utils.h:115
TfToken shaderPropertyType
The exact SdrShaderProperty type name.
Definition: utils.h:134
int arraySize
If the value type is a fixed-size array/tuple, this will be greater then zero.
Definition: utils.h:138
bool valueTypeNameIsExact
true iff the value type name is an exact match to the MaterialX type.
Definition: utils.h:142
SdfValueTypeName valueTypeName
The value type name that most closely matches the MaterialX type.
Definition: utils.h:130
Common typedefs that are used throughout the NDR library.