| 1 | // | 
| 2 | // Redistribution and use in source and binary forms, with or without | 
| 3 | // modification, are permitted provided that the following conditions | 
| 4 | // are met: | 
| 5 | //  * Redistributions of source code must retain the above copyright | 
| 6 | //    notice, this list of conditions and the following disclaimer. | 
| 7 | //  * Redistributions in binary form must reproduce the above copyright | 
| 8 | //    notice, this list of conditions and the following disclaimer in the | 
| 9 | //    documentation and/or other materials provided with the distribution. | 
| 10 | //  * Neither the name of NVIDIA CORPORATION nor the names of its | 
| 11 | //    contributors may be used to endorse or promote products derived | 
| 12 | //    from this software without specific prior written permission. | 
| 13 | // | 
| 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY | 
| 15 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 16 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
| 17 | // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 
| 18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
| 19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 
| 20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 
| 21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 
| 22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 25 | // | 
| 26 | // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved. | 
| 27 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. | 
| 28 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.   | 
| 29 |  | 
| 30 |  | 
| 31 | #ifndef PX_PHYSICS_EXTENSIONS_SIMPLE_FACTORY_H | 
| 32 | #define PX_PHYSICS_EXTENSIONS_SIMPLE_FACTORY_H | 
| 33 | /** \addtogroup extensions | 
| 34 |   @{ | 
| 35 | */ | 
| 36 |  | 
| 37 | #include "common/PxPhysXCommonConfig.h" | 
| 38 | #include "foundation/PxTransform.h" | 
| 39 | #include "foundation/PxPlane.h" | 
| 40 |  | 
| 41 | #if !PX_DOXYGEN | 
| 42 | namespace physx | 
| 43 | { | 
| 44 | #endif | 
| 45 |  | 
| 46 | 	class PxPhysics; | 
| 47 | 	class PxMaterial; | 
| 48 | 	class PxRigidActor; | 
| 49 | 	class PxRigidDynamic; | 
| 50 | 	class PxRigidStatic; | 
| 51 | 	class PxGeometry; | 
| 52 | 	class PxShape; | 
| 53 |  | 
| 54 |  | 
| 55 | /** \brief simple method to create a PxRigidDynamic actor with a single PxShape.  | 
| 56 |  | 
| 57 | 	\param[in] sdk the PxPhysics object | 
| 58 | 	\param[in] transform the global pose of the new object | 
| 59 | 	\param[in] geometry the geometry of the new object's shape, which must be a sphere, capsule, box or convex | 
| 60 | 	\param[in] material the material for the new object's shape | 
| 61 | 	\param[in] density the density of the new object. Must be greater than zero. | 
| 62 | 	\param[in] shapeOffset an optional offset for the new shape, defaults to identity | 
| 63 |  | 
| 64 | 	\return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could  | 
| 65 | 	not be constructed | 
| 66 |  | 
| 67 | 	@see PxRigidDynamic PxShapeFlag | 
| 68 | */ | 
| 69 |  | 
| 70 | PxRigidDynamic*	PxCreateDynamic(PxPhysics& sdk, | 
| 71 | 								const PxTransform& transform, | 
| 72 | 								const PxGeometry& geometry, | 
| 73 | 								PxMaterial& material, | 
| 74 | 								PxReal density, | 
| 75 | 								const PxTransform& shapeOffset = PxTransform(PxIdentity)); | 
| 76 |  | 
| 77 |  | 
| 78 | /** \brief simple method to create a PxRigidDynamic actor with a single PxShape.  | 
| 79 |  | 
| 80 | 	\param[in] sdk the PxPhysics object | 
| 81 | 	\param[in] transform the transform of the new object | 
| 82 | 	\param[in] shape the shape of the new object | 
| 83 | 	\param[in] density the density of the new object. Must be greater than zero. | 
| 84 |  | 
| 85 | 	\return a new dynamic actor with the PxRigidBodyFlag, or NULL if it could  | 
| 86 | 	not be constructed | 
| 87 |  | 
| 88 | 	@see PxRigidDynamic PxShapeFlag | 
| 89 | */ | 
| 90 |  | 
| 91 | PxRigidDynamic*	PxCreateDynamic(PxPhysics& sdk, | 
| 92 | 								const PxTransform& transform, | 
| 93 | 								PxShape& shape, | 
| 94 | 								PxReal density); | 
| 95 |  | 
| 96 |  | 
| 97 | /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape.  | 
| 98 |  | 
| 99 | 	\param[in] sdk the PxPhysics object | 
| 100 | 	\param[in] transform the global pose of the new object | 
| 101 | 	\param[in] geometry the geometry of the new object's shape | 
| 102 | 	\param[in] material the material for the new object's shape | 
| 103 | 	\param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. | 
| 104 | 	\param[in] shapeOffset an optional offset for the new shape, defaults to identity | 
| 105 |  | 
| 106 | 	\note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However,  | 
| 107 | 	kinematics of other geometry types may not participate in simulation collision and may be used only for | 
| 108 | 	triggers or scene queries of moving objects under animation control. In this case the density parameter | 
| 109 | 	will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) | 
| 110 |  | 
| 111 | 	\return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could  | 
| 112 | 	not be constructed | 
| 113 |  | 
| 114 | 	@see PxRigidDynamic PxShapeFlag | 
| 115 | */ | 
| 116 |  | 
| 117 | PxRigidDynamic*	PxCreateKinematic(PxPhysics& sdk, | 
| 118 | 								  const PxTransform& transform, | 
| 119 | 								  const PxGeometry& geometry, | 
| 120 | 								  PxMaterial& material, | 
| 121 | 								  PxReal density, | 
| 122 | 								  const PxTransform& shapeOffset = PxTransform(PxIdentity)); | 
| 123 |  | 
| 124 |  | 
| 125 | /** \brief simple method to create a kinematic PxRigidDynamic actor with a single PxShape.  | 
| 126 |  | 
| 127 | 	\param[in] sdk the PxPhysics object | 
| 128 | 	\param[in] transform the global pose of the new object | 
| 129 | 	\param[in] density the density of the new object. Must be greater than zero if the object is to participate in simulation. | 
| 130 | 	\param[in] shape the shape of the new object | 
| 131 |  | 
| 132 | 	\note unlike PxCreateDynamic, the geometry is not restricted to box, capsule, sphere or convex. However,  | 
| 133 | 	kinematics of other geometry types may not participate in simulation collision and may be used only for | 
| 134 | 	triggers or scene queries of moving objects under animation control. In this case the density parameter | 
| 135 | 	will be ignored and the created shape will be set up as a scene query only shape (see #PxShapeFlag::eSCENE_QUERY_SHAPE) | 
| 136 |  | 
| 137 | 	\return a new dynamic actor with the PxRigidBodyFlag::eKINEMATIC set, or NULL if it could  | 
| 138 | 	not be constructed | 
| 139 |  | 
| 140 | 	@see PxRigidDynamic PxShapeFlag | 
| 141 | */ | 
| 142 |  | 
| 143 | PxRigidDynamic*	PxCreateKinematic(PxPhysics& sdk, | 
| 144 | 								  const PxTransform& transform, | 
| 145 | 								  PxShape& shape, | 
| 146 | 								  PxReal density); | 
| 147 |  | 
| 148 |  | 
| 149 | /** \brief simple method to create a PxRigidStatic actor with a single PxShape.  | 
| 150 |  | 
| 151 | 	\param[in] sdk the PxPhysics object | 
| 152 | 	\param[in] transform the global pose of the new object | 
| 153 | 	\param[in] geometry the geometry of the new object's shape | 
| 154 | 	\param[in] material the material for the new object's shape | 
| 155 | 	\param[in] shapeOffset an optional offset for the new shape, defaults to identity | 
| 156 |  | 
| 157 | 	\return a new static actor, or NULL if it could not be constructed | 
| 158 |  | 
| 159 | 	@see PxRigidStatic | 
| 160 | */ | 
| 161 |  | 
| 162 | PxRigidStatic*	PxCreateStatic(PxPhysics& sdk, | 
| 163 | 							   const PxTransform& transform, | 
| 164 | 							   const PxGeometry& geometry, | 
| 165 | 							   PxMaterial& material, | 
| 166 | 							   const PxTransform& shapeOffset = PxTransform(PxIdentity)); | 
| 167 |  | 
| 168 |  | 
| 169 | /** \brief simple method to create a PxRigidStatic actor with a single PxShape.  | 
| 170 |  | 
| 171 | 	\param[in] sdk the PxPhysics object | 
| 172 | 	\param[in] transform the global pose of the new object | 
| 173 | 	\param[in] shape the new object's shape | 
| 174 |  | 
| 175 | 	\return a new static actor, or NULL if it could not be constructed | 
| 176 |  | 
| 177 | 	@see PxRigidStatic | 
| 178 | */ | 
| 179 |  | 
| 180 | PxRigidStatic*	PxCreateStatic(PxPhysics& sdk, | 
| 181 | 							   const PxTransform& transform, | 
| 182 | 							   PxShape& shape); | 
| 183 |  | 
| 184 |  | 
| 185 | /** \brief simple method to create a PxRigidStatic actor with a single PxShape.  | 
| 186 |  | 
| 187 | 	\param[in] sdk the PxPhysics object | 
| 188 | 	\param[in] transform the global pose of the new object | 
| 189 | 	\param[in] shape the new object's shape | 
| 190 |  | 
| 191 | 	\return a new static actor, or NULL if it could not be constructed | 
| 192 |  | 
| 193 | 	@see PxRigidStatic | 
| 194 | */ | 
| 195 |  | 
| 196 | PxRigidStatic*	PxCreateStatic(PxPhysics& sdk, | 
| 197 | 							   const PxTransform& transform, | 
| 198 | 							   PxShape& shape); | 
| 199 |  | 
| 200 |  | 
| 201 | /** | 
| 202 | \brief create a shape by copying attributes from another shape | 
| 203 |  | 
| 204 | The function clones a PxShape. The following properties are copied: | 
| 205 | - geometry | 
| 206 | - flags | 
| 207 | - materials | 
| 208 | - actor-local pose | 
| 209 | - contact offset | 
| 210 | - rest offset | 
| 211 | - simulation filter data | 
| 212 | - query filter data | 
| 213 |  | 
| 214 | The following are not copied and retain their default values: | 
| 215 | - name | 
| 216 | - user data | 
| 217 |  | 
| 218 | \param[in] physicsSDK - the physics SDK used to allocate the shape | 
| 219 | \param[in] shape the shape from which to take the attributes. | 
| 220 | \param[in] isExclusive whether the new shape should be an exclusive or shared shape. | 
| 221 |  | 
| 222 | \return the newly-created rigid static | 
| 223 |  | 
| 224 | */ | 
| 225 |  | 
| 226 | PxShape* PxCloneShape(PxPhysics& physicsSDK, | 
| 227 | 					  const PxShape& shape, | 
| 228 | 					  bool isExclusive); | 
| 229 |  | 
| 230 |  | 
| 231 |  | 
| 232 | /** | 
| 233 | \brief create a static body by copying attributes from another rigid actor | 
| 234 |  | 
| 235 | The function clones a PxRigidDynamic or PxRigidStatic as a PxRigidStatic. A uniform scale is applied. The following properties are copied: | 
| 236 | - shapes | 
| 237 | - actor flags  | 
| 238 | - owner client and client behavior bits | 
| 239 |  | 
| 240 | The following are not copied and retain their default values: | 
| 241 | - name | 
| 242 | - joints or observers | 
| 243 | - aggregate or scene membership | 
| 244 | - user data | 
| 245 |  | 
| 246 | \note Transforms are not copied with bit-exact accuracy. | 
| 247 |  | 
| 248 | \param[in] physicsSDK - the physics SDK used to allocate the rigid static | 
| 249 | \param[in] actor the rigid actor from which to take the attributes. | 
| 250 | \param[in] transform the transform of the new static. | 
| 251 |  | 
| 252 | \return the newly-created rigid static | 
| 253 |  | 
| 254 | */ | 
| 255 |  | 
| 256 | PxRigidStatic* PxCloneStatic(PxPhysics& physicsSDK,  | 
| 257 | 							 const PxTransform& transform, | 
| 258 | 							 const PxRigidActor& actor); | 
| 259 |  | 
| 260 |  | 
| 261 | /** | 
| 262 | \brief create a dynamic body by copying attributes from an existing body | 
| 263 |  | 
| 264 | The following properties are copied: | 
| 265 | - shapes | 
| 266 | - actor flags and rigidDynamic flags | 
| 267 | - mass, moment of inertia, and center of mass frame | 
| 268 | - linear and angular velocity | 
| 269 | - linear and angular damping | 
| 270 | - maximum angular velocity | 
| 271 | - position and velocity solver iterations | 
| 272 | - maximum depenetration velocity | 
| 273 | - sleep threshold | 
| 274 | - contact report threshold | 
| 275 | - dominance group | 
| 276 | - owner client and client behavior bits | 
| 277 | - name pointer | 
| 278 |  | 
| 279 | The following are not copied and retain their default values: | 
| 280 | - name | 
| 281 | - joints or observers | 
| 282 | - aggregate or scene membership | 
| 283 | - sleep timer | 
| 284 | - user data | 
| 285 |  | 
| 286 | \note Transforms are not copied with bit-exact accuracy. | 
| 287 |  | 
| 288 | \param[in] physicsSDK PxPhysics - the physics SDK used to allocate the rigid static | 
| 289 | \param[in] body the rigid dynamic to clone. | 
| 290 | \param[in] transform the transform of the new dynamic | 
| 291 |  | 
| 292 | \return the newly-created rigid static | 
| 293 |  | 
| 294 | */ | 
| 295 |  | 
| 296 | PxRigidDynamic*	PxCloneDynamic(PxPhysics& physicsSDK, 	  | 
| 297 | 							   const PxTransform& transform, | 
| 298 | 							   const PxRigidDynamic& body); | 
| 299 |  | 
| 300 |  | 
| 301 | /** \brief create a plane actor. The plane equation is n.x + d = 0 | 
| 302 |  | 
| 303 | 	\param[in] sdk the PxPhysics object | 
| 304 | 	\param[in] plane a plane of the form n.x + d = 0 | 
| 305 | 	\param[in] material the material for the new object's shape | 
| 306 |  | 
| 307 | 	\return a new static actor, or NULL if it could not be constructed | 
| 308 |  | 
| 309 | 	@see PxRigidStatic | 
| 310 | */ | 
| 311 |  | 
| 312 | PxRigidStatic*	PxCreatePlane(PxPhysics& sdk, | 
| 313 | 							  const PxPlane& plane, | 
| 314 | 							  PxMaterial& material); | 
| 315 |  | 
| 316 |  | 
| 317 | /** | 
| 318 | \brief scale a rigid actor by a uniform scale | 
| 319 |  | 
| 320 | The geometry and relative positions of the actor are multiplied by the given scale value. If the actor is a rigid body or an | 
| 321 | articulation link and the scaleMassProps value is true, the mass properties are scaled assuming the density is constant: the  | 
| 322 | 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.  | 
| 323 |  | 
| 324 | \param[in] actor a rigid actor | 
| 325 | \param[in] scale the scale by which to multiply the actor. Must be >0. | 
| 326 | \param[in] scaleMassProps whether to scale the mass properties | 
| 327 | */ | 
| 328 |  | 
| 329 | void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps = true); | 
| 330 |  | 
| 331 |  | 
| 332 | #if !PX_DOXYGEN | 
| 333 | } // namespace physx | 
| 334 | #endif | 
| 335 |  | 
| 336 | /** @} */ | 
| 337 | #endif | 
| 338 |  |