Loading...
Searching...
No Matches
modelAPI.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 USD_GENERATED_MODELAPI_H
8#define USD_GENERATED_MODELAPI_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usd/api.h"
15#include "pxr/usd/usd/prim.h"
16#include "pxr/usd/usd/stage.h"
17
18#include "pxr/base/vt/value.h"
19
20#include "pxr/base/gf/vec3d.h"
21#include "pxr/base/gf/vec3f.h"
23
24#include "pxr/base/tf/token.h"
25#include "pxr/base/tf/type.h"
26
27PXR_NAMESPACE_OPEN_SCOPE
28
29class SdfAssetPath;
30
31// -------------------------------------------------------------------------- //
32// MODELAPI //
33// -------------------------------------------------------------------------- //
34
56{
57public:
61 static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI;
62
67 explicit UsdModelAPI(const UsdPrim& prim=UsdPrim())
68 : UsdAPISchemaBase(prim)
69 {
70 }
71
75 explicit UsdModelAPI(const UsdSchemaBase& schemaObj)
76 : UsdAPISchemaBase(schemaObj)
77 {
78 }
79
81 USD_API
82 virtual ~UsdModelAPI();
83
87 USD_API
88 static const TfTokenVector &
89 GetSchemaAttributeNames(bool includeInherited=true);
90
100 USD_API
101 static UsdModelAPI
102 Get(const UsdStagePtr &stage, const SdfPath &path);
103
104
105protected:
109 USD_API
111
112private:
113 // needs to invoke _GetStaticTfType.
114 friend class UsdSchemaRegistry;
115 USD_API
116 static const TfType &_GetStaticTfType();
117
118 static bool _IsTypedSchema();
119
120 // override SchemaBase virtuals.
121 USD_API
122 const TfType &_GetTfType() const override;
123
124public:
125 // ===================================================================== //
126 // Feel free to add custom code below this line, it will be preserved by
127 // the code generator.
128 //
129 // Just remember to:
130 // - Close the class declaration with };
131 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
132 // - Close the include guard with #endif
133 // ===================================================================== //
134 // --(BEGIN CUSTOM CODE)--
135
139
145 KindValidationNone,
146 KindValidationModelHierarchy
147 };
148
155 USD_API
156 bool GetKind(TfToken* kind) const;
157
162 USD_API
163 bool SetKind(const TfToken& kind) const;
164
180 USD_API
181 bool IsKind(const TfToken& baseKind,
182 KindValidation validation=KindValidationModelHierarchy) const;
183
186 USD_API
187 bool IsModel() const;
188
191 USD_API
192 bool IsGroup() const;
193
195
199
206 USD_API
207 bool GetAssetIdentifier(SdfAssetPath *identifier) const;
208
213 USD_API
214 void SetAssetIdentifier(const SdfAssetPath &identifier) const;
215
221 USD_API
222 bool GetAssetName(std::string *assetName) const;
223
228 USD_API
229 void SetAssetName(const std::string &assetName) const;
230
242 USD_API
243 bool GetAssetVersion(std::string *version) const;
244
249 USD_API
250 void SetAssetVersion(const std::string &version) const;
251
261 USD_API
263 const;
264
270 USD_API
272 const;
273
283 USD_API
284 bool GetAssetInfo(VtDictionary *info) const;
285
289 USD_API
290 void SetAssetInfo(const VtDictionary &info) const;
291
293
294protected:
295
296 template<typename T>
297 bool _GetAssetInfoByKey(const TfToken &key, T *val) const {
298 VtValue vtVal = GetPrim().GetAssetInfoByKey(key);
299 if (!vtVal.IsEmpty() && vtVal.IsHolding<T>()) {
300 *val = vtVal.UncheckedGet<T>();
301 return true;
302 }
303 return false;
304 }
305};
306
321#define USDMODEL_ASSET_INFO_KEYS \
322 (identifier) \
323 (name) \
324 (version) \
325 (payloadAssetDependencies)
326
327TF_DECLARE_PUBLIC_TOKENS(UsdModelAPIAssetInfoKeys, USD_API, USDMODEL_ASSET_INFO_KEYS);
328
329PXR_NAMESPACE_CLOSE_SCOPE
330
331#endif
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:78
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
The base class for all API schemas.
Definition: apiSchemaBase.h:99
UsdModelAPI is an API schema that provides an interface to a prim's model qualities,...
Definition: modelAPI.h:56
USD_API void SetAssetName(const std::string &assetName) const
Sets the model's asset name to assetName.
USD_API bool SetKind(const TfToken &kind) const
Author a kind for this prim, at the current UsdEditTarget.
USD_API bool GetPayloadAssetDependencies(VtArray< SdfAssetPath > *assetDeps) const
Returns the list of asset dependencies referenced inside the payload of the model.
USD_API void SetAssetInfo(const VtDictionary &info) const
Sets the model's assetInfo dictionary to info in the current edit target.
USD_API bool GetAssetInfo(VtDictionary *info) const
Returns the model's composed assetInfo dictionary.
static USD_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...
USD_API bool GetAssetName(std::string *assetName) const
Returns the model's asset name from the composed assetInfo dictionary.
USD_API bool GetKind(TfToken *kind) const
Retrieve the authored kind for this prim.
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: modelAPI.h:61
USD_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
KindValidation
Option for validating queries to a prim's kind metadata.
Definition: modelAPI.h:144
virtual USD_API ~UsdModelAPI()
Destructor.
static USD_API UsdModelAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdModelAPI holding the prim adhering to this schema at path on stage.
USD_API bool GetAssetIdentifier(SdfAssetPath *identifier) const
Returns the model's asset identifier as authored in the composed assetInfo dictionary.
UsdModelAPI(const UsdSchemaBase &schemaObj)
Construct a UsdModelAPI on the prim held by schemaObj .
Definition: modelAPI.h:75
USD_API bool GetAssetVersion(std::string *version) const
Returns the model's resolved asset version.
USD_API bool IsModel() const
Return true if this prim represents a model, based on its kind metadata.
UsdModelAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdModelAPI on UsdPrim prim .
Definition: modelAPI.h:67
USD_API void SetPayloadAssetDependencies(const VtArray< SdfAssetPath > &assetDeps) const
Sets the list of external asset dependencies referenced inside the payload of a model.
USD_API bool IsGroup() const
Return true if this prim represents a model group, based on its kind metadata.
USD_API bool IsKind(const TfToken &baseKind, KindValidation validation=KindValidationModelHierarchy) const
Return true if the prim's kind metadata is or inherits from baseKind as defined by the Kind Registry.
USD_API void SetAssetIdentifier(const SdfAssetPath &identifier) const
Sets the model's asset identifier to the given asset path, identifier.
USD_API void SetAssetVersion(const std::string &version) const
Sets the model's asset version string.
USD_API VtValue GetAssetInfoByKey(const TfToken &keyPath) const
Return the element identified by keyPath in this object's composed assetInfo dictionary.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
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...
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:213
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152
bool IsEmpty() const
Returns true iff this value is empty.
Definition: value.h:1275
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
Definition: value.h:1050
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
Definition: value.h:1094
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:112
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92
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
#define USDMODEL_ASSET_INFO_KEYS
Definition: modelAPI.h:321