materialAPI.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 USDRI_GENERATED_MATERIALAPI_H
25 #define USDRI_GENERATED_MATERIALAPI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdRi/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdRi/tokens.h"
35 
36 #include "pxr/usd/usdShade/input.h"
37 #include "pxr/usd/usdShade/output.h"
39 
40 
41 #include "pxr/base/vt/value.h"
42 
43 #include "pxr/base/gf/vec3d.h"
44 #include "pxr/base/gf/vec3f.h"
45 #include "pxr/base/gf/matrix4d.h"
46 
47 #include "pxr/base/tf/token.h"
48 #include "pxr/base/tf/type.h"
49 
50 PXR_NAMESPACE_OPEN_SCOPE
51 
52 class SdfAssetPath;
53 
54 // -------------------------------------------------------------------------- //
55 // RIMATERIALAPI //
56 // -------------------------------------------------------------------------- //
57 
73 {
74 public:
79 
84  explicit UsdRiMaterialAPI(const UsdPrim& prim=UsdPrim())
85  : UsdAPISchemaBase(prim)
86  {
87  }
88 
92  explicit UsdRiMaterialAPI(const UsdSchemaBase& schemaObj)
93  : UsdAPISchemaBase(schemaObj)
94  {
95  }
96 
98  USDRI_API
99  virtual ~UsdRiMaterialAPI();
100 
104  USDRI_API
105  static const TfTokenVector &
106  GetSchemaAttributeNames(bool includeInherited=true);
107 
117  USDRI_API
118  static UsdRiMaterialAPI
119  Get(const UsdStagePtr &stage, const SdfPath &path);
120 
121 
138  USDRI_API
139  static bool
140  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
141 
157  USDRI_API
158  static UsdRiMaterialAPI
159  Apply(const UsdPrim &prim);
160 
161 protected:
165  USDRI_API
166  UsdSchemaKind _GetSchemaKind() const override;
167 
168 private:
169  // needs to invoke _GetStaticTfType.
170  friend class UsdSchemaRegistry;
171  USDRI_API
172  static const TfType &_GetStaticTfType();
173 
174  static bool _IsTypedSchema();
175 
176  // override SchemaBase virtuals.
177  USDRI_API
178  const TfType &_GetTfType() const override;
179 
180 public:
181  // --------------------------------------------------------------------- //
182  // SURFACE
183  // --------------------------------------------------------------------- //
191  USDRI_API
193 
199  USDRI_API
200  UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
201 
202 public:
203  // --------------------------------------------------------------------- //
204  // DISPLACEMENT
205  // --------------------------------------------------------------------- //
213  USDRI_API
215 
221  USDRI_API
222  UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
223 
224 public:
225  // --------------------------------------------------------------------- //
226  // VOLUME
227  // --------------------------------------------------------------------- //
235  USDRI_API
236  UsdAttribute GetVolumeAttr() const;
237 
243  USDRI_API
244  UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
245 
246 public:
247  // ===================================================================== //
248  // Feel free to add custom code below this line, it will be preserved by
249  // the code generator.
250  //
251  // Just remember to:
252  // - Close the class declaration with };
253  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
254  // - Close the include guard with #endif
255  // ===================================================================== //
256  // --(BEGIN CUSTOM CODE)--
257 
259  explicit UsdRiMaterialAPI(const UsdShadeMaterial& material)
260  : UsdRiMaterialAPI(material.GetPrim())
261  {
262  }
263 
264  // --------------------------------------------------------------------- //
266  // --------------------------------------------------------------------- //
268 
270  USDRI_API
272 
274  USDRI_API
276 
278  USDRI_API
280 
282 
283  // --------------------------------------------------------------------- //
285  // --------------------------------------------------------------------- //
287 
288  USDRI_API
289  bool SetSurfaceSource(const SdfPath &surfacePath) const;
290 
291  USDRI_API
292  bool SetDisplacementSource(const SdfPath &displacementPath) const;
293 
294  USDRI_API
295  bool SetVolumeSource(const SdfPath &volumePath) const;
296 
298 
299  // --------------------------------------------------------------------- //
301  // --------------------------------------------------------------------- //
303 
310  USDRI_API
311  UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const;
312 
319  USDRI_API
320  UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const;
321 
328  USDRI_API
329  UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const;
330 
332 
333 
338  USDRI_API
341  bool computeTransitiveConsumers=false) const;
342 
344 
345 private:
346  UsdShadeShader _GetSourceShaderObject(const UsdShadeOutput &output,
347  bool ignoreBaseMaterial) const;
348 
349  // Helper method to get the deprecated 'bxdf' output.
350  UsdShadeOutput _GetBxdfOutput(const UsdPrim &materialPrim) const;
351 };
352 
353 PXR_NAMESPACE_CLOSE_SCOPE
354 
355 #endif
USDRI_API UsdShadeNodeGraph::InterfaceInputConsumersMap ComputeInterfaceInputConsumersMap(bool computeTransitiveConsumers=false) const
Walks the namespace subtree below the material and computes a map containing the list of all inputs o...
USDRI_API UsdShadeOutput GetDisplacementOutput() const
Returns the "displacement" output associated with the material.
virtual USDRI_API ~UsdRiMaterialAPI()
Destructor.
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:355
UsdPrim GetPrim() const
Return this schema object's held prim.
Definition: schemaBase.h:120
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
Single Apply API schema.
USDRI_API UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "volume" output on the material is connected to one.
USDRI_API UsdAttribute CreateVolumeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetVolumeAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDRI_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
USDRI_API UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetDisplacementAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
UsdRiMaterialAPI(const UsdSchemaBase &schemaObj)
Construct a UsdRiMaterialAPI on the prim held by schemaObj .
Definition: materialAPI.h:92
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: materialAPI.h:78
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
USDRI_API UsdAttribute GetVolumeAttr() const
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USDRI_API UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetSurfaceAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDRI_API UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "displacement" output on the material is connected to one.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
UsdRiMaterialAPI(const UsdShadeMaterial &material)
A constructor for creating a MaterialAPI object from a material prim.
Definition: materialAPI.h:259
static USDRI_API UsdRiMaterialAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
static USDRI_API UsdRiMaterialAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdRiMaterialAPI holding the prim adhering to this schema at path on stage.
UsdRiMaterialAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdRiMaterialAPI on UsdPrim prim .
Definition: materialAPI.h:84
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...
USDRI_API UsdShadeOutput GetVolumeOutput() const
Returns the "volume" output associated with the material.
A Material provides a container into which multiple "render targets" can add data that defines a "sha...
Definition: material.h:111
static USDRI_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 USDRI_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
Returns true if this single-apply API schema can be applied to the given prim.
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:47
USDRI_API UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "surface" output on the material is connected to one.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
USDRI_API UsdAttribute GetDisplacementAttr() const
USDRI_API UsdShadeOutput GetSurfaceOutput() const
Returns the "surface" output associated with the material.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USDRI_API UsdAttribute GetSurfaceAttr() const