All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
31 #include "pxr/usd/usd/apiSchemaBase.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"
38 #include "pxr/usd/usdShade/material.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 
69 {
70 public:
75 
80  explicit UsdRiMaterialAPI(const UsdPrim& prim=UsdPrim())
81  : UsdAPISchemaBase(prim)
82  {
83  }
84 
88  explicit UsdRiMaterialAPI(const UsdSchemaBase& schemaObj)
89  : UsdAPISchemaBase(schemaObj)
90  {
91  }
92 
94  USDRI_API
95  virtual ~UsdRiMaterialAPI();
96 
100  USDRI_API
101  static const TfTokenVector &
102  GetSchemaAttributeNames(bool includeInherited=true);
103 
113  USDRI_API
114  static UsdRiMaterialAPI
115  Get(const UsdStagePtr &stage, const SdfPath &path);
116 
117 
130  USDRI_API
131  static UsdRiMaterialAPI
132  Apply(const UsdPrim &prim);
133 
134 protected:
138  USDRI_API
139  UsdSchemaType _GetSchemaType() const override;
140 
141 private:
142  // needs to invoke _GetStaticTfType.
143  friend class UsdSchemaRegistry;
144  USDRI_API
145  static const TfType &_GetStaticTfType();
146 
147  static bool _IsTypedSchema();
148 
149  // override SchemaBase virtuals.
150  USDRI_API
151  const TfType &_GetTfType() const override;
152 
153 public:
154  // --------------------------------------------------------------------- //
155  // SURFACE
156  // --------------------------------------------------------------------- //
164  USDRI_API
166 
172  USDRI_API
173  UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
174 
175 public:
176  // --------------------------------------------------------------------- //
177  // DISPLACEMENT
178  // --------------------------------------------------------------------- //
186  USDRI_API
188 
194  USDRI_API
195  UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
196 
197 public:
198  // --------------------------------------------------------------------- //
199  // VOLUME
200  // --------------------------------------------------------------------- //
208  USDRI_API
209  UsdAttribute GetVolumeAttr() const;
210 
216  USDRI_API
217  UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
218 
219 public:
220  // ===================================================================== //
221  // Feel free to add custom code below this line, it will be preserved by
222  // the code generator.
223  //
224  // Just remember to:
225  // - Close the class declaration with };
226  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
227  // - Close the include guard with #endif
228  // ===================================================================== //
229  // --(BEGIN CUSTOM CODE)--
230 
232  explicit UsdRiMaterialAPI(const UsdShadeMaterial& material)
233  : UsdRiMaterialAPI(material.GetPrim())
234  {
235  }
236 
237  // --------------------------------------------------------------------- //
239  // --------------------------------------------------------------------- //
241 
243  USDRI_API
245 
247  USDRI_API
249 
251  USDRI_API
253 
255 
256  // --------------------------------------------------------------------- //
258  // --------------------------------------------------------------------- //
260 
261  USDRI_API
262  bool SetSurfaceSource(const SdfPath &surfacePath) const;
263 
264  USDRI_API
265  bool SetDisplacementSource(const SdfPath &displacementPath) const;
266 
267  USDRI_API
268  bool SetVolumeSource(const SdfPath &volumePath) const;
269 
271 
272  // --------------------------------------------------------------------- //
274  // --------------------------------------------------------------------- //
276 
283  USDRI_API
284  UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const;
285 
292  USDRI_API
293  UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const;
294 
301  USDRI_API
302  UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const;
303 
305 
306 
311  USDRI_API
314  bool computeTransitiveConsumers=false) const;
315 
317 
318 private:
319  UsdShadeShader _GetSourceShaderObject(const UsdShadeOutput &output,
320  bool ignoreBaseMaterial) const;
321 
322  // Helper method to get the deprecated 'bxdf' output.
323  UsdShadeOutput _GetBxdfOutput(const UsdPrim &materialPrim) const;
324 };
325 
326 PXR_NAMESPACE_CLOSE_SCOPE
327 
328 #endif
USDRI_API UsdShadeOutput GetDisplacementOutput() const
Returns the "displacement" output associated with the material.
USDRI_API UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "displacement" output on the material is connected to one...
USDRI_API UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "volume" output on the material is connected to one...
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:346
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: materialAPI.h:74
USDRI_API UsdAttribute GetSurfaceAttr() const
Declaration token outputs:ri:surface C++ Type TfToken Usd Type SdfValueTypeNames-&gt;Token ...
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
USDRI_API UsdShadeOutput GetVolumeOutput() const
Returns the &quot;volume&quot; output associated with the material.
UsdRiMaterialAPI(const UsdSchemaBase &schemaObj)
Construct a UsdRiMaterialAPI on the prim held by schemaObj .
Definition: materialAPI.h:88
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...
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
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:433
Single Apply API schema.
USDRI_API UsdShadeOutput GetSurfaceOutput() const
Returns the &quot;surface&quot; output associated with the material.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
USDRI_API UsdAttribute GetDisplacementAttr() const
Declaration token outputs:ri:displacement C++ Type TfToken Usd Type SdfValueTypeNames-&gt;Token ...
USDRI_API UsdAttribute GetVolumeAttr() const
Declaration token outputs:ri:volume C++ Type TfToken Usd Type SdfValueTypeNames-&gt;Token ...
USDRI_API UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the &quot;surface&quot; output on the material is connected to one...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
UsdRiMaterialAPI(const UsdShadeMaterial &material)
A constructor for creating a MaterialAPI object from a material prim.
Definition: materialAPI.h:232
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...
USDRI_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
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:80
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...
A Material provides a container into which multiple &quot;render targets&quot; can add data that defines a &quot;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...
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 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...
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
This API provides outputs that connect a material prim to prman shaders and RIS objects.
Definition: materialAPI.h:68
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
UsdPrim GetPrim() const
Return this schema object&#39;s held prim.
Definition: schemaBase.h:119