All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
materialAPI.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef USDRI_GENERATED_MATERIALAPI_H
8#define USDRI_GENERATED_MATERIALAPI_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdRi/api.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
18
19#include "pxr/usd/usdShade/input.h"
20#include "pxr/usd/usdShade/output.h"
22
23
24#include "pxr/base/vt/value.h"
25
26#include "pxr/base/gf/vec3d.h"
27#include "pxr/base/gf/vec3f.h"
29
30#include "pxr/base/tf/token.h"
31#include "pxr/base/tf/type.h"
32
33PXR_NAMESPACE_OPEN_SCOPE
34
35class SdfAssetPath;
36
37// -------------------------------------------------------------------------- //
38// RIMATERIALAPI //
39// -------------------------------------------------------------------------- //
40
56{
57public:
61 static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
62
67 explicit UsdRiMaterialAPI(const UsdPrim& prim=UsdPrim())
68 : UsdAPISchemaBase(prim)
69 {
70 }
71
75 explicit UsdRiMaterialAPI(const UsdSchemaBase& schemaObj)
76 : UsdAPISchemaBase(schemaObj)
77 {
78 }
79
81 USDRI_API
83
87 USDRI_API
88 static const TfTokenVector &
89 GetSchemaAttributeNames(bool includeInherited=true);
90
100 USDRI_API
101 static UsdRiMaterialAPI
102 Get(const UsdStagePtr &stage, const SdfPath &path);
103
104
121 USDRI_API
122 static bool
123 CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
124
140 USDRI_API
141 static UsdRiMaterialAPI
142 Apply(const UsdPrim &prim);
143
144protected:
148 USDRI_API
150
151private:
152 // needs to invoke _GetStaticTfType.
153 friend class UsdSchemaRegistry;
154 USDRI_API
155 static const TfType &_GetStaticTfType();
156
157 static bool _IsTypedSchema();
158
159 // override SchemaBase virtuals.
160 USDRI_API
161 const TfType &_GetTfType() const override;
162
163public:
164 // --------------------------------------------------------------------- //
165 // SURFACE
166 // --------------------------------------------------------------------- //
174 USDRI_API
176
182 USDRI_API
183 UsdAttribute CreateSurfaceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
184
185public:
186 // --------------------------------------------------------------------- //
187 // DISPLACEMENT
188 // --------------------------------------------------------------------- //
196 USDRI_API
198
204 USDRI_API
205 UsdAttribute CreateDisplacementAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
206
207public:
208 // --------------------------------------------------------------------- //
209 // VOLUME
210 // --------------------------------------------------------------------- //
218 USDRI_API
220
226 USDRI_API
227 UsdAttribute CreateVolumeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
228
229public:
230 // ===================================================================== //
231 // Feel free to add custom code below this line, it will be preserved by
232 // the code generator.
233 //
234 // Just remember to:
235 // - Close the class declaration with };
236 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
237 // - Close the include guard with #endif
238 // ===================================================================== //
239 // --(BEGIN CUSTOM CODE)--
240
242 explicit UsdRiMaterialAPI(const UsdShadeMaterial& material)
243 : UsdRiMaterialAPI(material.GetPrim())
244 {
245 }
246
247 // --------------------------------------------------------------------- //
249 // --------------------------------------------------------------------- //
251
253 USDRI_API
255
257 USDRI_API
259
261 USDRI_API
263
265
266 // --------------------------------------------------------------------- //
268 // --------------------------------------------------------------------- //
270
271 USDRI_API
272 bool SetSurfaceSource(const SdfPath &surfacePath) const;
273
274 USDRI_API
275 bool SetDisplacementSource(const SdfPath &displacementPath) const;
276
277 USDRI_API
278 bool SetVolumeSource(const SdfPath &volumePath) const;
279
281
282 // --------------------------------------------------------------------- //
284 // --------------------------------------------------------------------- //
286
293 USDRI_API
294 UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const;
295
302 USDRI_API
303 UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const;
304
311 USDRI_API
312 UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const;
313
315
316
321 USDRI_API
324 bool computeTransitiveConsumers=false) const;
325
327
328private:
329 UsdShadeShader _GetSourceShaderObject(const UsdShadeOutput &output,
330 bool ignoreBaseMaterial) const;
331
332 // Helper method to get the deprecated 'bxdf' output.
333 UsdShadeOutput _GetBxdfOutput(const UsdPrim &materialPrim) const;
334};
335
336PXR_NAMESPACE_CLOSE_SCOPE
337
338#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
TfType represents a dynamic runtime type.
Definition: type.h:48
The base class for all API schemas.
Definition: apiSchemaBase.h:99
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
USDRI_API UsdShadeOutput GetVolumeOutput() const
Returns the "volume" output associated with the material.
virtual USDRI_API ~UsdRiMaterialAPI()
Destructor.
UsdRiMaterialAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdRiMaterialAPI on UsdPrim prim .
Definition: materialAPI.h:67
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 UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
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.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: materialAPI.h:61
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.
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 UsdShadeShader GetDisplacement(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "displacement" output on the material is connected to one.
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...
UsdRiMaterialAPI(const UsdSchemaBase &schemaObj)
Construct a UsdRiMaterialAPI on the prim held by schemaObj .
Definition: materialAPI.h:75
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 UsdShadeShader GetVolume(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "volume" output on the material is connected to one.
USDRI_API UsdShadeOutput GetSurfaceOutput() const
Returns the "surface" output associated with the material.
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.
USDRI_API UsdShadeShader GetSurface(bool ignoreBaseMaterial=false) const
Returns a valid shader object if the "surface" output on the material is connected to one.
USDRI_API UsdAttribute GetDisplacementAttr() const
USDRI_API UsdAttribute GetSurfaceAttr() const
static USDRI_API UsdRiMaterialAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
UsdRiMaterialAPI(const UsdShadeMaterial &material)
A constructor for creating a MaterialAPI object from a material prim.
Definition: materialAPI.h:242
USDRI_API UsdShadeOutput GetDisplacementOutput() const
Returns the "displacement" output associated with the material.
USDRI_API UsdAttribute GetVolumeAttr() const
The base class for all schema types in Usd.
Definition: schemaBase.h:39
UsdPrim GetPrim() const
Return this schema object's held prim.
Definition: schemaBase.h:103
Singleton registry that provides access to schema type information and the prim definitions for regis...
A Material provides a container into which multiple "render contexts" can add data that defines a "sh...
Definition: material.h:96
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:338
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:31
Base class for all USD shaders.
Definition: shader.h:69
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440