HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
massAPI.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_MASSAPI_H
8 #define USDPHYSICS_GENERATED_MASSAPI_H
9 
10 /// \file usdPhysics/massAPI.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 // PHYSICSMASSAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdPhysicsMassAPI
37 ///
38 /// Defines explicit mass properties (mass, density, inertia etc.).
39 /// MassAPI can be applied to any object that has a PhysicsCollisionAPI or
40 /// a PhysicsRigidBodyAPI.
41 ///
43 {
44 public:
45  /// Compile time constant representing what kind of schema this class is.
46  ///
47  /// \sa UsdSchemaKind
49 
50  /// Construct a UsdPhysicsMassAPI on UsdPrim \p prim .
51  /// Equivalent to UsdPhysicsMassAPI::Get(prim.GetStage(), prim.GetPath())
52  /// for a \em valid \p prim, but will not immediately throw an error for
53  /// an invalid \p prim
54  explicit UsdPhysicsMassAPI(const UsdPrim& prim=UsdPrim())
55  : UsdAPISchemaBase(prim)
56  {
57  }
58 
59  /// Construct a UsdPhysicsMassAPI on the prim held by \p schemaObj .
60  /// Should be preferred over UsdPhysicsMassAPI(schemaObj.GetPrim()),
61  /// as it preserves SchemaBase state.
62  explicit UsdPhysicsMassAPI(const UsdSchemaBase& schemaObj)
63  : UsdAPISchemaBase(schemaObj)
64  {
65  }
66 
67  /// Destructor.
69  virtual ~UsdPhysicsMassAPI();
70 
71  /// Return a vector of names of all pre-declared attributes for this schema
72  /// class and all its ancestor classes. Does not include attributes that
73  /// may be authored by custom/extended methods of the schemas involved.
75  static const TfTokenVector &
76  GetSchemaAttributeNames(bool includeInherited=true);
77 
78  /// Return a UsdPhysicsMassAPI holding the prim adhering to this
79  /// schema at \p path on \p stage. If no prim exists at \p path on
80  /// \p stage, or if the prim at that path does not adhere to this schema,
81  /// return an invalid schema object. This is shorthand for the following:
82  ///
83  /// \code
84  /// UsdPhysicsMassAPI(stage->GetPrimAtPath(path));
85  /// \endcode
86  ///
88  static UsdPhysicsMassAPI
89  Get(const UsdStagePtr &stage, const SdfPath &path);
90 
91 
92  /// Returns true if this <b>single-apply</b> API schema can be applied to
93  /// the given \p prim. If this schema can not be a applied to the prim,
94  /// this returns false and, if provided, populates \p whyNot with the
95  /// reason it can not be applied.
96  ///
97  /// Note that if CanApply returns false, that does not necessarily imply
98  /// that calling Apply will fail. Callers are expected to call CanApply
99  /// before calling Apply if they want to ensure that it is valid to
100  /// apply a schema.
101  ///
102  /// \sa UsdPrim::GetAppliedSchemas()
103  /// \sa UsdPrim::HasAPI()
104  /// \sa UsdPrim::CanApplyAPI()
105  /// \sa UsdPrim::ApplyAPI()
106  /// \sa UsdPrim::RemoveAPI()
107  ///
109  static bool
110  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
111 
112  /// Applies this <b>single-apply</b> API schema to the given \p prim.
113  /// This information is stored by adding "PhysicsMassAPI" to the
114  /// token-valued, listOp metadata \em apiSchemas on the prim.
115  ///
116  /// \return A valid UsdPhysicsMassAPI object is returned upon success.
117  /// An invalid (or empty) UsdPhysicsMassAPI object is returned upon
118  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
119  /// resulting in failure.
120  ///
121  /// \sa UsdPrim::GetAppliedSchemas()
122  /// \sa UsdPrim::HasAPI()
123  /// \sa UsdPrim::CanApplyAPI()
124  /// \sa UsdPrim::ApplyAPI()
125  /// \sa UsdPrim::RemoveAPI()
126  ///
128  static UsdPhysicsMassAPI
129  Apply(const UsdPrim &prim);
130 
131 protected:
132  /// Returns the kind of schema this class belongs to.
133  ///
134  /// \sa UsdSchemaKind
136  UsdSchemaKind _GetSchemaKind() const override;
137 
138 private:
139  // needs to invoke _GetStaticTfType.
140  friend class UsdSchemaRegistry;
142  static const TfType &_GetStaticTfType();
143 
144  static bool _IsTypedSchema();
145 
146  // override SchemaBase virtuals.
148  const TfType &_GetTfType() const override;
149 
150 public:
151  // --------------------------------------------------------------------- //
152  // MASS
153  // --------------------------------------------------------------------- //
154  /// If non-zero, directly specifies the mass of the object.
155  /// Note that any child prim can also have a mass when they apply massAPI.
156  /// In this case, the precedence rule is 'parent mass overrides the
157  /// child's'. This may come as counter-intuitive, but mass is a computed
158  /// quantity and in general not accumulative. For example, if a parent
159  /// has mass of 10, and one of two children has mass of 20, allowing
160  /// child's mass to override its parent results in a mass of -10 for the
161  /// other child. Note if mass is 0.0 it is ignored. Units: mass.
162  ///
163  ///
164  /// | ||
165  /// | -- | -- |
166  /// | Declaration | `float physics:mass = 0` |
167  /// | C++ Type | float |
168  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
170  UsdAttribute GetMassAttr() const;
171 
172  /// See GetMassAttr(), and also
173  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
174  /// If specified, author \p defaultValue as the attribute's default,
175  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
176  /// the default for \p writeSparsely is \c false.
178  UsdAttribute CreateMassAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
179 
180 public:
181  // --------------------------------------------------------------------- //
182  // DENSITY
183  // --------------------------------------------------------------------- //
184  /// If non-zero, specifies the density of the object.
185  /// In the context of rigid body physics, density indirectly results in
186  /// setting mass via (mass = density x volume of the object). How the
187  /// volume is computed is up to implementation of the physics system.
188  /// It is generally computed from the collision approximation rather than
189  /// the graphical mesh. In the case where both density and mass are
190  /// specified for the same object, mass has precedence over density.
191  /// Unlike mass, child's prim's density overrides parent prim's density
192  /// as it is accumulative. Note that density of a collisionAPI can be also
193  /// alternatively set through a PhysicsMaterialAPI. The material density
194  /// has the weakest precedence in density definition. Note if density is
195  /// 0.0 it is ignored. Units: mass/distance/distance/distance.
196  ///
197  /// | ||
198  /// | -- | -- |
199  /// | Declaration | `float physics:density = 0` |
200  /// | C++ Type | float |
201  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
204 
205  /// See GetDensityAttr(), and also
206  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
207  /// If specified, author \p defaultValue as the attribute's default,
208  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
209  /// the default for \p writeSparsely is \c false.
211  UsdAttribute CreateDensityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
212 
213 public:
214  // --------------------------------------------------------------------- //
215  // CENTEROFMASS
216  // --------------------------------------------------------------------- //
217  /// Center of mass in the prim's local space. Units: distance.
218  ///
219  /// | ||
220  /// | -- | -- |
221  /// | Declaration | `point3f physics:centerOfMass = (-inf, -inf, -inf)` |
222  /// | C++ Type | GfVec3f |
223  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Point3f |
226 
227  /// See GetCenterOfMassAttr(), and also
228  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
229  /// If specified, author \p defaultValue as the attribute's default,
230  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
231  /// the default for \p writeSparsely is \c false.
233  UsdAttribute CreateCenterOfMassAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
234 
235 public:
236  // --------------------------------------------------------------------- //
237  // DIAGONALINERTIA
238  // --------------------------------------------------------------------- //
239  /// If non-zero, specifies diagonalized inertia tensor along the
240  /// principal axes. Note if diagonalInertial is (0.0, 0.0, 0.0) it is
241  /// ignored. Units: mass*distance*distance.
242  ///
243  /// | ||
244  /// | -- | -- |
245  /// | Declaration | `float3 physics:diagonalInertia = (0, 0, 0)` |
246  /// | C++ Type | GfVec3f |
247  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3 |
250 
251  /// See GetDiagonalInertiaAttr(), and also
252  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
253  /// If specified, author \p defaultValue as the attribute's default,
254  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
255  /// the default for \p writeSparsely is \c false.
257  UsdAttribute CreateDiagonalInertiaAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
258 
259 public:
260  // --------------------------------------------------------------------- //
261  // PRINCIPALAXES
262  // --------------------------------------------------------------------- //
263  /// Orientation of the inertia tensor's principal axes in the
264  /// prim's local space.
265  ///
266  /// | ||
267  /// | -- | -- |
268  /// | Declaration | `quatf physics:principalAxes = (0, 0, 0, 0)` |
269  /// | C++ Type | GfQuatf |
270  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Quatf |
273 
274  /// See GetPrincipalAxesAttr(), and also
275  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
276  /// If specified, author \p defaultValue as the attribute's default,
277  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
278  /// the default for \p writeSparsely is \c false.
280  UsdAttribute CreatePrincipalAxesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
281 
282 public:
283  // ===================================================================== //
284  // Feel free to add custom code below this line, it will be preserved by
285  // the code generator.
286  //
287  // Just remember to:
288  // - Close the class declaration with };
289  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
290  // - Close the include guard with #endif
291  // ===================================================================== //
292  // --(BEGIN CUSTOM CODE)--
293 
294 };
295 
297 
298 #endif
USDPHYSICS_API UsdAttribute GetDiagonalInertiaAttr() const
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDPHYSICS_API UsdPhysicsMassAPI Get(const UsdStagePtr &stage, const SdfPath &path)
USDPHYSICS_API UsdAttribute CreateDensityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
USDPHYSICS_API UsdAttribute CreateCenterOfMassAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDPHYSICS_API UsdPhysicsMassAPI Apply(const UsdPrim &prim)
USDPHYSICS_API UsdAttribute CreateDiagonalInertiaAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdPhysicsMassAPI(const UsdPrim &prim=UsdPrim())
Definition: massAPI.h:54
USDPHYSICS_API UsdAttribute GetPrincipalAxesAttr() const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static USDPHYSICS_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: path.h:273
USDPHYSICS_API UsdAttribute CreatePrincipalAxesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define USDPHYSICS_API
Definition: api.h:23
virtual USDPHYSICS_API ~UsdPhysicsMassAPI()
Destructor.
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDPHYSICS_API UsdAttribute CreateMassAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDPHYSICS_API UsdAttribute GetMassAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
static const UsdSchemaKind schemaKind
Definition: massAPI.h:48
Definition: value.h:146
USDPHYSICS_API UsdAttribute GetDensityAttr() const
USDPHYSICS_API UsdAttribute GetCenterOfMassAttr() const
UsdPhysicsMassAPI(const UsdSchemaBase &schemaObj)
Definition: massAPI.h:62