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