All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
connectableAPI.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_CONNECTABLEAPI_H
25 #define USDSHADE_GENERATED_CONNECTABLEAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 #include "pxr/usd/usd/apiSchemaBase.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 
35 #include "pxr/usd/usdShade/shader.h"
36 #include "pxr/usd/usdShade/nodeGraph.h"
37 
38 
39 #include "pxr/base/vt/value.h"
40 
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/matrix4d.h"
44 
45 #include "pxr/base/tf/token.h"
46 #include "pxr/base/tf/type.h"
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 class SdfAssetPath;
51 
52 // -------------------------------------------------------------------------- //
53 // CONNECTABLEAPI //
54 // -------------------------------------------------------------------------- //
55 
80 {
81 public:
86 
91  explicit UsdShadeConnectableAPI(const UsdPrim& prim=UsdPrim())
92  : UsdAPISchemaBase(prim)
93  {
94  }
95 
99  explicit UsdShadeConnectableAPI(const UsdSchemaBase& schemaObj)
100  : UsdAPISchemaBase(schemaObj)
101  {
102  }
103 
105  USDSHADE_API
106  virtual ~UsdShadeConnectableAPI();
107 
111  USDSHADE_API
112  static const TfTokenVector &
113  GetSchemaAttributeNames(bool includeInherited=true);
114 
124  USDSHADE_API
126  Get(const UsdStagePtr &stage, const SdfPath &path);
127 
128 
129 protected:
133  USDSHADE_API
134  UsdSchemaType _GetSchemaType() const override;
135 
136 private:
137  // needs to invoke _GetStaticTfType.
138  friend class UsdSchemaRegistry;
139  USDSHADE_API
140  static const TfType &_GetStaticTfType();
141 
142  static bool _IsTypedSchema();
143 
144  // override SchemaBase virtuals.
145  USDSHADE_API
146  const TfType &_GetTfType() const override;
147 
148 public:
149  // ===================================================================== //
150  // Feel free to add custom code below this line, it will be preserved by
151  // the code generator.
152  //
153  // Just remember to:
154  // - Close the class declaration with };
155  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
156  // - Close the include guard with #endif
157  // ===================================================================== //
158  // --(BEGIN CUSTOM CODE)--
159 
160 protected:
163  USDSHADE_API
164  bool _IsCompatible() const override;
165 
166 public:
167 
174  { }
175 
181  UsdShadeConnectableAPI(nodeGraph.GetPrim())
182  { }
183 
185  USDSHADE_API
186  bool IsShader() const;
187 
189  USDSHADE_API
190  bool IsNodeGraph() const;
191 
199 
208  USDSHADE_API
209  static bool CanConnect(const UsdShadeInput &input,
210  const UsdAttribute &source);
211 
213  USDSHADE_API
214  static bool CanConnect(const UsdShadeInput &input,
215  const UsdShadeInput &sourceInput) {
216  return CanConnect(input, sourceInput.GetAttr());
217  }
218 
220  USDSHADE_API
221  static bool CanConnect(const UsdShadeInput &input,
222  const UsdShadeOutput &sourceOutput) {
223  return CanConnect(input, sourceOutput.GetAttr());
224  }
225 
236  USDSHADE_API
237  static bool CanConnect(const UsdShadeOutput &output,
238  const UsdAttribute &source=UsdAttribute());
239 
241  USDSHADE_API
242  static bool CanConnect(const UsdShadeOutput &output,
243  const UsdShadeInput &sourceInput) {
244  return CanConnect(output, sourceInput.GetAttr());
245  }
246 
248  USDSHADE_API
249  static bool CanConnect(const UsdShadeOutput &output,
250  const UsdShadeOutput &sourceOutput) {
251  return CanConnect(output, sourceOutput.GetAttr());
252  }
253 
281  USDSHADE_API
282  static bool ConnectToSource(
283  UsdProperty const &shadingProp,
284  UsdShadeConnectableAPI const &source,
285  TfToken const &sourceName,
286  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
288 
290  USDSHADE_API
291  static bool ConnectToSource(
292  UsdShadeInput const &input,
293  UsdShadeConnectableAPI const &source,
294  TfToken const &sourceName,
295  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
297  {
298  return ConnectToSource(input.GetAttr(), source, sourceName, sourceType,
299  typeName);
300  }
301 
303  USDSHADE_API
304  static bool ConnectToSource(
305  UsdShadeOutput const &output,
306  UsdShadeConnectableAPI const &source,
307  TfToken const &sourceName,
308  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
310  {
311  return ConnectToSource(output.GetProperty(), source, sourceName, sourceType,
312  typeName);
313  }
314 
324  USDSHADE_API
325  static bool ConnectToSource(UsdProperty const &shadingProp,
326  SdfPath const &sourcePath);
327 
329  USDSHADE_API
330  static bool ConnectToSource(UsdShadeInput const &input,
331  SdfPath const &sourcePath) {
332  return ConnectToSource(input.GetAttr(), sourcePath);
333  }
334 
336  USDSHADE_API
337  static bool ConnectToSource(UsdShadeOutput const &output,
338  SdfPath const &sourcePath) {
339  return ConnectToSource(output.GetProperty(), sourcePath);
340  }
341 
346  USDSHADE_API
347  static bool ConnectToSource(UsdProperty const &shadingProp,
348  UsdShadeInput const &sourceInput);
349 
351  USDSHADE_API
352  static bool ConnectToSource(UsdShadeInput const &input,
353  UsdShadeInput const &sourceInput) {
354  return ConnectToSource(input.GetAttr(), sourceInput);
355  }
356 
358  USDSHADE_API
359  static bool ConnectToSource(UsdShadeOutput const &output,
360  UsdShadeInput const &sourceInput) {
361  return ConnectToSource(output.GetProperty(), sourceInput);
362  }
363 
368  USDSHADE_API
369  static bool ConnectToSource(UsdProperty const &shadingProp,
370  UsdShadeOutput const &sourceOutput);
371 
373  USDSHADE_API
374  static bool ConnectToSource(UsdShadeInput const &input,
375  UsdShadeOutput const &sourceOutput) {
376  return ConnectToSource(input.GetAttr(), sourceOutput);
377  }
378 
380  USDSHADE_API
381  static bool ConnectToSource(UsdShadeOutput const &output,
382  UsdShadeOutput const &sourceOutput) {
383  return ConnectToSource(output.GetProperty(), sourceOutput);
384  }
385 
386 
408  USDSHADE_API
409  static bool GetConnectedSource(UsdProperty const &shadingProp,
410  UsdShadeConnectableAPI *source,
411  TfToken *sourceName,
412  UsdShadeAttributeType *sourceType);
413 
415  USDSHADE_API
416  static bool GetConnectedSource(UsdShadeInput const &input,
417  UsdShadeConnectableAPI *source,
418  TfToken *sourceName,
419  UsdShadeAttributeType *sourceType) {
420  return GetConnectedSource(input.GetAttr(), source, sourceName,
421  sourceType);
422  }
423 
425  USDSHADE_API
426  static bool GetConnectedSource(UsdShadeOutput const &output,
427  UsdShadeConnectableAPI *source,
428  TfToken *sourceName,
429  UsdShadeAttributeType *sourceType) {
430  return GetConnectedSource(output.GetProperty(), source, sourceName,
431  sourceType);
432  }
433 
437  USDSHADE_API
438  static bool GetRawConnectedSourcePaths(UsdProperty const &shadingProp,
439  SdfPathVector *sourcePaths);
440 
442  USDSHADE_API
443  static bool GetRawConnectedSourcePaths(UsdShadeInput const &input,
444  SdfPathVector *sourcePaths) {
445  return GetRawConnectedSourcePaths(input.GetAttr(), sourcePaths);
446  }
447 
449  USDSHADE_API
450  static bool GetRawConnectedSourcePaths(UsdShadeOutput const &output,
451  SdfPathVector *sourcePaths) {
452  return GetRawConnectedSourcePaths(output.GetProperty(), sourcePaths);
453  }
454 
468  USDSHADE_API
469  static bool HasConnectedSource(const UsdProperty &shadingProp);
470 
472  USDSHADE_API
473  static bool HasConnectedSource(const UsdShadeInput &input) {
474  return HasConnectedSource(input.GetAttr());
475  }
476 
478  USDSHADE_API
479  static bool HasConnectedSource(const UsdShadeOutput &output) {
480  return HasConnectedSource(output.GetProperty());
481  }
482 
487  USDSHADE_API
489  const UsdProperty &shadingProp);
490 
492  USDSHADE_API
495  }
496 
498  USDSHADE_API
500  {
502  }
503 
514  USDSHADE_API
515  static bool DisconnectSource(UsdProperty const &shadingProp);
516 
518  USDSHADE_API
519  static bool DisconnectSource(UsdShadeInput const &input) {
520  return DisconnectSource(input.GetAttr());
521  }
522 
524  USDSHADE_API
525  static bool DisconnectSource(UsdShadeOutput const &output) {
526  return DisconnectSource(output.GetProperty());
527  }
528 
535  USDSHADE_API
536  static bool ClearSource(UsdProperty const &shadingProp);
537 
539  USDSHADE_API
540  static bool ClearSource(UsdShadeInput const &input) {
541  return ClearSource(input.GetAttr());
542  }
543 
545  USDSHADE_API
546  static bool ClearSource(UsdShadeOutput const &output) {
547  return ClearSource(output.GetProperty());
548  }
549 
551 
552 
555 
562  USDSHADE_API
563  UsdShadeOutput CreateOutput(const TfToken& name,
564  const SdfValueTypeName& typeName) const;
565 
570  USDSHADE_API
571  UsdShadeOutput GetOutput(const TfToken &name) const;
572 
576  USDSHADE_API
577  std::vector<UsdShadeOutput> GetOutputs() const;
578 
580 
583 
588  USDSHADE_API
589  UsdShadeInput CreateInput(const TfToken& name,
590  const SdfValueTypeName& typeName) const;
591 
596  USDSHADE_API
597  UsdShadeInput GetInput(const TfToken &name) const;
598 
602  USDSHADE_API
603  std::vector<UsdShadeInput> GetInputs() const;
604 
606 
607 };
608 
609 PXR_NAMESPACE_CLOSE_SCOPE
610 
611 #endif
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
USDSHADE_API UsdShadeOutput GetOutput(const TfToken &name) const
Return the requested output if it exists.
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdShadeOutput const &output, SdfPathVector *sourcePaths)
UsdShadeConnectableAPI(const UsdSchemaBase &schemaObj)
Construct a UsdShadeConnectableAPI on the prim held by schemaObj .
USDSHADE_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeInput const &sourceInput)
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeOutput const &sourceOutput)
static USDSHADE_API bool ClearSource(UsdShadeOutput const &output)
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdShadeInput &sourceInput)
UsdAttribute GetAttr() const
Explicit UsdAttribute extractor.
Definition: output.h:222
static USDSHADE_API bool DisconnectSource(UsdProperty const &shadingProp)
Disconnect source for this shading property.
Represents a value type name, i.e.
Definition: valueTypeName.h:83
USDSHADE_API std::vector< UsdShadeInput > GetInputs() const
Returns all inputs on the connectable prim (i.e.
const UsdProperty & GetProperty() const
Explicit UsdProperty extractor.
Definition: output.h:225
The base class for all API schemas.
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeInput const &sourceInput)
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
USDSHADE_API UsdShadeOutput CreateOutput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an output, which represents and externally computed, typed value.
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
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdShadeOutput &sourceOutput)
static USDSHADE_API bool GetConnectedSource(UsdShadeOutput const &output, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
static USDSHADE_API bool GetConnectedSource(UsdProperty const &shadingProp, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
Finds the source of a connection for the given shading property.
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...
static USDSHADE_API bool ClearSource(UsdProperty const &shadingProp)
Clears source for this shading property in the current UsdEditTarget.
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, SdfPath const &sourcePath)
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, SdfPath const &sourcePath)
static USDSHADE_API bool ConnectToSource(UsdShadeInput const &input, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
Non-applied API schema.
USDSHADE_API bool IsShader() const
Returns true if the prim is a shader.
USDSHADE_API UsdShadeInput CreateInput(const TfToken &name, const SdfValueTypeName &typeName) const
Create an input which can both have a value and be connected.
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:131
virtual USDSHADE_API ~UsdShadeConnectableAPI()
Destructor.
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
const UsdAttribute & GetAttr() const
Explicit UsdAttribute extractor.
Definition: input.h:227
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:433
USDSHADE_API bool _IsCompatible() const override
Returns true if the given prim is compatible with this API schema, i.e.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdProperty &shadingProp)
Returns true if the connection to the given shading property&#39;s source, as returned by UsdShadeConnect...
UsdShadeConnectableAPI(const UsdShadeShader &shader)
Constructor that takes a UsdShadeShader.
static USDSHADE_API bool HasConnectedSource(const UsdShadeInput &input)
static USDSHADE_API bool ConnectToSource(UsdShadeOutput const &output, UsdShadeOutput const &sourceOutput)
static USDSHADE_API bool GetConnectedSource(UsdShadeInput const &input, UsdShadeConnectableAPI *source, TfToken *sourceName, UsdShadeAttributeType *sourceType)
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
UsdShadeConnectableAPI(const UsdShadeNodeGraph &nodeGraph)
Constructor that takes a UsdShadeNodeGraph.
static USDSHADE_API bool CanConnect(const UsdShadeOutput &output, const UsdShadeOutput &sourceOutput)
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
UsdShadeConnectableAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeConnectableAPI on UsdPrim prim .
static USDSHADE_API bool ConnectToSource(UsdProperty const &shadingProp, UsdShadeConnectableAPI const &source, TfToken const &sourceName, UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output, SdfValueTypeName typeName=SdfValueTypeName())
Authors a connection for a given shading property shadingProp.
static USDSHADE_API bool HasConnectedSource(const UsdShadeOutput &output)
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdShadeOutput &output)
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...
USDSHADE_API std::vector< UsdShadeOutput > GetOutputs() const
Returns all outputs on the connectable prim (i.e.
static USDSHADE_API bool CanConnect(const UsdShadeOutput &output, const UsdShadeInput &sourceInput)
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 UsdShadeInput GetInput(const TfToken &name) const
Return the requested input if it exists.
static USDSHADE_API bool CanConnect(const UsdShadeInput &input, const UsdAttribute &source)
Determines whether the given input can be connected to the given source attribute, which can be an input or an output.
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdProperty const &shadingProp, SdfPathVector *sourcePaths)
Returns the &quot;raw&quot; (authored) connected source paths for the given shading property.
static USDSHADE_API UsdShadeConnectableAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeConnectableAPI holding the prim adhering to this schema at path on stage...
static USDSHADE_API bool DisconnectSource(UsdShadeInput const &input)
static USDSHADE_API bool DisconnectSource(UsdShadeOutput const &output)
static USDSHADE_API bool HasConnectedSource(const UsdProperty &shadingProp)
Returns true if and only if the shading property is currently connected to a valid (defined) source...
static USDSHADE_API bool IsSourceConnectionFromBaseMaterial(const UsdShadeInput &input)
static USDSHADE_API bool GetRawConnectedSourcePaths(UsdShadeInput const &input, SdfPathVector *sourcePaths)
USDSHADE_API bool IsNodeGraph() const
Returns true if the prim is a node-graph.
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119
static USDSHADE_API bool ClearSource(UsdShadeInput const &input)