materialNetwork2Interface.h
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 HD_MATERIAL_NETWORK_2_INTERFACE_H
25 #define HD_MATERIAL_NETWORK_2_INTERFACE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/material.h"
30 #include "pxr/imaging/hd/materialNetworkInterface.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
41 {
42 public:
43 
45  const SdfPath &materialPrimPath,
46  HdMaterialNetwork2 *materialNetwork)
47  : _materialPrimPath(materialPrimPath)
48  , _materialNetwork(materialNetwork)
49  , _lastAccessedNode(nullptr)
50  {}
51 
52  SdfPath GetMaterialPrimPath() const override {
53  return _materialPrimPath;
54  }
55 
56  HD_API
57  TfTokenVector GetNodeNames() const override;
58 
59  HD_API
60  TfToken GetNodeType(const TfToken &nodeName) const override;
61 
62  HD_API
63  TfTokenVector GetAuthoredNodeParameterNames(
64  const TfToken &nodeName) const override;
65 
66  HD_API
67  VtValue GetNodeParameterValue(
68  const TfToken &nodeName,
69  const TfToken &paramName) const override;
70 
71  HD_API
72  TfTokenVector GetNodeInputConnectionNames(
73  const TfToken &nodeName) const override;
74 
75  HD_API
76  InputConnectionVector GetNodeInputConnection(
77  const TfToken &nodeName,
78  const TfToken &inputName) const override;
79 
80  HD_API
81  void DeleteNode(const TfToken &nodeName) override;
82 
83  HD_API
84  void SetNodeType(
85  const TfToken &nodeName,
86  const TfToken &nodeType) override;
87 
88  HD_API
89  void SetNodeParameterValue(
90  const TfToken &nodeName,
91  const TfToken &paramName,
92  const VtValue &value) override;
93 
94  HD_API
95  void DeleteNodeParameter(
96  const TfToken &nodeName,
97  const TfToken &paramName) override;
98 
99  HD_API
100  void SetNodeInputConnection(
101  const TfToken &nodeName,
102  const TfToken &inputName,
103  const InputConnectionVector &connections) override;
104 
105  HD_API
106  void DeleteNodeInputConnection(
107  const TfToken &nodeName,
108  const TfToken &inputName) override;
109 
110  HD_API
111  TfTokenVector GetTerminalNames() const override;
112 
113  HD_API
114  InputConnectionResult GetTerminalConnection(
115  const TfToken &terminalName) const override;
116 
117  HD_API
118  void DeleteTerminal(const TfToken &terminalName) override;
119 
120  HD_API
121  void SetTerminalConnection(
122  const TfToken &terminalName,
123  const InputConnection &connection) override;
124 
125 private:
126  SdfPath _materialPrimPath;
127  HdMaterialNetwork2 *_materialNetwork;
128  mutable TfToken _lastAccessedNodeName;
129  mutable HdMaterialNode2 *_lastAccessedNode;
130 
131  HdMaterialNode2 *_GetNode(const TfToken &nodeName) const;
132  HdMaterialNode2 *_GetOrCreateNode(const TfToken &nodeName) const;
133 
134 };
135 
136 
137 
138 PXR_NAMESPACE_CLOSE_SCOPE
139 
140 #endif //HD_MATERIAL_NETWORK_2_INTERFACE_H
Abstract interface for querying and mutating a material network.
This is a small-vector class with local storage optimization, the local storage can be specified via ...
Definition: smallVector.h:177
HD_API TfTokenVector GetTerminalNames() const override
Implements HdMaterialNetworkInterface interface backed by an HdMaterialNetwork2 – which is useful for...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Describes an instance of a node within a network A node contains a (shader) type identifier,...
Definition: material.h:163
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Container of nodes and top-level terminal connections.
Definition: material.h:175
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166