HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
limitAPI.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 USDPHYSICS_GENERATED_LIMITAPI_H
8 #define USDPHYSICS_GENERATED_LIMITAPI_H
9 
10 /// \file usdPhysics/limitAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdPhysics/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // PHYSICSLIMITAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdPhysicsLimitAPI
37 ///
38 /// The PhysicsLimitAPI can be applied to a PhysicsJoint and will
39 /// restrict the movement along an axis. PhysicsLimitAPI is a multipleApply
40 /// schema: The PhysicsJoint can be restricted along "transX", "transY",
41 /// "transZ", "rotX", "rotY", "rotZ", "distance". Setting these as a
42 /// multipleApply schema TfToken name will define the degree of freedom the
43 /// PhysicsLimitAPI is applied to. Note that if the low limit is higher than
44 /// the high limit, motion along this axis is considered locked.
45 ///
47 {
48 public:
49  /// Compile time constant representing what kind of schema this class is.
50  ///
51  /// \sa UsdSchemaKind
53 
54  /// Construct a UsdPhysicsLimitAPI on UsdPrim \p prim with
55  /// name \p name . Equivalent to
56  /// UsdPhysicsLimitAPI::Get(
57  /// prim.GetStage(),
58  /// prim.GetPath().AppendProperty(
59  /// "limit:name"));
60  ///
61  /// for a \em valid \p prim, but will not immediately throw an error for
62  /// an invalid \p prim
64  const UsdPrim& prim=UsdPrim(), const TfToken &name=TfToken())
65  : UsdAPISchemaBase(prim, /*instanceName*/ name)
66  { }
67 
68  /// Construct a UsdPhysicsLimitAPI on the prim held by \p schemaObj with
69  /// name \p name. Should be preferred over
70  /// UsdPhysicsLimitAPI(schemaObj.GetPrim(), name), as it preserves
71  /// SchemaBase state.
73  const UsdSchemaBase& schemaObj, const TfToken &name)
74  : UsdAPISchemaBase(schemaObj, /*instanceName*/ name)
75  { }
76 
77  /// Destructor.
79  virtual ~UsdPhysicsLimitAPI();
80 
81  /// Return a vector of names of all pre-declared attributes for this schema
82  /// class and all its ancestor classes. Does not include attributes that
83  /// may be authored by custom/extended methods of the schemas involved.
85  static const TfTokenVector &
86  GetSchemaAttributeNames(bool includeInherited=true);
87 
88  /// Return a vector of names of all pre-declared attributes for this schema
89  /// class and all its ancestor classes for a given instance name. Does not
90  /// include attributes that may be authored by custom/extended methods of
91  /// the schemas involved. The names returned will have the proper namespace
92  /// prefix.
94  static TfTokenVector
95  GetSchemaAttributeNames(bool includeInherited, const TfToken &instanceName);
96 
97  /// Returns the name of this multiple-apply schema instance
98  TfToken GetName() const {
99  return _GetInstanceName();
100  }
101 
102  /// Return a UsdPhysicsLimitAPI holding the prim adhering to this
103  /// schema at \p path on \p stage. If no prim exists at \p path on
104  /// \p stage, or if the prim at that path does not adhere to this schema,
105  /// return an invalid schema object. \p path must be of the format
106  /// <path>.limit:name .
107  ///
108  /// This is shorthand for the following:
109  ///
110  /// \code
111  /// TfToken name = SdfPath::StripNamespace(path.GetToken());
112  /// UsdPhysicsLimitAPI(
113  /// stage->GetPrimAtPath(path.GetPrimPath()), name);
114  /// \endcode
115  ///
117  static UsdPhysicsLimitAPI
118  Get(const UsdStagePtr &stage, const SdfPath &path);
119 
120  /// Return a UsdPhysicsLimitAPI with name \p name holding the
121  /// prim \p prim. Shorthand for UsdPhysicsLimitAPI(prim, name);
123  static UsdPhysicsLimitAPI
124  Get(const UsdPrim &prim, const TfToken &name);
125 
126  /// Return a vector of all named instances of UsdPhysicsLimitAPI on the
127  /// given \p prim.
129  static std::vector<UsdPhysicsLimitAPI>
130  GetAll(const UsdPrim &prim);
131 
132  /// Checks if the given name \p baseName is the base name of a property
133  /// of PhysicsLimitAPI.
135  static bool
136  IsSchemaPropertyBaseName(const TfToken &baseName);
137 
138  /// Checks if the given path \p path is of an API schema of type
139  /// PhysicsLimitAPI. If so, it stores the instance name of
140  /// the schema in \p name and returns true. Otherwise, it returns false.
142  static bool
144 
145  /// Returns true if this <b>multiple-apply</b> API schema can be applied,
146  /// with the given instance name, \p name, to the given \p prim. If this
147  /// schema can not be a applied the prim, this returns false and, if
148  /// provided, populates \p whyNot with the reason it can not be applied.
149  ///
150  /// Note that if CanApply returns false, that does not necessarily imply
151  /// that calling Apply will fail. Callers are expected to call CanApply
152  /// before calling Apply if they want to ensure that it is valid to
153  /// apply a schema.
154  ///
155  /// \sa UsdPrim::GetAppliedSchemas()
156  /// \sa UsdPrim::HasAPI()
157  /// \sa UsdPrim::CanApplyAPI()
158  /// \sa UsdPrim::ApplyAPI()
159  /// \sa UsdPrim::RemoveAPI()
160  ///
162  static bool
163  CanApply(const UsdPrim &prim, const TfToken &name,
164  std::string *whyNot=nullptr);
165 
166  /// Applies this <b>multiple-apply</b> API schema to the given \p prim
167  /// along with the given instance name, \p name.
168  ///
169  /// This information is stored by adding "PhysicsLimitAPI:<i>name</i>"
170  /// to the token-valued, listOp metadata \em apiSchemas on the prim.
171  /// For example, if \p name is 'instance1', the token
172  /// 'PhysicsLimitAPI:instance1' is added to 'apiSchemas'.
173  ///
174  /// \return A valid UsdPhysicsLimitAPI object is returned upon success.
175  /// An invalid (or empty) UsdPhysicsLimitAPI object is returned upon
176  /// failure. See \ref UsdPrim::ApplyAPI() for
177  /// conditions resulting in failure.
178  ///
179  /// \sa UsdPrim::GetAppliedSchemas()
180  /// \sa UsdPrim::HasAPI()
181  /// \sa UsdPrim::CanApplyAPI()
182  /// \sa UsdPrim::ApplyAPI()
183  /// \sa UsdPrim::RemoveAPI()
184  ///
186  static UsdPhysicsLimitAPI
187  Apply(const UsdPrim &prim, const TfToken &name);
188 
189 protected:
190  /// Returns the kind of schema this class belongs to.
191  ///
192  /// \sa UsdSchemaKind
194  UsdSchemaKind _GetSchemaKind() const override;
195 
196 private:
197  // needs to invoke _GetStaticTfType.
198  friend class UsdSchemaRegistry;
200  static const TfType &_GetStaticTfType();
201 
202  static bool _IsTypedSchema();
203 
204  // override SchemaBase virtuals.
206  const TfType &_GetTfType() const override;
207 
208 public:
209  // --------------------------------------------------------------------- //
210  // LOW
211  // --------------------------------------------------------------------- //
212  /// Lower limit. Units: degrees or distance depending on trans or
213  /// rot axis applied to. -inf means not limited in negative direction.
214  ///
215  /// | ||
216  /// | -- | -- |
217  /// | Declaration | `float physics:low = -inf` |
218  /// | C++ Type | float |
219  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
221  UsdAttribute GetLowAttr() const;
222 
223  /// See GetLowAttr(), and also
224  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
225  /// If specified, author \p defaultValue as the attribute's default,
226  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
227  /// the default for \p writeSparsely is \c false.
229  UsdAttribute CreateLowAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
230 
231 public:
232  // --------------------------------------------------------------------- //
233  // HIGH
234  // --------------------------------------------------------------------- //
235  /// Upper limit. Units: degrees or distance depending on trans or
236  /// rot axis applied to. inf means not limited in positive direction.
237  ///
238  /// | ||
239  /// | -- | -- |
240  /// | Declaration | `float physics:high = inf` |
241  /// | C++ Type | float |
242  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
244  UsdAttribute GetHighAttr() const;
245 
246  /// See GetHighAttr(), and also
247  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
248  /// If specified, author \p defaultValue as the attribute's default,
249  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
250  /// the default for \p writeSparsely is \c false.
252  UsdAttribute CreateHighAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
253 
254 public:
255  // ===================================================================== //
256  // Feel free to add custom code below this line, it will be preserved by
257  // the code generator.
258  //
259  // Just remember to:
260  // - Close the class declaration with };
261  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
262  // - Close the include guard with #endif
263  // ===================================================================== //
264  // --(BEGIN CUSTOM CODE)--
265 };
266 
268 
269 #endif
static USDPHYSICS_API UsdPhysicsLimitAPI Apply(const UsdPrim &prim, const TfToken &name)
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDPHYSICS_API UsdAttribute GetHighAttr() const
static USDPHYSICS_API std::vector< UsdPhysicsLimitAPI > GetAll(const UsdPrim &prim)
USDPHYSICS_API UsdAttribute GetLowAttr() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDPHYSICS_API UsdPhysicsLimitAPI Get(const UsdStagePtr &stage, const SdfPath &path)
static USDPHYSICS_API bool IsPhysicsLimitAPIPath(const SdfPath &path, TfToken *name)
const TfToken & _GetInstanceName() const
Definition: token.h:70
USDPHYSICS_API UsdAttribute CreateHighAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDPHYSICS_API bool IsSchemaPropertyBaseName(const TfToken &baseName)
Definition: prim.h:116
UsdPhysicsLimitAPI(const UsdSchemaBase &schemaObj, const TfToken &name)
Definition: limitAPI.h:72
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
static const UsdSchemaKind schemaKind
Definition: limitAPI.h:52
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: path.h:273
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
#define USDPHYSICS_API
Definition: api.h:23
TfToken GetName() const
Returns the name of this multiple-apply schema instance.
Definition: limitAPI.h:98
UsdPhysicsLimitAPI(const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
Definition: limitAPI.h:63
UsdSchemaKind
Definition: common.h:112
virtual USDPHYSICS_API ~UsdPhysicsLimitAPI()
Destructor.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDPHYSICS_API UsdAttribute CreateLowAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:146
Multiple Apply API Schema.