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 #include "pxr/usd/usdShade/connectableAPIBehavior.h"
42 
43 #include "pxr/base/vt/value.h"
44 
45 #include "pxr/base/gf/vec3d.h"
46 #include "pxr/base/gf/vec3f.h"
47 #include "pxr/base/gf/matrix4d.h"
48 
49 #include "pxr/base/tf/token.h"
50 #include "pxr/base/tf/type.h"
51 
52 PXR_NAMESPACE_OPEN_SCOPE
53 
54 class SdfAssetPath;
55 
56 // -------------------------------------------------------------------------- //
57 // NODEGRAPH //
58 // -------------------------------------------------------------------------- //
59 
81 {
82 public:
87 
92  explicit UsdShadeNodeGraph(const UsdPrim& prim=UsdPrim())
93  : UsdTyped(prim)
94  {
95  }
96 
100  explicit UsdShadeNodeGraph(const UsdSchemaBase& schemaObj)
101  : UsdTyped(schemaObj)
102  {
103  }
104 
106  USDSHADE_API
107  virtual ~UsdShadeNodeGraph();
108 
112  USDSHADE_API
113  static const TfTokenVector &
114  GetSchemaAttributeNames(bool includeInherited=true);
115 
125  USDSHADE_API
126  static UsdShadeNodeGraph
127  Get(const UsdStagePtr &stage, const SdfPath &path);
128 
151  USDSHADE_API
152  static UsdShadeNodeGraph
153  Define(const UsdStagePtr &stage, const SdfPath &path);
154 
155 protected:
159  USDSHADE_API
160  UsdSchemaType _GetSchemaType() const override;
161 
162 private:
163  // needs to invoke _GetStaticTfType.
164  friend class UsdSchemaRegistry;
165  USDSHADE_API
166  static const TfType &_GetStaticTfType();
167 
168  static bool _IsTypedSchema();
169 
170  // override SchemaBase virtuals.
171  USDSHADE_API
172  const TfType &_GetTfType() const override;
173 
174 public:
175  // ===================================================================== //
176  // Feel free to add custom code below this line, it will be preserved by
177  // the code generator.
178  //
179  // Just remember to:
180  // - Close the class declaration with };
181  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
182  // - Close the include guard with #endif
183  // ===================================================================== //
184  // --(BEGIN CUSTOM CODE)--
185 
190  USDSHADE_API
191  UsdShadeNodeGraph(const UsdShadeConnectableAPI &connectable);
192 
202  USDSHADE_API
204 
210 
215  USDSHADE_API
216  UsdShadeOutput CreateOutput(const TfToken& name,
217  const SdfValueTypeName& typeName) const;
218 
221  USDSHADE_API
222  UsdShadeOutput GetOutput(const TfToken &name) const;
223 
226  USDSHADE_API
227  std::vector<UsdShadeOutput> GetOutputs() const;
228 
244  USDSHADE_API
246  const TfToken &outputName,
247  TfToken *sourceName,
248  UsdShadeAttributeType *sourceType) const;
249 
251 
284 
292  USDSHADE_API
293  UsdShadeInput CreateInput(const TfToken& name,
294  const SdfValueTypeName& typeName) const;
295 
298  USDSHADE_API
299  UsdShadeInput GetInput(const TfToken &name) const;
300 
304  USDSHADE_API
305  std::vector<UsdShadeInput> GetInputs() const;
306 
308 
309  // Provide custom hash and equality comparison function objects for
310  // UsdShadeNodeGraph until bug 143077 is resolved.
311 
314  inline size_t operator()(const UsdShadeNodeGraph &nodeGraph) const {
315  return hash_value(nodeGraph.GetPrim());
316  }
317  };
320  {
321  inline bool operator() (UsdShadeNodeGraph const& s1,
322  UsdShadeNodeGraph const& s2) const
323  {
324  return s1.GetPrim() == s2.GetPrim();
325  }
326  };
327 
328  // ---------------------------------------------------------------------- //
336 
341  USDSHADE_API
342  std::vector<UsdShadeInput> GetInterfaceInputs() const;
343 
346  typedef std::unordered_map<UsdShadeInput, std::vector<UsdShadeInput>,
348 
350  typedef std::unordered_map<UsdShadeNodeGraph,
355 
371  USDSHADE_API
373  bool computeTransitiveConsumers=false) const;
374 
376 
380  USDSHADE_API
381  bool
382  CanConnectOutputToSource(const UsdShadeOutput &output,
383  const UsdAttribute &source,
384  std::string *reason) override;
385  };
386 
387 };
388 
389 PXR_NAMESPACE_CLOSE_SCOPE
390 
391 #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
UsdShadeNodeGraph provides its own connectability behavior, to support nesting of node graphs...
Definition: nodeGraph.h:379
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:347
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
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
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:80
This class encapsulates a shader or node-graph input, which is a connectable attribute 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:87
std::unordered_map< UsdShadeNodeGraph, InterfaceInputConsumersMap, NodeGraphHasher, NodeGraphEqualFn > NodeGraphInputConsumersMap
Map of node-graphs to their associated input-consumers map.
Definition: nodeGraph.h:354
UsdShadeNodeGraph(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeGraph on UsdPrim prim .
Definition: nodeGraph.h:92
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:127
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
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:442
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:288
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:313
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:85
TfType represents a dynamic runtime type.
Definition: type.h:64
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeNodeGraph(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeGraph on the prim held by schemaObj .
Definition: nodeGraph.h:100
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: nodeGraph.h:86
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:45
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:319
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...
UsdShadeConnectableAPIBehavior defines the compatibilty and behavior UsdShadeConnectableAPIof when ap...
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