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_SPHERICALJOINT_H |
15 | #define PX_SPHERICALJOINT_H |
16 | /** \addtogroup extensions |
17 | @{ |
18 | */ |
19 | |
20 | #include "extensions/PxJoint.h" |
21 | #include "extensions/PxJointLimit.h" |
22 | |
23 | #ifndef PX_DOXYGEN |
24 | namespace physx |
25 | { |
26 | #endif |
27 | |
28 | class PxSphericalJoint; |
29 | |
30 | /** |
31 | \brief Create a spherical joint. |
32 | |
33 | \param[in] physics the physics SDK |
34 | \param[in] actor0 an actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame |
35 | \param[in] localFrame0 the position and orientation of the joint relative to actor0 |
36 | \param[in] actor1 an actor to which the joint is attached. NULL may be used to attach the joint to a specific point in the world frame |
37 | \param[in] localFrame1 the position and orientation of the joint relative to actor1 |
38 | |
39 | @see PxSphericalJoint |
40 | */ |
41 | |
42 | PxSphericalJoint* PxSphericalJointCreate(PxPhysics& physics, |
43 | PxRigidActor* actor0, const PxTransform& localFrame0, |
44 | PxRigidActor* actor1, const PxTransform& localFrame1); |
45 | |
46 | |
47 | /** |
48 | \brief Flags specific to the spherical joint. |
49 | |
50 | @see PxSphericalJoint |
51 | */ |
52 | |
53 | struct PxSphericalJointFlag |
54 | { |
55 | enum Enum |
56 | { |
57 | eLIMIT_ENABLED = 1<<1 //!< the cone limit for the spherical joint is enabled |
58 | }; |
59 | }; |
60 | typedef PxFlags<PxSphericalJointFlag::Enum, PxU16> PxSphericalJointFlags; |
61 | PX_FLAGS_OPERATORS(PxSphericalJointFlag::Enum, PxU16) |
62 | |
63 | /** |
64 | \brief A joint which behaves in a similar way to a ball and socket. |
65 | |
66 | A spherical joint removes all linear degrees of freedom from two objects. |
67 | |
68 | The position of the joint on each actor is specified by the origin of the body's joint frame. |
69 | |
70 | A spherical joint may have a cone limit, to restrict the motion to within a certain range. In |
71 | addition, the bodies may be projected together if the distance between them exceeds a given threshold. |
72 | |
73 | Projection, drive and limits are activated by setting the appropriate flags on the joint. |
74 | |
75 | @see PxRevoluteJointCreate() PxJoint |
76 | */ |
77 | |
78 | class PxSphericalJoint : public PxJoint |
79 | { |
80 | public: |
81 | |
82 | |
83 | /** |
84 | \brief Set the limit cone. |
85 | |
86 | If enabled, the limit cone will constrain the angular movement of the joint to lie |
87 | within an elliptical cone. |
88 | |
89 | \return the limit cone |
90 | |
91 | @see PxJointLimitCone setLimit() |
92 | */ |
93 | |
94 | virtual PxJointLimitCone getLimitCone() const = 0; |
95 | |
96 | /** |
97 | \brief Get the limit cone. |
98 | |
99 | \param[in] limit the limit cone |
100 | |
101 | @see PxJointLimitCone getLimit() |
102 | */ |
103 | |
104 | virtual void setLimitCone(const PxJointLimitCone &limit) = 0; |
105 | |
106 | /** |
107 | \brief Set the flags specific to the Spherical Joint. |
108 | |
109 | <b>Default</b> PxSphericalJointFlags(0) |
110 | |
111 | \param[in] flags The joint flags. |
112 | |
113 | @see PxSphericalJointFlag setFlag() getFlags() |
114 | */ |
115 | |
116 | virtual void setSphericalJointFlags(PxSphericalJointFlags flags) = 0; |
117 | |
118 | /** |
119 | \brief Set a single flag specific to a Spherical Joint to true or false. |
120 | |
121 | \param[in] flag The flag to set or clear. |
122 | \param[in] value the value to which to set the flag |
123 | |
124 | @see PxSphericalJointFlag, getFlags() setFlags() |
125 | */ |
126 | |
127 | virtual void setSphericalJointFlag(PxSphericalJointFlag::Enum flag, bool value) = 0; |
128 | |
129 | /** |
130 | \brief Get the flags specific to the Spherical Joint. |
131 | |
132 | \return the joint flags |
133 | |
134 | @see PxSphericalJoint::flags, PxSphericalJointFlag setFlag() setFlags() |
135 | */ |
136 | |
137 | virtual PxSphericalJointFlags getSphericalJointFlags(void) const = 0; |
138 | |
139 | /** |
140 | \brief Set the linear tolerance threshold for projection. Projection is enabled if PxConstraintFlag::ePROJECTION |
141 | is set for the joint. |
142 | |
143 | If the joint separates by more than this distance along its locked degrees of freedom, the solver |
144 | will move the bodies to close the distance. |
145 | |
146 | Setting a very small tolerance may result in simulation jitter or other artifacts. |
147 | |
148 | Sometimes it is not possible to project (for example when the joints form a cycle). |
149 | |
150 | <b>Range:</b> [0, PX_MAX_F32)<br> |
151 | <b>Default:</b> 1e10f |
152 | |
153 | \param[in] tolerance the linear tolerance threshold |
154 | |
155 | @see getProjectionLinearTolerance() PxJoint::setConstraintFlags() PxConstraintFlag::ePROJECTION |
156 | */ |
157 | |
158 | virtual void setProjectionLinearTolerance(PxReal tolerance) = 0; |
159 | |
160 | |
161 | /** |
162 | \brief Get the linear tolerance threshold for projection. |
163 | |
164 | \return the linear tolerance threshold |
165 | |
166 | @see setProjectionLinearTolerance() |
167 | */ |
168 | |
169 | virtual PxReal getProjectionLinearTolerance() const = 0; |
170 | |
171 | /** |
172 | \brief Returns string name of PxSphericalJoint, used for serialization |
173 | */ |
174 | virtual const char* getConcreteTypeName() const { return "PxSphericalJoint" ; } |
175 | |
176 | protected: |
177 | |
178 | //serialization |
179 | |
180 | /** |
181 | \brief Constructor |
182 | */ |
183 | PX_INLINE PxSphericalJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {} |
184 | |
185 | /** |
186 | \brief Deserialization constructor |
187 | */ |
188 | PX_INLINE PxSphericalJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {} |
189 | |
190 | /** |
191 | \brief Returns whether a given type name matches with the type of this instance |
192 | */ |
193 | virtual bool isKindOf(const char* name) const { return !strcmp("PxSphericalJoint" , name) || PxJoint::isKindOf(name); } |
194 | |
195 | //~serialization |
196 | |
197 | }; |
198 | |
199 | #ifndef PX_DOXYGEN |
200 | } // namespace physx |
201 | #endif |
202 | |
203 | /** @} */ |
204 | #endif |
205 | |