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

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

GTPD - Jungle Rumble - integrate into GTP SVN structure

Line 
1#ifndef NX_PHYSICS_NXHINGEJOINTDESC
2#define NX_PHYSICS_NXHINGEJOINTDESC
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 "NxJointDesc.h"
16#include "NxJointLimitPairDesc.h"
17#include "NxSpringDesc.h"
18#include "NxMotorDesc.h"
19
20/**
21\brief Desc class for #NxRevoluteJoint.
22
23<b>Platform:</b>
24\li PC SW: Yes
25\li PPU  : No
26\li PS3  : Yes
27\li XB360: Yes
28
29@see NxRevoluteJoint
30*/
31class NxRevoluteJointDesc : public NxJointDesc
32        {
33        public:
34        /**
35        \brief Optional limits for the angular motion of the joint.
36
37        <b>Range:</b> See #NxJointLimitPairDesc<br>
38        <b>Default:</b> See #NxJointLimitPairDesc
39
40        @see NxJointLimitPairDesc NxJointLimitDesc NxRevoluteJointFlag
41        */
42        NxJointLimitPairDesc limit;
43
44        /**
45        \brief Optional motor.
46
47        <b>Range:</b> See #NxMotorDesc<br>
48        <b>Default:</b> See #NxMotorDesc
49
50        @see NxMotorDesc NxRevoluteJointFlag
51        */
52        NxMotorDesc                      motor;
53
54        /**
55        \brief Optional spring.
56
57        <b>Range:</b> See #NxSpringDesc<br>
58        <b>Default:</b> See #NxSpringDesc
59
60        @see NxSpringDesc NxRevoluteJointFlag
61        */
62        NxSpringDesc             spring;
63
64        /**
65        \brief The distance beyond which the joint is projected.
66       
67        projectionMode is NX_JPM_POINT_MINDIST, the joint gets artificially projected together when it drifts more than this distance. Sometimes it is not possible to project (for example when the joints form a cycle)
68        Should be nonnegative. 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.
69
70        <b>Range:</b> (0,inf)<br>
71        <b>Default:</b> 1.0
72
73        @see projectionMode projectionAngle
74    */
75        NxReal projectionDistance;     
76
77        /**
78        \brief The angle beyond which the joint is projected.
79       
80        This similar to #projectionDistance, except this is an angle (in radians) to which angular drift is
81        projected.
82
83        <b>Unit:</b> Radians
84        <b>Range:</b> (0,PI)<br>
85        <b>Default:</b> 0.0872 (about 5 degrees in radians)
86
87        @see projectionDistance projectionMode
88        */
89        NxReal projectionAngle;
90
91        /**
92        \brief This is a combination of the bits defined by ::NxRevoluteJointFlag.
93
94        <b>Default:</b> 0
95
96        @see NxRevoluteJointFlag
97        */
98        NxU32 flags;
99
100        /**
101        \brief use this to enable joint projection
102
103        <b>Default:</b> NX_JPM_NONE
104
105        @see NxJointProjectionMode projectionDistance projectionAngle NxRevoluteJoint.setProjectionMode()
106        */
107        NxJointProjectionMode projectionMode;
108
109        /**
110        \brief constructor sets to default.
111        */
112
113        NX_INLINE NxRevoluteJointDesc();       
114        /**
115        \brief (re)sets the structure to the default.   
116
117        \param[in] fromCtor Avoid redundant work if called from constructor.
118        */
119        NX_INLINE void setToDefault(bool fromCtor = false);
120       
121        /**
122        \brief Returns true if the descriptor is valid.
123       
124        \return true if the current settings are valid
125        */
126        NX_INLINE bool isValid() const;
127
128        };
129
130NX_INLINE NxRevoluteJointDesc::NxRevoluteJointDesc() : NxJointDesc(NX_JOINT_REVOLUTE)   //constructor sets to default
131        {
132        setToDefault(true);
133        }
134
135NX_INLINE void NxRevoluteJointDesc::setToDefault(bool fromCtor)
136        {
137        NxJointDesc::setToDefault();
138        projectionDistance = 1.0f;
139        projectionAngle = 0.0872f;      //about 5 degrees in radians.
140
141        if (!fromCtor)
142                {
143                limit.setToDefault();
144                motor.setToDefault();
145                spring.setToDefault();
146                }
147
148        flags = 0;
149        projectionMode = NX_JPM_NONE;
150        }
151
152NX_INLINE bool NxRevoluteJointDesc::isValid() const
153        {
154        if (projectionDistance < 0.0f) return false;
155        if (projectionAngle < 0.02f) return false;      //if its smaller then current algo gets too close to a singularity.
156       
157
158        if (!limit.isValid()) return false;
159        if (!motor.isValid()) return false;
160        if (!spring.isValid()) return false;
161
162
163        return NxJointDesc::isValid();
164        }
165
166/** @} */
167#endif
168
169
170//AGCOPYRIGHTBEGIN
171///////////////////////////////////////////////////////////////////////////
172// Copyright © 2005 AGEIA Technologies.
173// All rights reserved. www.ageia.com
174///////////////////////////////////////////////////////////////////////////
175//AGCOPYRIGHTEND
176
Note: See TracBrowser for help on using the repository browser.