Loading...
Searching...
No Matches
nodeDefAPI.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_NODEDEFAPI_H
25#define USDSHADE_GENERATED_NODEDEFAPI_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/usdShade/api.h"
32#include "pxr/usd/usd/prim.h"
33#include "pxr/usd/usd/stage.h"
35
36#include "pxr/usd/ndr/declare.h"
38
39
40#include "pxr/base/vt/value.h"
41
42#include "pxr/base/gf/vec3d.h"
43#include "pxr/base/gf/vec3f.h"
45
46#include "pxr/base/tf/token.h"
47#include "pxr/base/tf/type.h"
48
49PXR_NAMESPACE_OPEN_SCOPE
50
51class SdfAssetPath;
52
53// -------------------------------------------------------------------------- //
54// NODEDEFAPI //
55// -------------------------------------------------------------------------- //
56
85{
86public:
90 static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
91
96 explicit UsdShadeNodeDefAPI(const UsdPrim& prim=UsdPrim())
97 : UsdAPISchemaBase(prim)
98 {
99 }
100
104 explicit UsdShadeNodeDefAPI(const UsdSchemaBase& schemaObj)
105 : UsdAPISchemaBase(schemaObj)
106 {
107 }
108
110 USDSHADE_API
112
116 USDSHADE_API
117 static const TfTokenVector &
118 GetSchemaAttributeNames(bool includeInherited=true);
119
129 USDSHADE_API
130 static UsdShadeNodeDefAPI
131 Get(const UsdStagePtr &stage, const SdfPath &path);
132
133
150 USDSHADE_API
151 static bool
152 CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
153
169 USDSHADE_API
170 static UsdShadeNodeDefAPI
171 Apply(const UsdPrim &prim);
172
173protected:
177 USDSHADE_API
179
180private:
181 // needs to invoke _GetStaticTfType.
182 friend class UsdSchemaRegistry;
183 USDSHADE_API
184 static const TfType &_GetStaticTfType();
185
186 static bool _IsTypedSchema();
187
188 // override SchemaBase virtuals.
189 USDSHADE_API
190 const TfType &_GetTfType() const override;
191
192public:
193 // --------------------------------------------------------------------- //
194 // IMPLEMENTATIONSOURCE
195 // --------------------------------------------------------------------- //
219 USDSHADE_API
221
227 USDSHADE_API
228 UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
229
230public:
231 // --------------------------------------------------------------------- //
232 // ID
233 // --------------------------------------------------------------------- //
249 USDSHADE_API
251
257 USDSHADE_API
258 UsdAttribute CreateIdAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
259
260public:
261 // ===================================================================== //
262 // Feel free to add custom code below this line, it will be preserved by
263 // the code generator.
264 //
265 // Just remember to:
266 // - Close the class declaration with };
267 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
268 // - Close the include guard with #endif
269 // ===================================================================== //
270 // --(BEGIN CUSTOM CODE)--
271
272
273 // -------------------------------------------------------------------------
281
317 USDSHADE_API
319
323 USDSHADE_API
324 bool SetShaderId(const TfToken &id) const;
325
333 USDSHADE_API
334 bool GetShaderId(TfToken *id) const;
335
341 USDSHADE_API
343 const SdfAssetPath &sourceAsset,
344 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
345
361 USDSHADE_API
363 SdfAssetPath *sourceAsset,
364 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
365
372 USDSHADE_API
374 const TfToken &subIdentifier,
375 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
376
391 USDSHADE_API
393 TfToken *subIdentifier,
394 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
395
401 USDSHADE_API
403 const std::string &sourceCode,
404 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
405
421 USDSHADE_API
423 std::string *sourceCode,
424 const TfToken &sourceType=UsdShadeTokens->universalSourceType) const;
425
427 // -------------------------------------------------------------------------
428
433 USDSHADE_API
434 SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType)
435 const;
436
437};
438
439PXR_NAMESPACE_CLOSE_SCOPE
440
441#endif
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
TfType represents a dynamic runtime type.
Definition: type.h:65
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
The base class for all schema types in Usd.
Definition: schemaBase.h:56
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdShadeNodeDefAPI is an API schema that provides attributes for a prim to select a corresponding Sha...
Definition: nodeDefAPI.h:85
USDSHADE_API bool GetSourceCode(std::string *sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's source code for the specified sourceType value by reading the info:sourceType:so...
USDSHADE_API bool GetSourceAsset(SdfAssetPath *sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's source asset value for the specified sourceType value from the info:sourceType:s...
USDSHADE_API UsdAttribute GetImplementationSourceAttr() const
Specifies the attribute that should be consulted to get the shader's implementation or its source cod...
USDSHADE_API bool SetSourceAsset(const SdfAssetPath &sourceAsset, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader's source-asset path value to sourceAsset for the given source type,...
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: nodeDefAPI.h:90
USDSHADE_API bool SetShaderId(const TfToken &id) const
Sets the shader's ID value.
USDSHADE_API UsdAttribute CreateImplementationSourceAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetImplementationSourceAttr(), and also Create vs Get Property Methods for when to use Get vs Cre...
UsdShadeNodeDefAPI(const UsdSchemaBase &schemaObj)
Construct a UsdShadeNodeDefAPI on the prim held by schemaObj .
Definition: nodeDefAPI.h:104
virtual USDSHADE_API ~UsdShadeNodeDefAPI()
Destructor.
static USDSHADE_API UsdShadeNodeDefAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdShadeNodeDefAPI holding the prim adhering to this schema at path on stage.
UsdShadeNodeDefAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdShadeNodeDefAPI on UsdPrim prim .
Definition: nodeDefAPI.h:96
static USDSHADE_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.
USDSHADE_API bool SetSourceCode(const std::string &sourceCode, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Sets the shader's source-code value to sourceCode for the given source type, sourceType.
USDSHADE_API TfToken GetImplementationSource() const
Reads the value of info:implementationSource attribute and returns a token identifying the attribute ...
static USDSHADE_API UsdShadeNodeDefAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
USDSHADE_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
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...
USDSHADE_API bool GetSourceAssetSubIdentifier(TfToken *subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Fetches the shader's sub-identifier for the source asset with the specified sourceType value from the...
USDSHADE_API SdrShaderNodeConstPtr GetShaderNodeForSourceType(const TfToken &sourceType) const
This method attempts to ensure that there is a ShaderNode in the shader registry (i....
USDSHADE_API bool SetSourceAssetSubIdentifier(const TfToken &subIdentifier, const TfToken &sourceType=UsdShadeTokens->universalSourceType) const
Set a sub-identifier to be used with a source asset of the given source type.
USDSHADE_API bool GetShaderId(TfToken *id) const
Fetches the shader's ID value from the info:id attribute, if the shader's info:implementationSource i...
USDSHADE_API UsdAttribute GetIdAttr() const
The id is an identifier for the type or purpose of the shader.
USDSHADE_API UsdAttribute CreateIdAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetIdAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:165
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:129
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:457
Common typedefs that are used throughout the NDR library.
USDSHADE_API TfStaticData< UsdShadeTokensType > UsdShadeTokens
A global variable with static, efficient TfTokens for use in all public USD API.