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

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

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#ifndef NX_PHYSICS_NXSPHEREJOINTDESC
2#define NX_PHYSICS_NXSPHEREJOINTDESC
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#include "NxJointLimitPairDesc.h"
16#include "NxSpringDesc.h"
17#include "NxJointDesc.h"
18
19class NxActor;
20
21
22/**
23\brief Desc class for an #NxSphericalJoint.
24
25@see NxSphericalJoint NxScene.createJoint()
26*/
27class NxSphericalJointDesc : public NxJointDesc
28        {
29        public:
30        /**
31        \brief swing limit axis defined in the joint space of actor 0.
32       
33        ([localNormal[0], localAxis[0]^localNormal[0],localAxis[0]])
34
35        <b>Range:</b> direction vector<br>
36        <b>Default:</b> 0.0, 0.0, 1.0
37
38        <b>Platform:</b>
39        \li PC SW: Yes
40        \li PPU  : No
41        \li PS3  : Yes
42        \li XB360: Yes
43        */
44        NxVec3 swingAxis;
45
46       
47        /**
48        \brief Distance above which to project joint.
49
50        If flags.projectionMode is 1, the joint gets artificially projected together when it drifts more than this distance.
51       
52        Sometimes it is not possible to project (for example when the joints form a cycle).
53
54        Should be nonnegative.
55       
56        However, it may be a bad idea to always project to a very small or zero distance because the solver *needs* some error in order to produce correct motion.
57
58        <b>Range:</b> (0,inf)<br>
59        <b>Default:</b> 1.0
60
61        <b>Platform:</b>
62        \li PC SW: Yes
63        \li PPU  : No
64        \li PS3  : Yes
65        \li XB360: Yes
66
67        @see projectionMode NxJointProjectionMode
68        */
69        NxReal projectionDistance;     
70
71
72//limits:
73
74        /**
75        \brief limits rotation around twist axis
76
77        <b>Range:</b> See #NxJointLimitPairDesc<br>
78        <b>Default:</b> See #NxJointLimitPairDesc
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 NxJointLimitPairDesc swingLimit
87        */
88        NxJointLimitPairDesc twistLimit;
89
90        /**
91        \brief limits swing of twist axis
92
93        <b>Range:</b> See #NxJointLimitDesc<br>
94        <b>Default:</b> See #NxJointLimitDesc
95
96        <b>Platform:</b>
97        \li PC SW: Yes
98        \li PPU  : No
99        \li PS3  : Yes
100        \li XB360: Yes
101
102        @see NxJointLimitDesc twistLimit
103        */
104        NxJointLimitDesc swingLimit;
105       
106       
107//spring + damper:
108
109        /**
110        \brief spring that works against twisting
111
112    <b>Range:</b> See #NxSpringDesc<br>
113        <b>Default:</b> See #NxSpringDesc
114
115        <b>Platform:</b>
116        \li PC SW: Yes
117        \li PPU  : No
118        \li PS3  : Yes
119        \li XB360: Yes
120
121        @see NxSpringDesc
122        */
123        NxSpringDesc     twistSpring;
124
125        /**
126        \brief spring that works against swinging
127
128    <b>Range:</b> See #NxSpringDesc<br>
129        <b>Default:</b> See #NxSpringDesc
130
131        <b>Platform:</b>
132        \li PC SW: Yes
133        \li PPU  : No
134        \li PS3  : Yes
135        \li XB360: Yes
136
137        @see NxSpringDesc
138        */
139        NxSpringDesc     swingSpring;
140
141        /**
142        \brief spring that lets the joint get pulled apart
143
144    <b>Range:</b> See #NxSpringDesc<br>
145        <b>Default:</b> See #NxSpringDesc
146
147        <b>Platform:</b>
148        \li PC SW: Yes
149        \li PPU  : No
150        \li PS3  : Yes
151        \li XB360: Yes
152
153        @see NxSpringDesc
154        */
155        NxSpringDesc     jointSpring;
156
157        /**
158        \brief This is a combination of the bits defined by ::NxSphericalJointFlag .
159
160        <b>Default:</b> 0
161
162        <b>Platform:</b>
163        \li PC SW: Yes
164        \li PPU  : No
165        \li PS3  : Yes
166        \li XB360: Yes
167
168        @see NxSphericalJointFlag
169        */
170        NxU32 flags;                                                   
171
172        /**
173        \brief use this to enable joint projection
174
175        <b>Default:</b> NX_JPM_NONE
176
177        <b>Platform:</b>
178        \li PC SW: Yes
179        \li PPU  : No
180        \li PS3  : Yes
181        \li XB360: Yes
182
183        @see projectionDistance NxJointProjectionMode
184        */
185        NxJointProjectionMode projectionMode;
186
187        /**
188        \brief Constructor sets to default.
189        */
190        NX_INLINE NxSphericalJointDesc();       
191        /**
192        \brief (re)sets the structure to the default.   
193        */
194        NX_INLINE void setToDefault();
195        /**
196        \brief Returns true if the descriptor is valid.
197
198        \return true if the current settings are valid
199        */
200        NX_INLINE bool isValid() const;
201        };
202
203NX_INLINE NxSphericalJointDesc::NxSphericalJointDesc() : NxJointDesc(NX_JOINT_SPHERICAL)        //constructor sets to default
204        {
205        setToDefault();
206        }
207
208NX_INLINE void NxSphericalJointDesc::setToDefault()
209        {
210        NxJointDesc::setToDefault();
211
212        swingAxis.set(0,0,1);
213
214        twistLimit.setToDefault();
215        swingLimit.setToDefault();
216        twistSpring.setToDefault();
217        swingSpring.setToDefault();
218        jointSpring.setToDefault();
219
220        projectionDistance = 1.0f;
221
222        flags = 0;
223        projectionMode = NX_JPM_NONE;
224        }
225
226NX_INLINE bool NxSphericalJointDesc::isValid() const
227        {
228        //check unit vectors
229        if (swingAxis.magnitudeSquared() < 0.9f) return false;
230        if (projectionDistance < 0.0f) return false;
231
232        if (!twistLimit.isValid()) return false;
233        if (!swingLimit.isValid()) return false;
234        if (!swingSpring.isValid()) return false;
235        if (!twistSpring.isValid()) return false;
236        if (!jointSpring.isValid()) return false;
237
238        return NxJointDesc::isValid();
239        }
240
241/** @} */
242#endif
243
244
245//AGCOPYRIGHTBEGIN
246///////////////////////////////////////////////////////////////////////////
247// Copyright © 2005 AGEIA Technologies.
248// All rights reserved. www.ageia.com
249///////////////////////////////////////////////////////////////////////////
250//AGCOPYRIGHTEND
251
Note: See TracBrowser for help on using the repository browser.