| 1 | /* |
| 2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
| 5 | * and proprietary rights in and to this software, related documentation |
| 6 | * and any modifications thereto. Any use, reproduction, disclosure or |
| 7 | * distribution of this software and related documentation without an express |
| 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
| 9 | */ |
| 10 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
| 11 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
| 12 | |
| 13 | |
| 14 | #ifndef PX_PHYSICS_EXTENSIONS_SIMPLE_FACTORY_H |
| 15 | #define PX_PHYSICS_EXTENSIONS_SIMPLE_FACTORY_H |
| 16 | /** \addtogroup extensions |
| 17 | @{ |
| 18 | */ |
| 19 | |
| 20 | #include "common/PxPhysXCommonConfig.h" |
| 21 | #include "foundation/PxTransform.h" |
| 22 | #include "foundation/PxPlane.h" |
| 23 | |
| 24 | #ifndef PX_DOXYGEN |
| 25 | namespace physx |
| 26 | { |
| 27 | #endif |
| 28 | |
| 29 | class PxPhysics; |
| 30 | class PxMaterial; |
| 31 | class PxRigidActor; |
| 32 | class PxRigidDynamic; |
| 33 | class PxRigidStatic; |
| 34 | class PxGeometry; |
| 35 | class PxShape; |
| 36 | |
| 37 | |
| 38 | /** \brief simple method to create a PxRigidDynamic actor with a single PxShape. |
| 39 | |
| 40 | \param[in] sdk the PxPhysics object |
| 41 | \param[in] transform the global pose of the new object |
| 42 | \param[in] geometry the geometry of the new object's shape, which must be a sphere, capsule, box or convex |
| 43 | \param[in] material the material for the new object's shape |
| 44 | \param[in] density the density of the new object. Must be greater than zero. |
| 45 | \param[in] shapeOffset an optional offset for the new shape, defaults to identity |
| 46 | |
| 47 | \return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could |
| 48 | not be constructed |
| 49 | |
| 50 | @see PxRigidDynamic PxShapeFlag |
| 51 | */ |
| 52 | |
| 53 | PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk, |
| 54 | const PxTransform& transform, |
| 55 | const PxGeometry& geometry, |
| 56 | PxMaterial& material, |
| 57 | PxReal density, |
| 58 | const PxTransform& shapeOffset = PxTransform(PxIdentity)); |
| 59 | |
| 60 | |
| 61 | /** \brief simple method to create a PxRigidDynamic actor with a single PxShape. |
| 62 | |
| 63 | \param[in] sdk the PxPhysics object |
| 64 | \param[in] transform the transform of the new object |
| 65 | \param[in] shape the shape of the new object |
| 66 | \param[in] density the density of the new object. Must be greater than zero. |
| 67 | |
| 68 | \return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could |
| 69 | not be constructed |
| 70 | |
| 71 | @see PxRigidDynamic PxShapeFlag |
| 72 | */ |
| 73 | |
| 74 | PxRigidDynamic* PxCreateDynamic(PxPhysics& sdk, |
| 75 | const PxTransform& transform, |
| 76 | PxShape& shape, |
| 77 | PxReal density); |
| 78 | |
| 79 | |
| 80 | /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape. |
| 81 | |
| 82 | \param[in] sdk the PxPhysics object |
| 83 | \param[in] transform the global pose of the new object |
| 84 | \param[in] geometry the geometry of the new object's shape |
| 85 | \param[in] material the material for the new object's shape |
| 86 | \param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. |
| 87 | \param[in] shapeOffset an optional offset for the new shape, defaults to identity |
| 88 | |
| 89 | \note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However, |
| 90 | kinematics of other geometry types may not participate in simulation collision and may be used only for |
| 91 | triggers or scene queries of moving objects under animation control. In this case the density parameter |
| 92 | will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) |
| 93 | |
| 94 | \return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could |
| 95 | not be constructed |
| 96 | |
| 97 | @see PxRigidDynamic PxShapeFlag |
| 98 | */ |
| 99 | |
| 100 | PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk, |
| 101 | const PxTransform& transform, |
| 102 | const PxGeometry& geometry, |
| 103 | PxMaterial& material, |
| 104 | PxReal density, |
| 105 | const PxTransform& shapeOffset = PxTransform(PxIdentity)); |
| 106 | |
| 107 | |
| 108 | /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape. |
| 109 | |
| 110 | \param[in] sdk the PxPhysics object |
| 111 | \param[in] transform the global pose of the new object |
| 112 | \param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. |
| 113 | \param[in] shape the shape of the new object |
| 114 | |
| 115 | \note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However, |
| 116 | kinematics of other geometry types may not participate in simulation collision and may be used only for |
| 117 | triggers or scene queries of moving objects under animation control. In this case the density parameter |
| 118 | will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) |
| 119 | |
| 120 | \return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could |
| 121 | not be constructed |
| 122 | |
| 123 | @see PxRigidDynamic PxShapeFlag |
| 124 | */ |
| 125 | |
| 126 | PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk, |
| 127 | const PxTransform& transform, |
| 128 | PxShape& shape, |
| 129 | PxReal density); |
| 130 | |
| 131 | |
| 132 | /** \brief simple method to create a PxRigidStatic actor with a single PxShape. |
| 133 | |
| 134 | \param[in] sdk the PxPhysics object |
| 135 | \param[in] transform the global pose of the new object |
| 136 | \param[in] geometry the geometry of the new object's shape |
| 137 | \param[in] material the material for the new object's shape |
| 138 | \param[in] shapeOffset an optional offset for the new shape, defaults to identity |
| 139 | |
| 140 | \return a new static actor, or NULL if it could not be constructed |
| 141 | |
| 142 | @see PxRigidStatic |
| 143 | */ |
| 144 | |
| 145 | PxRigidStatic* PxCreateStatic(PxPhysics& sdk, |
| 146 | const PxTransform& transform, |
| 147 | const PxGeometry& geometry, |
| 148 | PxMaterial& material, |
| 149 | const PxTransform& shapeOffset = PxTransform(PxIdentity)); |
| 150 | |
| 151 | |
| 152 | /** \brief simple method to create a PxRigidStatic actor with a single PxShape. |
| 153 | |
| 154 | \param[in] sdk the PxPhysics object |
| 155 | \param[in] transform the global pose of the new object |
| 156 | \param[in] shape the new object's shape |
| 157 | |
| 158 | \return a new static actor, or NULL if it could not be constructed |
| 159 | |
| 160 | @see PxRigidStatic |
| 161 | */ |
| 162 | |
| 163 | PxRigidStatic* PxCreateStatic(PxPhysics& sdk, |
| 164 | const PxTransform& transform, |
| 165 | PxShape& shape); |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | \brief create a static body by copying attributes from another rigid actor |
| 170 | |
| 171 | The function clones a PxRigidDynamic as a PxRigidStatic. A uniform scale is applied. The following properties are copied: |
| 172 | - shapes |
| 173 | - actor flags |
| 174 | - owner client and client behavior bits |
| 175 | |
| 176 | The following are not copied and retain their default values: |
| 177 | - name |
| 178 | - joints or observers |
| 179 | - aggregate or scene membership |
| 180 | - user data |
| 181 | |
| 182 | \note Transforms are not copied with bit-exact accuracy. |
| 183 | |
| 184 | \param[in] physicsSDK - the physics SDK used to allocate the rigid static |
| 185 | \param[in] actor the rigid actor from which to take the attributes. |
| 186 | \param[in] transform the transform of the new static. |
| 187 | |
| 188 | \return the newly-created rigid static |
| 189 | |
| 190 | */ |
| 191 | |
| 192 | PxRigidStatic* PxCloneStatic(PxPhysics& physicsSDK, |
| 193 | const PxTransform& transform, |
| 194 | const PxRigidActor& actor); |
| 195 | |
| 196 | |
| 197 | /** |
| 198 | \brief create a dynamic body by copying attributes from an existing body |
| 199 | |
| 200 | The following properties are copied: |
| 201 | - shapes |
| 202 | - actor flags and rigidDynamic flags |
| 203 | - mass, moment of inertia, and center of mass frame |
| 204 | - linear and angular velocity |
| 205 | - linear and angular damping |
| 206 | - maximum angular velocity |
| 207 | - position and velocity solver iterations |
| 208 | - sleep threshold |
| 209 | - contact report threshold |
| 210 | - dominance group |
| 211 | - owner client and client behavior bits |
| 212 | |
| 213 | The following are not copied and retain their default values: |
| 214 | - name |
| 215 | - joints or observers |
| 216 | - aggregate or scene membership |
| 217 | - sleep timer |
| 218 | - user data |
| 219 | |
| 220 | \note Transforms are not copied with bit-exact accuracy. |
| 221 | |
| 222 | \param[in] physicsSDK PxPhysics - the physics SDK used to allocate the rigid static |
| 223 | \param[in] body the rigid dynamic to clone. |
| 224 | \param[in] transform the transform of the new dynamic |
| 225 | |
| 226 | \return the newly-created rigid static |
| 227 | |
| 228 | */ |
| 229 | |
| 230 | PxRigidDynamic* PxCloneDynamic(PxPhysics& physicsSDK, |
| 231 | const PxTransform& transform, |
| 232 | const PxRigidDynamic& body); |
| 233 | |
| 234 | |
| 235 | /** \brief create a plane actor. The plane equation is n.x + d = 0 |
| 236 | |
| 237 | \param[in] sdk the PxPhysics object |
| 238 | \param[in] plane a plane of the form n.x + d = 0 |
| 239 | \param[in] material the material for the new object's shape |
| 240 | |
| 241 | \return a new static actor, or NULL if it could not be constructed |
| 242 | |
| 243 | @see PxRigidStatic |
| 244 | */ |
| 245 | |
| 246 | PxRigidStatic* PxCreatePlane(PxPhysics& sdk, |
| 247 | const PxPlane& plane, |
| 248 | PxMaterial& material); |
| 249 | |
| 250 | |
| 251 | /** |
| 252 | \brief scale a rigid actor by a uniform scale |
| 253 | |
| 254 | The geometry and relative positions of the actor are multiplied by the given scale value. If the actor is a rigid body or an |
| 255 | articulation link and the scaleMassProps value is true, the mass properties are scaled assuming the density is constant: the |
| 256 | center of mass is linearly scaled, the mass is multiplied by the cube of the scale, and the inertia tensor by the fifth power of the scale. |
| 257 | |
| 258 | \param[in] actor a rigid actor |
| 259 | \param[in] scale the scale by which to multiply the actor |
| 260 | \param[in] scaleMassProps whether to scale the mass properties |
| 261 | */ |
| 262 | |
| 263 | void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps = true); |
| 264 | |
| 265 | |
| 266 | #ifndef PX_DOXYGEN |
| 267 | } // namespace physx |
| 268 | #endif |
| 269 | |
| 270 | /** @} */ |
| 271 | #endif |
| 272 | |