All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nodeGraph.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 USDSHADE_GENERATED_NODEGRAPH_H
25 #define USDSHADE_GENERATED_NODEGRAPH_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 #include "pxr/usd/usd/typed.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include <utility>
36 #include "pxr/usd/usd/editTarget.h"
37 #include "pxr/usd/usd/relationship.h"
38 #include "pxr/usd/usdShade/input.h"
39 #include "pxr/usd/usdShade/output.h"
40 #include "pxr/usd/usdShade/shader.h"
41 
42 #include "pxr/base/vt/value.h"
43 
44 #include "pxr/base/gf/vec3d.h"
45 #include "pxr/base/gf/vec3f.h"
46 #include "pxr/base/gf/matrix4d.h"
47 
48 #include "pxr/base/tf/token.h"
49 #include "pxr/base/tf/type.h"
50 
51 PXR_NAMESPACE_OPEN_SCOPE
52 
53 class SdfAssetPath;
54 
55 // -------------------------------------------------------------------------- //
56 // NODEGRAPH //
57 // -------------------------------------------------------------------------- //
58 
80 {
81 public:
86 
91  explicit UsdShadeNodeGraph(const UsdPrim& prim=UsdPrim())
92  : UsdTyped(prim)
93  {
94  }
95 
99  explicit UsdShadeNodeGraph(const UsdSchemaBase& schemaObj)
100  : UsdTyped(schemaObj)
101  {
102  }
103 
105  USDSHADE_API
106  virtual ~UsdShadeNodeGraph();
107 
111  USDSHADE_API
112  static const TfTokenVector &
113  GetSchemaAttributeNames(bool includeInherited=true);
114 
124  USDSHADE_API
125  static UsdShadeNodeGraph
126  Get(const UsdStagePtr &stage, const SdfPath &path);
127 
150  USDSHADE_API
151  static UsdShadeNodeGraph
152  Define(const UsdStagePtr &stage, const SdfPath &path);
153 
154 protected:
158  USDSHADE_API
159  UsdSchemaType _GetSchemaType() const override;
160 
161 private:
162  // needs to invoke _GetStaticTfType.
163  friend class UsdSchemaRegistry;
164  USDSHADE_API
165  static const TfType &_GetStaticTfType();
166 
167  static bool _IsTypedSchema();
168 
169  // override SchemaBase virtuals.
170  USDSHADE_API
171  const TfType &_GetTfType() const override;
172 
173 public:
174  // ===================================================================== //
175  // Feel free to add custom code below this line, it will be preserved by
176  // the code generator.
177  //
178  // Just remember to:
179  // - Close the class declaration with };
180  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
181  // - Close the include guard with #endif
182  // ===================================================================== //
183  // --(BEGIN CUSTOM CODE)--
184 
189  USDSHADE_API
190  UsdShadeNodeGraph(const UsdShadeConnectableAPI &connectable);
191 
201  USDSHADE_API
203 
209 
214  USDSHADE_API
215  UsdShadeOutput CreateOutput(const TfToken& name,
216  const SdfValueTypeName& typeName) const;
217 
220  USDSHADE_API
221  UsdShadeOutput GetOutput(const TfToken &name) const;
222 
225  USDSHADE_API
226  std::vector<UsdShadeOutput> GetOutputs() const;
227 
243  USDSHADE_API
245  const TfToken &outputName,
246  TfToken *sourceName,
247  UsdShadeAttributeType *sourceType) const;
248 
250 
283 
291  USDSHADE_API
292  UsdShadeInput CreateInput(const TfToken& name,
293  const SdfValueTypeName& typeName) const;
294 
297  USDSHADE_API
298  UsdShadeInput GetInput(const TfToken &name) const;
299 
303  USDSHADE_API
304  std::vector<UsdShadeInput> GetInputs() const;
305 
307 
308  // Provide custom hash and equality comparison function objects for
309  // UsdShadeNodeGraph until bug 143077 is resolved.
310 
313  inline size_t operator()(const UsdShadeNodeGraph &nodeGraph) const {
314  return hash_value(nodeGraph.GetPrim());
315  }
316  };
319  {
320  inline bool operator() (UsdShadeNodeGraph const& s1,
321  UsdShadeNodeGraph const& s2) const
322  {
323  return s1.GetPrim() == s2.GetPrim();
324  }
325  };
326 
327  // ---------------------------------------------------------------------- //
335 
340  USDSHADE_API
341  std::vector<UsdShadeInput> GetInterfaceInputs() const;
342 
345  typedef std::unordered_map<UsdShadeInput, std::vector<UsdShadeInput>,
347 
349  typedef std::unordered_map<UsdShadeNodeGraph,
354 
374  USDSHADE_API
376  bool computeTransitiveConsumers=false) const;
377 
378 protected:
379 
380  // Befriend UsdRiLookAPI and UsdRiMaterialAPI temporarily to assist in the
381  // transition to the new shading encoding.
382  friend class UsdRiLookAPI;
383  friend class UsdRiMaterialAPI;
384 
392  USDSHADE_API
394  bool computeTransitiveConsumers,
395  const TfToken &renderTarget) const;
396 
397 
398 
406  USDSHADE_API
407  std::vector<UsdShadeInput> _GetInterfaceInputs(const TfToken &renderTarget)
408  const;
409 
411 
412 };
413 
414 PXR_NAMESPACE_CLOSE_SCOPE
415 
416 #endif
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an Input which can either have a value or can be connected.
Hash functor.
Definition: input.h:106
std::unordered_map< UsdShadeInput, std::vector< UsdShadeInput >, UsdShadeInput::Hash > InterfaceInputConsumersMap
Map of interface inputs to corresponding vectors of inputs that consume their values.
Definition: nodeGraph.h:346
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs() const
Outputs are represented by attributes in the &quot;outputs:&quot; namespace.
Represents a value type name, i.e.
Definition: valueTypeName.h:83
Represents a concrete typed schema.
USDSHADE_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
A node-graph is a container for shading nodes, as well as other node-graphs.
Definition: nodeGraph.h:79
This class encapsulates a shader or node-graph input, which is a connectable property representing a ...
Definition: input.h:46
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output which can either have a value or can be connected.
virtual USDSHADE_API ~UsdShadeNodeGraph()
Destructor.
static USDSHADE_API UsdShadeNodeGraph Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeNodeGraph holding the prim adhering to this schema at path on stage.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
std::unordered_map< UsdShadeNodeGraph, InterfaceInputConsumersMap, NodeGraphHasher, NodeGraphEqualFn > NodeGraphInputConsumersMap
Map of node-graphs to their associated input-consumers map.
Definition: nodeGraph.h:353
UsdShadeNodeGraph(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeGraph on UsdPrim prim .
Definition: nodeGraph.h:91
USDSHADE_API InterfaceInputConsumersMap _ComputeInterfaceInputConsumersMap(bool computeTransitiveConsumers, const TfToken &renderTarget) const
UsdShadeConnectableAPI is an API schema that provides a common interface for creating outputs and mak...
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:149
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
The base class for all typed schemas (those that can impart a typeName to a UsdPrim), and therefore the base class for all instantiable and &quot;IsA&quot; schemas.
Definition: typed.h:47
USDSHADE_API UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
USDSHADE_API InterfaceInputConsumersMap ComputeInterfaceInputConsumersMap(bool computeTransitiveConsumers=false) const
Walks the namespace subtree below the node-graph and computes a map containing the list of all inputs...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
USDSHADE_API UsdShadeConnectableAPI ConnectableAPI() const
Contructs and returns a UsdShadeConnectableAPI object with this node-graph.
static USDSHADE_API UsdShadeNodeGraph Define(const UsdStagePtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefin...
Hash functor for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:312
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
static USDSHADE_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
Base class for all USD shaders.
Definition: shader.h:89
TfType represents a dynamic runtime type.
Definition: type.h:70
Singleton registry that provides access to prim and property definition information for registered Us...
UsdShadeNodeGraph(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeGraph on the prim held by schemaObj .
Definition: nodeGraph.h:99
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: nodeGraph.h:85
USDSHADE_API std::vector< UsdShadeInput > _GetInterfaceInputs(const TfToken &renderTarget) const
This class encapsulates a shader or node-graph output, which is a connectable property representing a...
Definition: output.h:47
The base class for all schema types in Usd.
Definition: schemaBase.h:56
USDSHADE_API std::vector< UsdShadeInput > GetInterfaceInputs() const
Returns all the &quot;Interface Inputs&quot; of the node-graph.
Equality comparator for UsdShadeNodeGraph objects.
Definition: nodeGraph.h:318
This API provides outputs that connect a material prim to prman shaders and RIS objects.
Definition: materialAPI.h:68
USDSHADE_API UsdShadeShader ComputeOutputSource(const TfToken &outputName, TfToken *sourceName, UsdShadeAttributeType *sourceType) const
Resolves the connection source of the requested output, identified by outputName to a shader output...
USDSHADE_API std::vector< UsdShadeInput > GetInputs() const
Returns all inputs present on the node-graph.
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119