source: GTP/trunk/App/Games/Jungle_Rumble/src/physic/physics/include/NxRevoluteJoint.h @ 1378

Revision 1378, 9.7 KB checked in by giegl, 18 years ago (diff)

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#ifndef NX_PHYSICS_NXHINGEJOINT
2#define NX_PHYSICS_NXHINGEJOINT
3/*----------------------------------------------------------------------------*\
4|
5|                                               Public Interface to NovodeX Technology
6|
7|                                                            www.novodex.com
8|
9\*----------------------------------------------------------------------------*/
10/** \addtogroup physics
11  @{
12*/
13
14#include "Nxp.h"
15
16#include "NxJoint.h"
17#include "NxRevoluteJointDesc.h"
18
19static const NxReal NX_NO_LOW_LIMIT  = -16;
20static const NxReal NX_NO_HIGH_LIMIT =  16;
21
22
23/**
24
25\brief A joint which behaves in a similar way to a hinge or axel.
26
27 A hinge joint removes all but a single rotational degree of freedom from two objects.
28 The axis along which the two bodies may rotate is specified with a point and a direction
29 vector.
30
31 \image html revoluteJoint.png
32
33 <h3>Creation</h3>
34
35 Example:
36
37 \include NxRevoluteJoint_Create.cpp
38
39 A revolute joint can be given a motor, so that it can apply a force to rotate the attached actors.
40
41 Example:
42
43 \include NxRevoluteJoint_Motor.cpp
44
45 <h3>Visulizations:</h3>
46\li #NX_VISUALIZE_JOINT_LOCAL_AXES
47\li #NX_VISUALIZE_JOINT_WORLD_AXES
48\li #NX_VISUALIZE_JOINT_LIMITS
49\li #NX_VISUALIZE_JOINT_ERROR
50\li #NX_VISUALIZE_JOINT_FORCE
51\li #NX_VISUALIZE_JOINT_REDUCED
52
53 @see NxRevoluteJointDesc NxScene.createJoint() NxJoint
54*/
55class NxRevoluteJoint : public NxJoint
56        {
57        public:
58        /**
59        \brief Use this for changing a significant number of joint parameters at once.
60
61        Use the set() methods for changing only a single property at once.
62
63        \param[in] desc The descriptor used to set the state of the object.
64
65        <b>Platform:</b>
66        \li PC SW: Yes
67        \li PPU  : No
68        \li PS3  : Yes
69        \li XB360: Yes
70
71        @see saveToDesc() NxRevoluteJointDesc
72        */
73        virtual void loadFromDesc(const NxRevoluteJointDesc& desc) = 0;
74
75        /**
76        \brief Writes all of the object's attributes to the desc struct  .
77
78        \param[out] desc The descriptor used to retrieve the state of the object.
79
80        <b>Platform:</b>
81        \li PC SW: Yes
82        \li PPU  : No
83        \li PS3  : Yes
84        \li XB360: Yes
85
86        @see loadFromDesc() NxRevoluteJointDesc
87        */
88        virtual void saveToDesc(NxRevoluteJointDesc& desc) = 0;
89
90        /**
91        \brief Sets angular joint limits.
92
93        If either of these limits are set, any planar limits in NxJoint are ignored.
94        The limits are angles defined the same way as the values getAngle() returns.
95       
96        The following has to hold:
97        - Pi < lowAngle < highAngle < Pi
98        Both limits are disabled by default.
99
100        Also sets coefficients of restitutions for the low and high angular limits.
101        These settings are only used if valid limits are set using setLimits().
102        These restitution coefficients work the same way as for contacts.
103
104        The coefficient of restitution determines whether a collision with the joint limit is
105        completely elastic (like pool balls, restitution = 1, no energy is lost in the collision),
106        completely inelastic (like putty, restitution = 0, no rebound after collision) or
107        somewhere in between. The default is 0 for both.
108
109        This automatically enables the limit.
110
111        \param[in] pair The new joint limit settings. <b>Range:</b> See #NxJointLimitPairDesc
112
113        <b>Platform:</b>
114        \li PC SW: Yes
115        \li PPU  : No
116        \li PS3  : Yes
117        \li XB360: Yes
118
119        @see NxJointLimitDesc NxJointLimitPairDesc getLimits()
120        */
121        virtual void setLimits(const NxJointLimitPairDesc & pair) = 0;
122
123        /**
124        \brief Retrieves the joint limits.
125       
126        Returns true if it is enabled.
127
128        Also returns the limit restitutions.
129
130        \param[in] pair Used to retrieve the joint limit settings.
131        \return True if the limit is enabled.
132
133        <b>Platform:</b>
134        \li PC SW: Yes
135        \li PPU  : No
136        \li PS3  : Yes
137        \li XB360: Yes
138
139        @see setLimits() NxJointLimitPairDesc NxJointLimitDesc
140        */
141        virtual bool getLimits(NxJointLimitPairDesc & pair) = 0;
142
143        /**
144        \brief Sets motor parameters for the joint.
145       
146        The motor rotates the bodies relative to each other along the hinge axis. The motor has these parameters:
147       
148        <ul>
149        <li>velTarget - the relative velocity the motor is trying to achieve. The motor will only be able
150                                to reach this velocity if the maxForce is sufficiently large. If the joint is
151                                spinning faster than this velocity, the motor will actually try to brake. If you set this
152                                to infinity then the motor will keep speeding up, unless there is some sort of resistance
153                                on the attached bodies. The sign of this variable determines the rotation direction,
154                                with positive values going the same way as positive joint angles.
155                                Default is infinity.</li>
156        <li>maxForce -  the maximum force (torque in this case) the motor can exert. Zero disables the motor.
157                                Default is 0, should be >= 0. Setting this to a very large value if velTarget is also
158                                very large may not be a good idea.</li>
159        <li>freeSpin -  if this flag is set, and if the joint is spinning faster than velTarget, then neither
160                                braking nor additional acceleration will result.
161                                default: false.</li>
162        </ul>
163
164        This automatically enables the motor.
165
166        \param[in] motorDesc The new motor parameters for the joint. <b>Range:</b> See #NxMotorDesc
167
168        <b>Platform:</b>
169        \li PC SW: Yes
170        \li PPU  : No
171        \li PS3  : Yes
172        \li XB360: Yes
173
174        @see NxMotorDesc getMotor()
175        */
176        virtual void setMotor(const NxMotorDesc &motorDesc) = 0;
177       
178        /**
179        \brief Reads back the motor parameters.
180       
181        Returns true if it is enabled.
182
183        \param[out] motorDesc Used to store the motor parameters of the joint. See #NxMotorDesc
184        \return True if the motor is enabled.
185
186        <b>Platform:</b>
187        \li PC SW: Yes
188        \li PPU  : No
189        \li PS3  : Yes
190        \li XB360: Yes
191
192        @see setMotor() NxMotorDesc
193        */
194        virtual bool getMotor(NxMotorDesc &motorDesc) = 0;
195
196        /**
197        \brief Sets spring parameters.
198       
199        The spring is implicitly integrated so no instability should result for arbitrary
200        spring and damping constants. Using these settings together with a motor is not possible -- the motor will have
201        priority and the spring settings are ignored.
202        If you would like to simulate your motor's internal friction, do this by altering the motor parameters directly.
203
204        spring - The rotational spring acts along the hinge axis and tries to force
205                                the joint angle to zero. A setting of zero disables the spring. Default is 0, should be >= 0.
206        damper - Damping coefficient; acts against the hinge's angular velocity. A setting of zero disables
207                                the damping. The default is 0, should be >= 0.
208        targetValue - The angle at which the spring is relaxed. In [-Pi,Pi]. Default is 0.
209
210        This automatically enables the spring.
211
212        \param[in] springDesc The new spring parameters for the joint. <b>Range:</b> See #NxSpringDesc.
213
214        <b>Platform:</b>
215        \li PC SW: Yes
216        \li PPU  : No
217        \li PS3  : Yes
218        \li XB360: Yes
219
220        @see getSpring() NxSpringDesc
221        */
222        virtual void setSpring(const NxSpringDesc &springDesc) = 0;
223
224        /**
225        \brief Retrieves spring settings.
226       
227        Returns true if it is enabled.
228
229        @see setSpring
230
231        \param[out] springDesc Used to retrieve the spring parameters for the joint. See #NxSpringDesc.
232        \return True if the spring is enabled.
233
234        <b>Platform:</b>
235        \li PC SW: Yes
236        \li PPU  : No
237        \li PS3  : Yes
238        \li XB360: Yes
239
240        @see NxSpringDesc setSpring()
241        */
242        virtual bool getSpring(NxSpringDesc &springDesc) = 0;
243
244        /**
245        \brief Retrieves the current revolute joint angle.
246       
247        The relative orientation of the bodies is stored when the joint is created, or when setAxis()
248        or setAnchor() is called.
249        This initial orientation returns an angle of zero, and joint angles are measured
250        relative to this pose.
251        The angle is in the range [-Pi, Pi], with positive angles CCW around the axis, measured
252        from body2 to body1.
253
254        <b>Unit:</b> Radians
255        <b>Range:</b> [-PI,PI]
256
257        \return The current hinge angle.
258       
259        <b>Platform:</b>
260        \li PC SW: Yes
261        \li PPU  : No
262        \li PS3  : Yes
263        \li XB360: Yes
264
265        @see getVelocity()
266        */
267        virtual NxReal getAngle() = 0;
268
269        /**
270        \brief Retrieves the revolute joint angle's rate of change (angular velocity).
271
272        It is the angular velocity of body1 minus body2 projected along the axis.
273
274        \return The hinge velocity.
275       
276        <b>Platform:</b>
277        \li PC SW: Yes
278        \li PPU  : No
279        \li PS3  : Yes
280        \li XB360: Yes
281
282        @see getAngle()
283        */
284        virtual NxReal getVelocity() = 0;
285
286        /**
287        \brief Sets the flags to enable/disable the spring/motor/limit.
288       
289        This is a combination of the ::NxRevoluteJointFlag bits.
290
291        \param[in] flags A combination of NxRevoluteJointFlag flags to set for this joint
292
293        <b>Platform:</b>
294        \li PC SW: Yes
295        \li PPU  : No
296        \li PS3  : Yes
297        \li XB360: Yes
298
299        @see NxRevoluteJointFlag getFlags()
300        */
301        virtual void setFlags(NxU32 flags) = 0;
302
303        /**
304        \brief Retrieve the revolute joints flags.
305
306        \return the current flag settings. See #NxRevoluteJointFlag
307
308        <b>Platform:</b>
309        \li PC SW: Yes
310        \li PPU  : No
311        \li PS3  : Yes
312        \li XB360: Yes
313
314        @see setFlags() NxRevoluteJointFlag
315        */
316        virtual NxU32 getFlags() = 0;
317
318        /**
319        \brief Sets the joint projection mode.
320
321        \param[in] projectionMode The new projection mode. See #NxJointProjectionMode.
322
323        <b>Platform:</b>
324        \li PC SW: Yes
325        \li PPU  : No
326        \li PS3  : Yes
327        \li XB360: Yes
328
329        @see getProjectionMode() NxJointProjectionMode NxRevoluteJointDesc.projectionMode
330        */
331        virtual void setProjectionMode(NxJointProjectionMode projectionMode) = 0;
332
333        /**
334        \brief Retrieves the joints projection mode.
335
336        \return the current flag settings.
337
338        <b>Platform:</b>
339        \li PC SW: Yes
340        \li PPU  : No
341        \li PS3  : Yes
342        \li XB360: Yes
343
344        @see setProjectionMode() NxJointProjectionMode NxRevoluteJointDesc.projectionMode
345        */
346        virtual NxJointProjectionMode getProjectionMode() = 0;
347        };
348
349/** @} */
350#endif
351
352
353//AGCOPYRIGHTBEGIN
354///////////////////////////////////////////////////////////////////////////
355// Copyright © 2005 AGEIA Technologies.
356// All rights reserved. www.ageia.com
357///////////////////////////////////////////////////////////////////////////
358//AGCOPYRIGHTEND
359
Note: See TracBrowser for help on using the repository browser.