Loading...
Searching...
No Matches
modelAPI.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 USD_GENERATED_MODELAPI_H
25#define USD_GENERATED_MODELAPI_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/usd/api.h"
32#include "pxr/usd/usd/prim.h"
33#include "pxr/usd/usd/stage.h"
34
35#include "pxr/base/vt/value.h"
36
37#include "pxr/base/gf/vec3d.h"
38#include "pxr/base/gf/vec3f.h"
40
41#include "pxr/base/tf/token.h"
42#include "pxr/base/tf/type.h"
43
44PXR_NAMESPACE_OPEN_SCOPE
45
46class SdfAssetPath;
47
48// -------------------------------------------------------------------------- //
49// MODELAPI //
50// -------------------------------------------------------------------------- //
51
73{
74public:
78 static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI;
79
84 explicit UsdModelAPI(const UsdPrim& prim=UsdPrim())
85 : UsdAPISchemaBase(prim)
86 {
87 }
88
92 explicit UsdModelAPI(const UsdSchemaBase& schemaObj)
93 : UsdAPISchemaBase(schemaObj)
94 {
95 }
96
98 USD_API
99 virtual ~UsdModelAPI();
100
104 USD_API
105 static const TfTokenVector &
106 GetSchemaAttributeNames(bool includeInherited=true);
107
117 USD_API
118 static UsdModelAPI
119 Get(const UsdStagePtr &stage, const SdfPath &path);
120
121
122protected:
126 USD_API
128
129private:
130 // needs to invoke _GetStaticTfType.
131 friend class UsdSchemaRegistry;
132 USD_API
133 static const TfType &_GetStaticTfType();
134
135 static bool _IsTypedSchema();
136
137 // override SchemaBase virtuals.
138 USD_API
139 const TfType &_GetTfType() const override;
140
141public:
142 // ===================================================================== //
143 // Feel free to add custom code below this line, it will be preserved by
144 // the code generator.
145 //
146 // Just remember to:
147 // - Close the class declaration with };
148 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
149 // - Close the include guard with #endif
150 // ===================================================================== //
151 // --(BEGIN CUSTOM CODE)--
152
156
162 KindValidationNone,
163 KindValidationModelHierarchy
164 };
165
172 USD_API
173 bool GetKind(TfToken* kind) const;
174
179 USD_API
180 bool SetKind(const TfToken& kind) const;
181
197 USD_API
198 bool IsKind(const TfToken& baseKind,
199 KindValidation validation=KindValidationModelHierarchy) const;
200
203 USD_API
204 bool IsModel() const;
205
208 USD_API
209 bool IsGroup() const;
210
212
216
223 USD_API
224 bool GetAssetIdentifier(SdfAssetPath *identifier) const;
225
230 USD_API
231 void SetAssetIdentifier(const SdfAssetPath &identifier) const;
232
238 USD_API
239 bool GetAssetName(std::string *assetName) const;
240
245 USD_API
246 void SetAssetName(const std::string &assetName) const;
247
259 USD_API
260 bool GetAssetVersion(std::string *version) const;
261
266 USD_API
267 void SetAssetVersion(const std::string &version) const;
268
278 USD_API
280 const;
281
287 USD_API
289 const;
290
300 USD_API
301 bool GetAssetInfo(VtDictionary *info) const;
302
306 USD_API
307 void SetAssetInfo(const VtDictionary &info) const;
308
310
311protected:
312
313 template<typename T>
314 bool _GetAssetInfoByKey(const TfToken &key, T *val) const {
315 VtValue vtVal = GetPrim().GetAssetInfoByKey(key);
316 if (!vtVal.IsEmpty() && vtVal.IsHolding<T>()) {
317 *val = vtVal.UncheckedGet<T>();
318 return true;
319 }
320 return false;
321 }
322};
323
338#define USDMODEL_ASSET_INFO_KEYS \
339 (identifier) \
340 (name) \
341 (version) \
342 (payloadAssetDependencies)
343
344TF_DECLARE_PUBLIC_TOKENS(UsdModelAPIAssetInfoKeys, USD_API, USDMODEL_ASSET_INFO_KEYS);
345
346PXR_NAMESPACE_CLOSE_SCOPE
347
348#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:290
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.
UsdModelAPI is an API schema that provides an interface to a prim's model qualities,...
Definition: modelAPI.h:73
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:78
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:161
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:92
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:84
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:134
The base class for all schema types in Usd.
Definition: schemaBase.h:56
UsdPrim GetPrim() const
Return this schema object's held prim.
Definition: schemaBase.h:120
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:228
A map with string keys and VtValue values.
Definition: dictionary.h:60
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
bool IsEmpty() const
Returns true iff this value is empty.
Definition: value.h:1300
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
Definition: value.h:1081
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
Definition: value.h:1121
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:129
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:98
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
#define USDMODEL_ASSET_INFO_KEYS
Definition: modelAPI.h:338