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 27 /// \file usdPhysics/rigidBodyAPI.h 28 29 #include "pxr/pxr.h" 30 #include "pxr/usd/usdPhysics/api.h" 31 #include "pxr/usd/usd/apiSchemaBase.h" 32 #include "pxr/usd/usd/prim.h" 33 #include "pxr/usd/usd/stage.h" 34 #include "pxr/usd/usdPhysics/tokens.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 45 PXR_NAMESPACE_OPEN_SCOPE 46 47 class SdfAssetPath; 48 49 // -------------------------------------------------------------------------- // 50 // PHYSICSRIGIDBODYAPI // 51 // -------------------------------------------------------------------------- // 52 53 /// \class UsdPhysicsRigidBodyAPI 54 /// 55 /// Applies physics body attributes to any UsdGeomXformable prim and 56 /// marks that prim to be driven by a simulation. If a simulation is running 57 /// it will update this prim's pose. All prims in the hierarchy below this 58 /// prim should move accordingly. 59 /// 60 class UsdPhysicsRigidBodyAPI : public UsdAPISchemaBase 61 { 62 public: 63 /// Compile time constant representing what kind of schema this class is. 64 /// 65 /// \sa UsdSchemaKind 66 static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI; 67 68 /// Construct a UsdPhysicsRigidBodyAPI on UsdPrim \p prim . 69 /// Equivalent to UsdPhysicsRigidBodyAPI::Get(prim.GetStage(), prim.GetPath()) 70 /// for a \em valid \p prim, but will not immediately throw an error for 71 /// an invalid \p prim 72 explicit UsdPhysicsRigidBodyAPI(const UsdPrim& prim=UsdPrim()) UsdAPISchemaBase(prim)73 : UsdAPISchemaBase(prim) 74 { 75 } 76 77 /// Construct a UsdPhysicsRigidBodyAPI on the prim held by \p schemaObj . 78 /// Should be preferred over UsdPhysicsRigidBodyAPI(schemaObj.GetPrim()), 79 /// as it preserves SchemaBase state. UsdPhysicsRigidBodyAPI(const UsdSchemaBase & schemaObj)80 explicit UsdPhysicsRigidBodyAPI(const UsdSchemaBase& schemaObj) 81 : UsdAPISchemaBase(schemaObj) 82 { 83 } 84 85 /// Destructor. 86 USDPHYSICS_API 87 virtual ~UsdPhysicsRigidBodyAPI(); 88 89 /// Return a vector of names of all pre-declared attributes for this schema 90 /// class and all its ancestor classes. Does not include attributes that 91 /// may be authored by custom/extended methods of the schemas involved. 92 USDPHYSICS_API 93 static const TfTokenVector & 94 GetSchemaAttributeNames(bool includeInherited=true); 95 96 /// Return a UsdPhysicsRigidBodyAPI holding the prim adhering to this 97 /// schema at \p path on \p stage. If no prim exists at \p path on 98 /// \p stage, or if the prim at that path does not adhere to this schema, 99 /// return an invalid schema object. This is shorthand for the following: 100 /// 101 /// \code 102 /// UsdPhysicsRigidBodyAPI(stage->GetPrimAtPath(path)); 103 /// \endcode 104 /// 105 USDPHYSICS_API 106 static UsdPhysicsRigidBodyAPI 107 Get(const UsdStagePtr &stage, const SdfPath &path); 108 109 110 /// Returns true if this <b>single-apply</b> API schema can be applied to 111 /// the given \p prim. If this schema can not be a applied to the prim, 112 /// this returns false and, if provided, populates \p whyNot with the 113 /// reason it can not be applied. 114 /// 115 /// Note that if CanApply returns false, that does not necessarily imply 116 /// that calling Apply will fail. Callers are expected to call CanApply 117 /// before calling Apply if they want to ensure that it is valid to 118 /// apply a schema. 119 /// 120 /// \sa UsdPrim::GetAppliedSchemas() 121 /// \sa UsdPrim::HasAPI() 122 /// \sa UsdPrim::CanApplyAPI() 123 /// \sa UsdPrim::ApplyAPI() 124 /// \sa UsdPrim::RemoveAPI() 125 /// 126 USDPHYSICS_API 127 static bool 128 CanApply(const UsdPrim &prim, std::string *whyNot=nullptr); 129 130 /// Applies this <b>single-apply</b> API schema to the given \p prim. 131 /// This information is stored by adding "PhysicsRigidBodyAPI" to the 132 /// token-valued, listOp metadata \em apiSchemas on the prim. 133 /// 134 /// \return A valid UsdPhysicsRigidBodyAPI object is returned upon success. 135 /// An invalid (or empty) UsdPhysicsRigidBodyAPI object is returned upon 136 /// failure. See \ref UsdPrim::ApplyAPI() for conditions 137 /// resulting in failure. 138 /// 139 /// \sa UsdPrim::GetAppliedSchemas() 140 /// \sa UsdPrim::HasAPI() 141 /// \sa UsdPrim::CanApplyAPI() 142 /// \sa UsdPrim::ApplyAPI() 143 /// \sa UsdPrim::RemoveAPI() 144 /// 145 USDPHYSICS_API 146 static UsdPhysicsRigidBodyAPI 147 Apply(const UsdPrim &prim); 148 149 protected: 150 /// Returns the kind of schema this class belongs to. 151 /// 152 /// \sa UsdSchemaKind 153 USDPHYSICS_API 154 UsdSchemaKind _GetSchemaKind() const override; 155 156 private: 157 // needs to invoke _GetStaticTfType. 158 friend class UsdSchemaRegistry; 159 USDPHYSICS_API 160 static const TfType &_GetStaticTfType(); 161 162 static bool _IsTypedSchema(); 163 164 // override SchemaBase virtuals. 165 USDPHYSICS_API 166 const TfType &_GetTfType() const override; 167 168 public: 169 // --------------------------------------------------------------------- // 170 // RIGIDBODYENABLED 171 // --------------------------------------------------------------------- // 172 /// Determines if this PhysicsRigidBodyAPI is enabled. 173 /// 174 /// | || 175 /// | -- | -- | 176 /// | Declaration | `bool physics:rigidBodyEnabled = 1` | 177 /// | C++ Type | bool | 178 /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool | 179 USDPHYSICS_API 180 UsdAttribute GetRigidBodyEnabledAttr() const; 181 182 /// See GetRigidBodyEnabledAttr(), and also 183 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. 184 /// If specified, author \p defaultValue as the attribute's default, 185 /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - 186 /// the default for \p writeSparsely is \c false. 187 USDPHYSICS_API 188 UsdAttribute CreateRigidBodyEnabledAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; 189 190 public: 191 // --------------------------------------------------------------------- // 192 // KINEMATICENABLED 193 // --------------------------------------------------------------------- // 194 /// Determines whether the body is kinematic or not. A kinematic 195 /// body is a body that is moved through animated poses or through 196 /// user defined poses. The simulation derives velocities for the 197 /// kinematic body based on the external motion. When a continuous motion 198 /// is not desired, this kinematic flag should be set to false. 199 /// 200 /// | || 201 /// | -- | -- | 202 /// | Declaration | `bool physics:kinematicEnabled = 0` | 203 /// | C++ Type | bool | 204 /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool | 205 USDPHYSICS_API 206 UsdAttribute GetKinematicEnabledAttr() const; 207 208 /// See GetKinematicEnabledAttr(), and also 209 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. 210 /// If specified, author \p defaultValue as the attribute's default, 211 /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - 212 /// the default for \p writeSparsely is \c false. 213 USDPHYSICS_API 214 UsdAttribute CreateKinematicEnabledAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; 215 216 public: 217 // --------------------------------------------------------------------- // 218 // STARTSASLEEP 219 // --------------------------------------------------------------------- // 220 /// Determines if the body is asleep when the simulation starts. 221 /// 222 /// | || 223 /// | -- | -- | 224 /// | Declaration | `uniform bool physics:startsAsleep = 0` | 225 /// | C++ Type | bool | 226 /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool | 227 /// | \ref SdfVariability "Variability" | SdfVariabilityUniform | 228 USDPHYSICS_API 229 UsdAttribute GetStartsAsleepAttr() const; 230 231 /// See GetStartsAsleepAttr(), and also 232 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. 233 /// If specified, author \p defaultValue as the attribute's default, 234 /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - 235 /// the default for \p writeSparsely is \c false. 236 USDPHYSICS_API 237 UsdAttribute CreateStartsAsleepAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; 238 239 public: 240 // --------------------------------------------------------------------- // 241 // VELOCITY 242 // --------------------------------------------------------------------- // 243 /// Linear velocity in the same space as the node's xform. 244 /// Units: distance/second. 245 /// 246 /// | || 247 /// | -- | -- | 248 /// | Declaration | `vector3f physics:velocity = (0, 0, 0)` | 249 /// | C++ Type | GfVec3f | 250 /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3f | 251 USDPHYSICS_API 252 UsdAttribute GetVelocityAttr() const; 253 254 /// See GetVelocityAttr(), and also 255 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. 256 /// If specified, author \p defaultValue as the attribute's default, 257 /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - 258 /// the default for \p writeSparsely is \c false. 259 USDPHYSICS_API 260 UsdAttribute CreateVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; 261 262 public: 263 // --------------------------------------------------------------------- // 264 // ANGULARVELOCITY 265 // --------------------------------------------------------------------- // 266 /// Angular velocity in the same space as the node's xform. 267 /// Units: degrees/second. 268 /// 269 /// | || 270 /// | -- | -- | 271 /// | Declaration | `vector3f physics:angularVelocity = (0, 0, 0)` | 272 /// | C++ Type | GfVec3f | 273 /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3f | 274 USDPHYSICS_API 275 UsdAttribute GetAngularVelocityAttr() const; 276 277 /// See GetAngularVelocityAttr(), and also 278 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create. 279 /// If specified, author \p defaultValue as the attribute's default, 280 /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true - 281 /// the default for \p writeSparsely is \c false. 282 USDPHYSICS_API 283 UsdAttribute CreateAngularVelocityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const; 284 285 public: 286 // --------------------------------------------------------------------- // 287 // SIMULATIONOWNER 288 // --------------------------------------------------------------------- // 289 /// Single PhysicsScene that will simulate this body. By 290 /// default this is the first PhysicsScene found in the stage using 291 /// UsdStage::Traverse(). 292 /// 293 USDPHYSICS_API 294 UsdRelationship GetSimulationOwnerRel() const; 295 296 /// See GetSimulationOwnerRel(), and also 297 /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create 298 USDPHYSICS_API 299 UsdRelationship CreateSimulationOwnerRel() const; 300 301 public: 302 // ===================================================================== // 303 // Feel free to add custom code below this line, it will be preserved by 304 // the code generator. 305 // 306 // Just remember to: 307 // - Close the class declaration with }; 308 // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE 309 // - Close the include guard with #endif 310 // ===================================================================== // 311 // --(BEGIN CUSTOM CODE)-- 312 }; 313 314 PXR_NAMESPACE_CLOSE_SCOPE 315 316 #endif 317