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_PRISMATICJOINT_H
15#define PX_PRISMATICJOINT_H
16/** \addtogroup extensions
17 @{
18*/
19
20#include "extensions/PxJoint.h"
21#include "extensions/PxJointLimit.h"
22
23#ifndef PX_DOXYGEN
24namespace physx
25{
26#endif
27
28class PxPrismaticJoint;
29
30/**
31\brief Create a prismatic 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 PxPrismaticJoint
40*/
41
42PxPrismaticJoint* PxPrismaticJointCreate(PxPhysics& physics,
43 PxRigidActor* actor0, const PxTransform& localFrame0,
44 PxRigidActor* actor1, const PxTransform& localFrame1);
45
46
47/**
48\brief Flags specific to the prismatic joint.
49
50@see PxPrismaticJoint
51*/
52
53struct PxPrismaticJointFlag
54{
55 enum Enum
56 {
57 eLIMIT_ENABLED = 1<<1
58 };
59};
60
61typedef PxFlags<PxPrismaticJointFlag::Enum, PxU16> PxPrismaticJointFlags;
62PX_FLAGS_OPERATORS(PxPrismaticJointFlag::Enum, PxU16)
63
64
65/**
66 \brief A prismatic joint permits relative translational movement between two bodies along
67 an axis, but no relative rotational movement.
68
69 the axis on each body is defined as the line containing the origin of the joint frame and
70 extending along the x-axis of that frame
71
72 \image html prismJoint.png
73
74 @see PxPrismaticJointCreate() PxJoint
75*/
76
77class PxPrismaticJoint : public PxJoint
78{
79public:
80
81
82 /**
83 \brief returns the displacement of the joint along its axis.
84 */
85
86 virtual PxReal getPosition() const = 0;
87
88 /**
89 \brief returns the velocity of the joint along its axis
90 */
91 virtual PxReal getVelocity() const = 0;
92
93 /**
94 \brief sets the joint limit parameters.
95
96 The limit range is [-PX_MAX_F32, PX_MAX_F32], but note that the width of the limit (upper-lower) must also be
97 a valid float.
98
99 @see PxJointLinearLimitPair getLimit()
100 */
101 virtual void setLimit(const PxJointLinearLimitPair&) = 0;
102
103 /**
104 \brief gets the joint limit parameters.
105
106 @see PxJointLinearLimit getLimit()
107 */
108 virtual PxJointLinearLimitPair getLimit() const = 0;
109
110
111 /**
112 \brief Set the flags specific to the Prismatic Joint.
113
114 <b>Default</b> PxPrismaticJointFlags(0)
115
116 \param[in] flags The joint flags.
117
118 @see PxPrismaticJointFlag setFlag() getFlags()
119 */
120
121 virtual void setPrismaticJointFlags(PxPrismaticJointFlags flags) = 0;
122
123 /**
124 \brief Set a single flag specific to a Prismatic Joint to true or false.
125
126 \param[in] flag The flag to set or clear.
127 \param[in] value the value to which to set the flag
128
129 @see PxPrismaticJointFlag, getFlags() setFlags()
130 */
131
132 virtual void setPrismaticJointFlag(PxPrismaticJointFlag::Enum flag, bool value) = 0;
133
134 /**
135 \brief Get the flags specific to the Prismatic Joint.
136
137 \return the joint flags
138
139 @see PxPrismaticJoint::flags, PxPrismaticJointFlag setFlag() setFlags()
140 */
141
142 virtual PxPrismaticJointFlags getPrismaticJointFlags(void) const = 0;
143
144 /**
145 \brief Set the linear tolerance threshold for projection.
146
147 If the joint separates by more than this distance along its locked degrees of freedom, the solver
148 will move the bodies to close the distance.
149
150 Setting a very small tolerance may result in simulation jitter or other artifacts.
151
152 Sometimes it is not possible to project (for example when the joints form a cycle).
153
154 This value must be nonnegative.
155
156 <b>Range:</b> [0, PX_MAX_F32)<br>
157 <b>Default:</b> 1e10f
158
159 \param[in] tolerance the linear tolerance threshold
160
161 @see getProjectionLinearTolerance()
162 */
163 virtual void setProjectionLinearTolerance(PxReal tolerance) = 0;
164
165 /**
166 \brief Get the linear tolerance threshold for projection.
167
168 \return the linear tolerance threshold in radians
169
170 @see setProjectionLinearTolerance()
171 */
172
173 virtual PxReal getProjectionLinearTolerance() const = 0;
174
175 /**
176 \brief Set the angular tolerance threshold for projection. Projection is enabled if PxConstraintFlag::ePROJECTION
177 is set for the joint.
178
179 If the joint separates by more than this distance along its locked degrees of freedom, the solver
180 will move the bodies to close the distance.
181
182 Setting a very small tolerance may result in simulation jitter or other artifacts.
183
184 Sometimes it is not possible to project (for example when the joints form a cycle).
185
186 <b>Range:</b> [0, PX_MAX_F32)<br>
187 <b>Default:</b> Pi
188
189 \param[in] tolerance the linear tolerance threshold
190
191 @see getProjectionLinearTolerance() PxJoint::setConstraintFlags()
192 */
193
194 virtual void setProjectionAngularTolerance(PxReal tolerance) = 0;
195
196 /**
197 \brief Get the angular tolerance threshold for projection.
198
199 @see getProjectionAngularTolerance()
200 */
201 virtual PxReal getProjectionAngularTolerance() const = 0;
202
203 /**
204 \brief Returns string name of PxPrismaticJoint, used for serialization
205 */
206 virtual const char* getConcreteTypeName() const { return "PxPrismaticJoint"; }
207
208protected:
209 //serialization
210
211 /**
212 \brief Constructor
213 */
214 PX_INLINE PxPrismaticJoint(PxType concreteType, PxBaseFlags baseFlags) : PxJoint(concreteType, baseFlags) {}
215
216 /**
217 \brief Deserialization constructor
218 */
219 PX_INLINE PxPrismaticJoint(PxBaseFlags baseFlags) : PxJoint(baseFlags) {}
220
221 /**
222 \brief Returns whether a given type name matches with the type of this instance
223 */
224 virtual bool isKindOf(const char* name) const { return !strcmp("PxPrismaticJoint", name) || PxJoint::isKindOf(name); }
225
226 //~serialization
227};
228
229#ifndef PX_DOXYGEN
230} // namespace physx
231#endif
232
233/** @} */
234#endif
235