rigidBodyAPI.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_RIGIDBODYAPI_H
25 #define USDPHYSICS_GENERATED_RIGIDBODYAPI_H
26 
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/gf/matrix3f.h"
37 #include "pxr/base/gf/quatf.h"
38 
39 #include "pxr/base/vt/value.h"
40 
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/matrix4d.h"
44 
45 #include "pxr/base/tf/token.h"
46 #include "pxr/base/tf/type.h"
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 class SdfAssetPath;
51 
52 // -------------------------------------------------------------------------- //
53 // PHYSICSRIGIDBODYAPI //
54 // -------------------------------------------------------------------------- //
55 
64 {
65 public:
70 
75  explicit UsdPhysicsRigidBodyAPI(const UsdPrim& prim=UsdPrim())
76  : UsdAPISchemaBase(prim)
77  {
78  }
79 
83  explicit UsdPhysicsRigidBodyAPI(const UsdSchemaBase& schemaObj)
84  : UsdAPISchemaBase(schemaObj)
85  {
86  }
87 
89  USDPHYSICS_API
90  virtual ~UsdPhysicsRigidBodyAPI();
91 
95  USDPHYSICS_API
96  static const TfTokenVector &
97  GetSchemaAttributeNames(bool includeInherited=true);
98 
108  USDPHYSICS_API
110  Get(const UsdStagePtr &stage, const SdfPath &path);
111 
112 
129  USDPHYSICS_API
130  static bool
131  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
132 
148  USDPHYSICS_API
149  static UsdPhysicsRigidBodyAPI
150  Apply(const UsdPrim &prim);
151 
152 protected:
156  USDPHYSICS_API
157  UsdSchemaKind _GetSchemaKind() const override;
158 
159 private:
160  // needs to invoke _GetStaticTfType.
161  friend class UsdSchemaRegistry;
162  USDPHYSICS_API
163  static const TfType &_GetStaticTfType();
164 
165  static bool _IsTypedSchema();
166 
167  // override SchemaBase virtuals.
168  USDPHYSICS_API
169  const TfType &_GetTfType() const override;
170 
171 public:
172  // --------------------------------------------------------------------- //
173  // RIGIDBODYENABLED
174  // --------------------------------------------------------------------- //
182  USDPHYSICS_API
184 
190  USDPHYSICS_API
191  UsdAttribute CreateRigidBodyEnabledAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
192 
193 public:
194  // --------------------------------------------------------------------- //
195  // KINEMATICENABLED
196  // --------------------------------------------------------------------- //
208  USDPHYSICS_API
210 
216  USDPHYSICS_API
217  UsdAttribute CreateKinematicEnabledAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
218 
219 public:
220  // --------------------------------------------------------------------- //
221  // STARTSASLEEP
222  // --------------------------------------------------------------------- //
231  USDPHYSICS_API
233 
239  USDPHYSICS_API
240  UsdAttribute CreateStartsAsleepAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
241 
242 public:
243  // --------------------------------------------------------------------- //
244  // VELOCITY
245  // --------------------------------------------------------------------- //
254  USDPHYSICS_API
256 
262  USDPHYSICS_API
263  UsdAttribute CreateVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
264 
265 public:
266  // --------------------------------------------------------------------- //
267  // ANGULARVELOCITY
268  // --------------------------------------------------------------------- //
277  USDPHYSICS_API
279 
285  USDPHYSICS_API
286  UsdAttribute CreateAngularVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
287 
288 public:
289  // --------------------------------------------------------------------- //
290  // SIMULATIONOWNER
291  // --------------------------------------------------------------------- //
296  USDPHYSICS_API
298 
301  USDPHYSICS_API
303 
304 public:
305  // ===================================================================== //
306  // Feel free to add custom code below this line, it will be preserved by
307  // the code generator.
308  //
309  // Just remember to:
310  // - Close the class declaration with };
311  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
312  // - Close the include guard with #endif
313  // ===================================================================== //
314  // --(BEGIN CUSTOM CODE)--
315 
318  {
319  float volume; //< Collision volume
320  GfMatrix3f inertia; //< Collision inertia
321  GfVec3f centerOfMass; //< Collision center of mass
322  GfVec3f localPos; //< Collision local position with respect to the rigid body
323  GfQuatf localRot; //< Collision local rotation with respect to the rigid body
324  };
325 
328  typedef std::function<MassInformationFnSig> MassInformationFn;
329 
336  USDPHYSICS_API
337  float ComputeMassProperties(GfVec3f* diagonalInertia, GfVec3f* com, GfQuatf* principalAxes,
338  const MassInformationFn& massInfoFn) const;
339 
340 };
341 
342 PXR_NAMESPACE_CLOSE_SCOPE
343 
344 #endif
static USDPHYSICS_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...
Applies physics body attributes to any UsdGeomXformable prim and marks that prim to be driven by a si...
Definition: rigidBodyAPI.h:63
USDPHYSICS_API UsdAttribute CreateKinematicEnabledAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetKinematicEnabledAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: rigidBodyAPI.h:69
USDPHYSICS_API UsdAttribute GetKinematicEnabledAttr() const
Determines whether the body is kinematic or not.
USDPHYSICS_API UsdAttribute GetStartsAsleepAttr() const
Determines if the body is asleep when the simulation starts.
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatf.h:60
USDPHYSICS_API UsdAttribute CreateVelocityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetVelocityAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
virtual USDPHYSICS_API ~UsdPhysicsRigidBodyAPI()
Destructor.
Single Apply API schema.
static USDPHYSICS_API UsdPhysicsRigidBodyAPI Apply(const UsdPrim &prim)
Applies this single-apply API schema to the given prim.
Stores a 3x3 matrix of float elements.
Definition: matrix3f.h:82
static USDPHYSICS_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
Returns true if this single-apply API schema can be applied to the given prim.
USDPHYSICS_API UsdRelationship CreateSimulationOwnerRel() const
See GetSimulationOwnerRel(), and also Create vs Get Property Methods for when to use Get vs Create.
USDPHYSICS_API UsdAttribute CreateAngularVelocityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetAngularVelocityAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDPHYSICS_API float ComputeMassProperties(GfVec3f *diagonalInertia, GfVec3f *com, GfQuatf *principalAxes, const MassInformationFn &massInfoFn) const
Compute mass properties of the rigid body diagonalInertia Computed diagonal of the inertial tensor fo...
USDPHYSICS_API UsdAttribute GetVelocityAttr() const
Linear velocity in the same space as the node's xform.
UsdPhysicsRigidBodyAPI(const UsdSchemaBase &schemaObj)
Construct a UsdPhysicsRigidBodyAPI on the prim held by schemaObj .
Definition: rigidBodyAPI.h:83
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
USDPHYSICS_API UsdAttribute GetAngularVelocityAttr() const
Angular velocity in the same space as the node's xform.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
static USDPHYSICS_API UsdPhysicsRigidBodyAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdPhysicsRigidBodyAPI holding the prim adhering to this schema at path on stage.
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
MassInformation MassInformationFnSig(const UsdPrim &)
Mass information function signature, for given UsdPrim gather MassInformation.
Definition: rigidBodyAPI.h:327
USDPHYSICS_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
USDPHYSICS_API UsdAttribute CreateStartsAsleepAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetStartsAsleepAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
UsdPhysicsRigidBodyAPI(const UsdPrim &prim=UsdPrim())
Construct a UsdPhysicsRigidBodyAPI on UsdPrim prim .
Definition: rigidBodyAPI.h:75
USDPHYSICS_API UsdAttribute GetRigidBodyEnabledAttr() const
Determines if this PhysicsRigidBodyAPI is enabled.
TfType represents a dynamic runtime type.
Definition: type.h:64
USDPHYSICS_API UsdAttribute CreateRigidBodyEnabledAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetRigidBodyEnabledAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDPHYSICS_API UsdRelationship GetSimulationOwnerRel() const
Single PhysicsScene that will simulate this body.
Singleton registry that provides access to schema type information and the prim definitions for regis...
Mass information for a collision, used in ComputeMassProperties MassInformationFn callback.
Definition: rigidBodyAPI.h:317
The base class for all schema types in Usd.
Definition: schemaBase.h:56
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...