RavEngine
Loading...
Searching...
No Matches
PxJoint.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_JOINT_H
30#define PX_JOINT_H
35#include "foundation/PxTransform.h"
36#include "PxRigidActor.h"
37#include "PxConstraint.h"
38#include "common/PxBase.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
45class PxRigidActor;
46class PxScene;
47class PxPhysics;
48class PxConstraint;
49
56{
57 enum Enum
58 {
59 eSPHERICAL = PxConcreteType::eFIRST_PHYSX_EXTENSION,
60 eREVOLUTE,
61 ePRISMATIC,
62 eFIXED,
63 eDISTANCE,
64 eD6,
65 eCONTACT,
66 eGEAR,
67 eRACK_AND_PINION,
68 eLast
69 };
70};
71
72PX_DEFINE_TYPEINFO(PxJoint, PxConcreteType::eUNDEFINED)
73PX_DEFINE_TYPEINFO(PxRackAndPinionJoint, PxJointConcreteType::eRACK_AND_PINION)
74PX_DEFINE_TYPEINFO(PxGearJoint, PxJointConcreteType::eGEAR)
75PX_DEFINE_TYPEINFO(PxD6Joint, PxJointConcreteType::eD6)
76PX_DEFINE_TYPEINFO(PxDistanceJoint, PxJointConcreteType::eDISTANCE)
77PX_DEFINE_TYPEINFO(PxContactJoint, PxJointConcreteType::eCONTACT)
78PX_DEFINE_TYPEINFO(PxFixedJoint, PxJointConcreteType::eFIXED)
79PX_DEFINE_TYPEINFO(PxPrismaticJoint, PxJointConcreteType::ePRISMATIC)
80PX_DEFINE_TYPEINFO(PxRevoluteJoint, PxJointConcreteType::eREVOLUTE)
81PX_DEFINE_TYPEINFO(PxSphericalJoint, PxJointConcreteType::eSPHERICAL)
82
83
84
91{
92 enum Enum
93 {
94 eACTOR0,
95 eACTOR1,
96 COUNT
97 };
98};
99
104class PxJoint : public PxBase
105{
106//= ATTENTION! =====================================================================================
107// Changing the data layout of this class breaks the binary serialization format. See comments for
108// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
109// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
110// accordingly.
111//==================================================================================================
112public:
113
124 virtual void setActors(PxRigidActor* actor0, PxRigidActor* actor1) = 0;
125
134 virtual void getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const = 0;
135
146 virtual void setLocalPose(PxJointActorIndex::Enum actor, const PxTransform& localPose) = 0;
147
157 virtual PxTransform getLocalPose(PxJointActorIndex::Enum actor) const = 0;
158
166
174
181
192 virtual void setBreakForce(PxReal force, PxReal torque) = 0;
193
202 virtual void getBreakForce(PxReal& force, PxReal& torque) const = 0;
203
211 virtual void setConstraintFlags(PxConstraintFlags flags) = 0;
212
221 virtual void setConstraintFlag(PxConstraintFlag::Enum flag, bool value) = 0;
222
231
239 virtual void setInvMassScale0(PxReal invMassScale) = 0;
240
248 virtual PxReal getInvMassScale0() const = 0;
249
257 virtual void setInvInertiaScale0(PxReal invInertiaScale) = 0;
258
266 virtual PxReal getInvInertiaScale0() const = 0;
267
275 virtual void setInvMassScale1(PxReal invMassScale) = 0;
276
284 virtual PxReal getInvMassScale1() const = 0;
285
293 virtual void setInvInertiaScale1(PxReal invInertiaScale) = 0;
294
302 virtual PxReal getInvInertiaScale1() const = 0;
303
311 virtual PxConstraint* getConstraint() const = 0;
312
323 virtual void setName(const char* name) = 0;
324
332 virtual const char* getName() const = 0;
333
339 virtual void release() = 0;
340
348 virtual PxScene* getScene() const = 0;
349
350 void* userData;
351
352 //serialization
353
357 static void getBinaryMetaData(PxOutputStream& stream);
358
359 //~serialization
360
361protected:
362 virtual ~PxJoint() {}
363
364 //serialization
365
369 PX_INLINE PxJoint(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {}
370
374 PX_INLINE PxJoint(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
375
379 virtual bool isKindOf(const char* name) const { return !::strcmp("PxJoint", name) || PxBase::isKindOf(name); }
380
381 //~serialization
382};
383
385{
386//= ATTENTION! =====================================================================================
387// Changing the data layout of this class breaks the binary serialization format. See comments for
388// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
389// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
390// accordingly.
391//==================================================================================================
392public:
393
394 PxReal stiffness;
395 PxReal damping;
396
397 PxSpring(PxReal stiffness_, PxReal damping_): stiffness(stiffness_), damping(damping_) {}
398};
399
400
401#if !PX_DOXYGEN
402} // namespace physx
403#endif
404
419PX_C_EXPORT void PX_CALL_CONV PxSetJointGlobalFrame(physx::PxJoint& joint, const physx::PxVec3* wsAnchor, const physx::PxVec3* wsAxis);
420
422#endif
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
virtual bool isKindOf(const char *superClass) const
Returns whether a given type name matches with the type of this instance.
Definition PxBase.h:179
A plugin class for implementing constraints.
Definition PxConstraint.h:100
a joint that maintains an upper or lower bound (or both) on the distance between two points on differ...
Definition PxContactJoint.h:95
A D6 joint is a general constraint between two actors.
Definition PxD6Joint.h:224
a joint that maintains an upper or lower bound (or both) on the distance between two points on differ...
Definition PxDistanceJoint.h:82
A fixed joint permits no relative movement between two bodies. ie the bodies are glued together.
Definition PxFixedJoint.h:65
A joint that connects two existing revolute joints and constrains their relative angular velocity and...
Definition PxGearJoint.h:63
a base interface providing common functionality for PhysX joints
Definition PxJoint.h:105
virtual PxTransform getRelativeTransform() const =0
get the relative pose for this joint
virtual PxReal getInvInertiaScale0() const =0
get the inverse inertia scale for actor0.
virtual PxVec3 getRelativeLinearVelocity() const =0
get the relative linear velocity of the joint
virtual void setConstraintFlags(PxConstraintFlags flags)=0
set the constraint flags for this joint.
virtual void getActors(PxRigidActor *&actor0, PxRigidActor *&actor1) const =0
Get the actors for this joint.
virtual void setInvMassScale0(PxReal invMassScale)=0
set the inverse mass scale for actor0.
virtual const char * getName() const =0
Retrieves the name string set with setName().
virtual void setInvInertiaScale0(PxReal invInertiaScale)=0
set the inverse inertia scale for actor0.
virtual PxScene * getScene() const =0
Retrieves the scene which this joint belongs to.
virtual void release()=0
Deletes the joint.
virtual void setConstraintFlag(PxConstraintFlag::Enum flag, bool value)=0
set a constraint flags for this joint to a specified value.
virtual PxReal getInvMassScale1() const =0
get the inverse mass scale for actor1.
virtual PxConstraintFlags getConstraintFlags() const =0
get the constraint flags for this joint.
virtual void setBreakForce(PxReal force, PxReal torque)=0
set the break force for this joint.
virtual void setInvInertiaScale1(PxReal invInertiaScale)=0
set the inverse inertia scale for actor1.
virtual void setLocalPose(PxJointActorIndex::Enum actor, const PxTransform &localPose)=0
Set the joint local pose for an actor.
virtual PxConstraint * getConstraint() const =0
Retrieves the PxConstraint corresponding to this joint.
virtual void getBreakForce(PxReal &force, PxReal &torque) const =0
get the break force for this joint.
PX_INLINE PxJoint(PxBaseFlags baseFlags)
Deserialization constructor.
Definition PxJoint.h:374
PX_INLINE PxJoint(PxType concreteType, PxBaseFlags baseFlags)
Constructor.
Definition PxJoint.h:369
virtual PxVec3 getRelativeAngularVelocity() const =0
get the relative angular velocity of the joint
virtual PxReal getInvMassScale0() const =0
get the inverse mass scale for actor0.
void * userData
user can assign this to whatever, usually to create a 1:1 relationship with a user object.
Definition PxJoint.h:350
virtual PxTransform getLocalPose(PxJointActorIndex::Enum actor) const =0
get the joint local pose for an actor.
static void getBinaryMetaData(PxOutputStream &stream)
Put class meta data in stream, used for serialization.
Definition ExtMetaData.cpp:129
virtual void setActors(PxRigidActor *actor0, PxRigidActor *actor1)=0
Set the actors for this joint.
virtual void setName(const char *name)=0
Sets a name string for the object that can be retrieved with getName().
virtual void setInvMassScale1(PxReal invMassScale)=0
set the inverse mass scale for actor1.
virtual bool isKindOf(const char *name) const
Returns whether a given type name matches with the type of this instance.
Definition PxJoint.h:379
virtual PxReal getInvInertiaScale1() const =0
get the inverse inertia scale for actor1.
Output stream class for I/O.
Definition PxIO.h:114
A prismatic joint permits relative translational movement between two bodies along an axis,...
Definition PxPrismaticJoint.h:87
A joint that connects an existing revolute joint to an existing prismatic joint, and constrains their...
Definition PxRackAndPinionJoint.h:64
A joint which behaves in a similar way to a hinge or axle.
Definition PxRevoluteJoint.h:99
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
A scene is a collection of bodies and constraints which can interact.
Definition PxScene.h:178
A joint which behaves in a similar way to a ball and socket.
Definition PxSphericalJoint.h:89
Definition PxJoint.h:385
PxReal stiffness
the spring strength of the drive: that is, the force proportional to the position error
Definition PxJoint.h:394
PxReal damping
the damping strength of the drive: that is, the force proportional to the velocity error
Definition PxJoint.h:395
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
PX_C_EXPORT void PX_CALL_CONV PxSetJointGlobalFrame(physx::PxJoint &joint, const physx::PxVec3 *wsAnchor, const physx::PxVec3 *wsAxis)
Helper function to setup a joint's global frame.
Definition ExtJoint.cpp:65
#define PX_CALL_CONV
Definition PxPreprocessor.h:299
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxConstraint.h:57
an enumeration for specifying one or other of the actors referenced by a joint
Definition PxJoint.h:91
an enumeration of PhysX' built-in joint types
Definition PxJoint.h:56