HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialNetworkInterface.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 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 #ifndef PXR_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
25 #define PXR_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/path.h"
29 #include "pxr/base/vt/value.h"
31 #include "pxr/base/tf/token.h"
32 
34 
35 /// \class HdMaterialNetworkInterface
36 ///
37 /// Abstract interface for querying and mutating a material network.
38 ///
39 /// This is useful for implementing matfilt functions which can be reused
40 /// by future scene index implementations.
41 ///
42 /// NOTE: Subclasses make no guarantee of thread-safety even for the const
43 /// accessors as they might make use of internal caching for optimization.
44 /// Should you want to read from a material from multiple threads, create
45 /// a thread-specific interface instance. The non-const methods should
46 /// never be considered thread-safe from multiple interface instances
47 /// backed from the same concrete data.
49 {
50 public:
51  virtual ~HdMaterialNetworkInterface() = default;
52 
53  virtual SdfPath GetMaterialPrimPath() const = 0;
54 
55  /// Returns the nearest enclosing model asset name, as described by
56  /// the model schema, or empty string if none is available.
57  virtual std::string GetModelAssetName() const = 0;
58 
59  virtual TfTokenVector GetNodeNames() const = 0;
60  virtual TfToken GetNodeType(const TfToken &nodeName) const = 0;
61 
62  /// Node type info is a collection of data related to the node type, often
63  /// used to determine the node type.
64  ///
65  /// For now, we only have getters for this, as we aren't really intending on
66  /// mutating this in any filter.
67  virtual TfTokenVector
68  GetNodeTypeInfoKeys(const TfToken& nodeName) const = 0;
69  virtual VtValue
70  GetNodeTypeInfoValue(const TfToken& nodeName, const TfToken& key) const = 0;
71 
73  const TfToken &nodeName) const = 0;
74 
76  const TfToken &nodeName,
77  const TfToken &paramName) const = 0;
78 
80  {
83  };
84 
86  const TfToken &nodeName,
87  const TfToken &paramName) const = 0;
88 
90  const TfToken &nodeName) const = 0;
91 
93  {
96  };
98 
100  const TfToken &nodeName,
101  const TfToken &inputName) const = 0;
102 
103  virtual void DeleteNode(const TfToken &nodeName) = 0;
104 
105  virtual void SetNodeType(
106  const TfToken &nodeName,
107  const TfToken &nodeType) = 0;
108 
109  virtual void SetNodeParameterValue(
110  const TfToken &nodeName,
111  const TfToken &paramName,
112  const VtValue &value) = 0;
113 
114  virtual void SetNodeParameterData(
115  const TfToken &nodeName,
116  const TfToken &paramName,
117  const NodeParamData &paramData) = 0;
118 
119  virtual void DeleteNodeParameter(
120  const TfToken &nodeName,
121  const TfToken &paramName) = 0;
122 
123  virtual void SetNodeInputConnection(
124  const TfToken &nodeName,
125  const TfToken &inputName,
126  const InputConnectionVector &connections) = 0;
127 
128  virtual void DeleteNodeInputConnection(
129  const TfToken &nodeName,
130  const TfToken &inputName) = 0;
131 
132  /// ------------------------------------------------------------------------
133  /// Terminal query & mutation
134  virtual TfTokenVector GetTerminalNames() const = 0;
135 
136  using InputConnectionResult = std::pair<bool, InputConnection>;
138  const TfToken &terminalName) const = 0;
139 
140  virtual void DeleteTerminal(
141  const TfToken &terminalName) = 0;
142 
143  virtual void SetTerminalConnection(
144  const TfToken &terminalName,
145  const InputConnection &connection) = 0;
146 };
147 
148 
150 
151 #endif // PXR_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
virtual std::string GetModelAssetName() const =0
virtual NodeParamData GetNodeParameterData(const TfToken &nodeName, const TfToken &paramName) const =0
virtual InputConnectionVector GetNodeInputConnection(const TfToken &nodeName, const TfToken &inputName) const =0
virtual TfTokenVector GetTerminalNames() const =0
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
virtual TfTokenVector GetNodeTypeInfoKeys(const TfToken &nodeName) const =0
virtual void DeleteNodeInputConnection(const TfToken &nodeName, const TfToken &inputName)=0
virtual void SetNodeParameterValue(const TfToken &nodeName, const TfToken &paramName, const VtValue &value)=0
virtual void SetNodeType(const TfToken &nodeName, const TfToken &nodeType)=0
virtual void SetTerminalConnection(const TfToken &terminalName, const InputConnection &connection)=0
virtual VtValue GetNodeTypeInfoValue(const TfToken &nodeName, const TfToken &key) const =0
Definition: token.h:87
virtual ~HdMaterialNetworkInterface()=default
virtual SdfPath GetMaterialPrimPath() const =0
virtual TfTokenVector GetNodeNames() const =0
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
Definition: path.h:290
virtual void SetNodeInputConnection(const TfToken &nodeName, const TfToken &inputName, const InputConnectionVector &connections)=0
virtual void SetNodeParameterData(const TfToken &nodeName, const TfToken &paramName, const NodeParamData &paramData)=0
virtual TfToken GetNodeType(const TfToken &nodeName) const =0
virtual void DeleteNode(const TfToken &nodeName)=0
virtual void DeleteNodeParameter(const TfToken &nodeName, const TfToken &paramName)=0
virtual TfTokenVector GetAuthoredNodeParameterNames(const TfToken &nodeName) const =0
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
virtual TfTokenVector GetNodeInputConnectionNames(const TfToken &nodeName) const =0
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual VtValue GetNodeParameterValue(const TfToken &nodeName, const TfToken &paramName) const =0
virtual void DeleteTerminal(const TfToken &terminalName)=0
Definition: core.h:1131
virtual InputConnectionResult GetTerminalConnection(const TfToken &terminalName) const =0
std::pair< bool, InputConnection > InputConnectionResult
Definition: value.h:164