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 private:
392  static bool _ConnectToSource(
393  UsdProperty const &shadingProp,
394  UsdShadeConnectableAPI const &source,
395  TfToken const &sourceName,
396  TfToken const &renderTarget,
397  UsdShadeAttributeType const sourceType=UsdShadeAttributeType::Output,
399 
400 protected:
401  // Befriend UsdRiLookAPI and UsdRiMaterialAPI temporarily to assist in the
402  // transition to the new shading encoding.
403  friend class UsdRiLookAPI;
404  friend class UsdRiMaterialAPI;
405 
413  USDSHADE_API
414  static bool _ConnectToSource(UsdProperty const &shadingProp,
415  UsdShadeInput const &sourceInput,
416  TfToken const &renderTarget);
417 
418 public:
419 
441  USDSHADE_API
442  static bool GetConnectedSource(UsdProperty const &shadingProp,
443  UsdShadeConnectableAPI *source,
444  TfToken *sourceName,
445  UsdShadeAttributeType *sourceType);
446 
448  USDSHADE_API
449  static bool GetConnectedSource(UsdShadeInput const &input,
450  UsdShadeConnectableAPI *source,
451  TfToken *sourceName,
452  UsdShadeAttributeType *sourceType) {
453  return GetConnectedSource(input.GetAttr(), source, sourceName,
454  sourceType);
455  }
456 
458  USDSHADE_API
459  static bool GetConnectedSource(UsdShadeOutput const &output,
460  UsdShadeConnectableAPI *source,
461  TfToken *sourceName,
462  UsdShadeAttributeType *sourceType) {
463  return GetConnectedSource(output.GetProperty(), source, sourceName,
464  sourceType);
465  }
466 
470  USDSHADE_API
471  static bool GetRawConnectedSourcePaths(UsdProperty const &shadingProp,
472  SdfPathVector *sourcePaths);
473 
475  USDSHADE_API
476  static bool GetRawConnectedSourcePaths(UsdShadeInput const &input,
477  SdfPathVector *sourcePaths) {
478  return GetRawConnectedSourcePaths(input.GetAttr(), sourcePaths);
479  }
480 
482  USDSHADE_API
483  static bool GetRawConnectedSourcePaths(UsdShadeOutput const &output,
484  SdfPathVector *sourcePaths) {
485  return GetRawConnectedSourcePaths(output.GetProperty(), sourcePaths);
486  }
487 
501  USDSHADE_API
502  static bool HasConnectedSource(const UsdProperty &shadingProp);
503 
505  USDSHADE_API
506  static bool HasConnectedSource(const UsdShadeInput &input) {
507  return HasConnectedSource(input.GetAttr());
508  }
509 
511  USDSHADE_API
512  static bool HasConnectedSource(const UsdShadeOutput &output) {
513  return HasConnectedSource(output.GetProperty());
514  }
515 
520  USDSHADE_API
522  const UsdProperty &shadingProp);
523 
525  USDSHADE_API
528  }
529 
531  USDSHADE_API
533  {
535  }
536 
547  USDSHADE_API
548  static bool DisconnectSource(UsdProperty const &shadingProp);
549 
551  USDSHADE_API
552  static bool DisconnectSource(UsdShadeInput const &input) {
553  return DisconnectSource(input.GetAttr());
554  }
555 
557  USDSHADE_API
558  static bool DisconnectSource(UsdShadeOutput const &output) {
559  return DisconnectSource(output.GetProperty());
560  }
561 
568  USDSHADE_API
569  static bool ClearSource(UsdProperty const &shadingProp);
570 
572  USDSHADE_API
573  static bool ClearSource(UsdShadeInput const &input) {
574  return ClearSource(input.GetAttr());
575  }
576 
578  USDSHADE_API
579  static bool ClearSource(UsdShadeOutput const &output) {
580  return ClearSource(output.GetProperty());
581  }
582 
592  USDSHADE_API
594 
596 
597 
600 
607  USDSHADE_API
608  UsdShadeOutput CreateOutput(const TfToken& name,
609  const SdfValueTypeName& typeName) const;
610 
615  USDSHADE_API
616  UsdShadeOutput GetOutput(const TfToken &name) const;
617 
621  USDSHADE_API
622  std::vector<UsdShadeOutput> GetOutputs() const;
623 
625 
628 
633  USDSHADE_API
634  UsdShadeInput CreateInput(const TfToken& name,
635  const SdfValueTypeName& typeName) const;
636 
641  USDSHADE_API
642  UsdShadeInput GetInput(const TfToken &name) const;
643 
647  USDSHADE_API
648  std::vector<UsdShadeInput> GetInputs() const;
649 
651 
652 };
653 
654 PXR_NAMESPACE_CLOSE_SCOPE
655 
656 #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.
static USDSHADE_API bool AreBidirectionalInterfaceConnectionsEnabled()
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: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
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:438
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.
This API provides outputs that connect a material prim to prman shaders and RIS objects.
Definition: materialAPI.h:68
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)