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 GetNodeTypeInfoKeys(const TfToken& nodeName) const override;
64 
65  HD_API
66  VtValue GetNodeTypeInfoValue(
67  const TfToken& nodeName, const TfToken& key) const override;
68 
69  HD_API
70  TfTokenVector GetAuthoredNodeParameterNames(
71  const TfToken &nodeName) const override;
72 
73  HD_API
74  VtValue GetNodeParameterValue(
75  const TfToken &nodeName,
76  const TfToken &paramName) const override;
77 
78  HD_API
79  TfTokenVector GetNodeInputConnectionNames(
80  const TfToken &nodeName) const override;
81 
82  HD_API
83  InputConnectionVector GetNodeInputConnection(
84  const TfToken &nodeName,
85  const TfToken &inputName) const override;
86 
87  HD_API
88  void DeleteNode(const TfToken &nodeName) override;
89 
90  HD_API
91  void SetNodeType(
92  const TfToken &nodeName,
93  const TfToken &nodeType) override;
94 
95  HD_API
96  void SetNodeParameterValue(
97  const TfToken &nodeName,
98  const TfToken &paramName,
99  const VtValue &value) override;
100 
101  HD_API
102  void DeleteNodeParameter(
103  const TfToken &nodeName,
104  const TfToken &paramName) override;
105 
106  HD_API
107  void SetNodeInputConnection(
108  const TfToken &nodeName,
109  const TfToken &inputName,
110  const InputConnectionVector &connections) override;
111 
112  HD_API
113  void DeleteNodeInputConnection(
114  const TfToken &nodeName,
115  const TfToken &inputName) override;
116 
117  HD_API
118  TfTokenVector GetTerminalNames() const override;
119 
120  HD_API
121  InputConnectionResult GetTerminalConnection(
122  const TfToken &terminalName) const override;
123 
124  HD_API
125  void DeleteTerminal(const TfToken &terminalName) override;
126 
127  HD_API
128  void SetTerminalConnection(
129  const TfToken &terminalName,
130  const InputConnection &connection) override;
131 
132 private:
133  SdfPath _materialPrimPath;
134  HdMaterialNetwork2 *_materialNetwork;
135  mutable TfToken _lastAccessedNodeName;
136  mutable HdMaterialNode2 *_lastAccessedNode;
137 
138  HdMaterialNode2 *_GetNode(const TfToken &nodeName) const;
139  HdMaterialNode2 *_GetOrCreateNode(const TfToken &nodeName) const;
140 
141 };
142 
143 
144 
145 PXR_NAMESPACE_CLOSE_SCOPE
146 
147 #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
HD_API TfTokenVector GetNodeTypeInfoKeys(const TfToken &nodeName) const override
Node type info is a collection of data related to the node type, often used to determine the node typ...
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