[1378] | 1 | #ifndef NX_PHYSICS_NXMOTORDESC
|
---|
| 2 | #define NX_PHYSICS_NXMOTORDESC
|
---|
| 3 | /*----------------------------------------------------------------------------*\
|
---|
| 4 | |
|
---|
| 5 | | Public Interface to NovodeX Technology
|
---|
| 6 | |
|
---|
| 7 | | www.novodex.com
|
---|
| 8 | |
|
---|
| 9 | \*----------------------------------------------------------------------------*/
|
---|
| 10 | /** \addtogroup physics
|
---|
| 11 | @{
|
---|
| 12 | */
|
---|
| 13 |
|
---|
| 14 | #include "NxBitField.h" //just for NxJointDriveDesc's drive type, to be removed.
|
---|
| 15 | /**
|
---|
| 16 | \brief Describes a joint motor.
|
---|
| 17 |
|
---|
| 18 | Some joints can be motorized, this allows them to apply a force to cause attached actors to move.
|
---|
| 19 |
|
---|
| 20 | Joints which can be motorized:
|
---|
| 21 |
|
---|
| 22 | <ul>
|
---|
| 23 | <li> #NxPulleyJoint </li>
|
---|
| 24 | <li> #NxRevoluteJoint </li>
|
---|
| 25 | </ul>
|
---|
| 26 |
|
---|
| 27 | #NxJointDriveDesc is used for a similar purpose with #NxD6Joint.
|
---|
| 28 |
|
---|
| 29 | Example (for a revolute joint):
|
---|
| 30 |
|
---|
| 31 | \include NxRevoluteJoint_Motor.cpp
|
---|
| 32 |
|
---|
| 33 | <b>Platform:</b>
|
---|
| 34 | \li PC SW: Yes
|
---|
| 35 | \li PPU : No
|
---|
| 36 | \li PS3 : Yes
|
---|
| 37 | \li XB360: Yes
|
---|
| 38 |
|
---|
| 39 | @see NxPulleyJoint NxRevoluteJoint
|
---|
| 40 | */
|
---|
| 41 | class NxMotorDesc
|
---|
| 42 | {
|
---|
| 43 | public:
|
---|
| 44 | /**
|
---|
| 45 | \brief The relative velocity the motor is trying to achieve.
|
---|
| 46 |
|
---|
| 47 | The motor will only be able to reach this velocity if the maxForce is sufficiently large.
|
---|
| 48 | If the joint is spinning faster than this velocity, the motor will actually try to brake(see #freeSpin).
|
---|
| 49 |
|
---|
| 50 | If you set this to infinity then the motor will keep speeding up, unless there is some sort
|
---|
| 51 | of resistance on the attached bodies. The sign of this variable determines the rotation direction,
|
---|
| 52 | with positive values going the same way as positive joint angles.
|
---|
| 53 |
|
---|
| 54 | Default is infinity.
|
---|
| 55 |
|
---|
| 56 | <b>Range:</b> [0,inf]<br>
|
---|
| 57 | <b>Default:</b> NX_MAX_REAL
|
---|
| 58 |
|
---|
| 59 | @see freeSpin
|
---|
| 60 | */
|
---|
| 61 | NxReal velTarget; //target velocity of motor
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
| 64 | \brief The maximum force (or torque) the motor can exert.
|
---|
| 65 |
|
---|
| 66 | Zero disables the motor.
|
---|
| 67 | Default is 0, should be >= 0. Setting this to a very large value if velTarget is also
|
---|
| 68 | very large may cause unexpected results.
|
---|
| 69 |
|
---|
| 70 | <b>Range:</b> [0,inf)<br>
|
---|
| 71 | <b>Default:</b> 0.0
|
---|
| 72 | */
|
---|
| 73 | NxReal maxForce; //maximum motor force/torque
|
---|
| 74 |
|
---|
| 75 | /**
|
---|
| 76 | \brief If true, motor will not brake when it spins faster than velTarget
|
---|
| 77 |
|
---|
| 78 | <b>Default:</b> false
|
---|
| 79 | */
|
---|
| 80 | NX_BOOL freeSpin;
|
---|
| 81 |
|
---|
| 82 | /**
|
---|
| 83 | \brief Constructor, sets members to default values.
|
---|
| 84 | */
|
---|
| 85 | NX_INLINE NxMotorDesc();
|
---|
| 86 |
|
---|
| 87 | /**
|
---|
| 88 | \brief Constructor, sets members to specified values.
|
---|
| 89 |
|
---|
| 90 | \param[in] velTarget target velocity of motor. <b>Range:</b> [0,inf]
|
---|
| 91 | \param[in] maxForce maximum motor force/torque. <b>Range:</b> [0,inf)
|
---|
| 92 | \param[in] freeSpin If true, motor will not brake when it spins faster than velTarget.
|
---|
| 93 | */
|
---|
| 94 | NX_INLINE NxMotorDesc(NxReal velTarget, NxReal maxForce = 0, NX_BOOL freeSpin = 0);
|
---|
| 95 |
|
---|
| 96 | /**
|
---|
| 97 | \brief Sets members to default values.
|
---|
| 98 | */
|
---|
| 99 | NX_INLINE void setToDefault();
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | \brief Returns true if the descriptor is valid.
|
---|
| 103 |
|
---|
| 104 | \return true if the current settings are valid
|
---|
| 105 | */
|
---|
| 106 | NX_INLINE bool isValid() const;
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 | NX_INLINE NxMotorDesc::NxMotorDesc()
|
---|
| 110 | {
|
---|
| 111 | setToDefault();
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | NX_INLINE NxMotorDesc::NxMotorDesc(NxReal v, NxReal m, NX_BOOL f)
|
---|
| 115 | {
|
---|
| 116 | velTarget = v;
|
---|
| 117 | maxForce = m;
|
---|
| 118 | freeSpin = f;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | NX_INLINE void NxMotorDesc::setToDefault()
|
---|
| 122 | {
|
---|
| 123 | velTarget = NX_MAX_REAL;
|
---|
| 124 | maxForce = 0;
|
---|
| 125 | freeSpin = 0;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | NX_INLINE bool NxMotorDesc::isValid() const
|
---|
| 129 | {
|
---|
| 130 | return (maxForce >= 0);
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | //TODO: the below class is very similar to the above and NxSpringDesc, so it should be merged...
|
---|
| 134 | /**
|
---|
| 135 | \brief Class used to describe drive properties for a #NxD6Joint
|
---|
| 136 |
|
---|
| 137 | <h3>Default Values</h3>
|
---|
| 138 |
|
---|
| 139 | \li #driveType - 0
|
---|
| 140 | \li #spring - 0
|
---|
| 141 | \li #damping - 0
|
---|
| 142 | \li #forceLimit - FLT_MAX
|
---|
| 143 | */
|
---|
| 144 | class NxJointDriveDesc
|
---|
| 145 | {
|
---|
| 146 | public:
|
---|
| 147 | /**
|
---|
| 148 | Type of drive to apply. See #NxD6JointDriveType.
|
---|
| 149 |
|
---|
| 150 | <b>Default:</b> 0
|
---|
| 151 | */
|
---|
| 152 | NxBitField32 driveType;
|
---|
| 153 |
|
---|
| 154 | /**
|
---|
| 155 | \brief spring coefficient
|
---|
| 156 |
|
---|
| 157 | <b>Default:</b> 0
|
---|
| 158 | <b>Range:</b> (-inf,inf)
|
---|
| 159 | */
|
---|
| 160 | NxReal spring;
|
---|
| 161 |
|
---|
| 162 | /**
|
---|
| 163 | \brief damper coefficient
|
---|
| 164 |
|
---|
| 165 | <b>Default:</b> 0
|
---|
| 166 | <b>Range:</b> [0,inf)
|
---|
| 167 | */
|
---|
| 168 | NxReal damping;
|
---|
| 169 |
|
---|
| 170 | /**
|
---|
| 171 | \brief The maximum force (or torque) the drive can exert.
|
---|
| 172 |
|
---|
| 173 | <b>Default:</b> NX_MAX_REAL
|
---|
| 174 | <b>Range:</b> [0,inf)
|
---|
| 175 | */
|
---|
| 176 | NxReal forceLimit;
|
---|
| 177 |
|
---|
| 178 | NxJointDriveDesc()
|
---|
| 179 | {
|
---|
| 180 | spring = 0;
|
---|
| 181 | damping = 0;
|
---|
| 182 | forceLimit = FLT_MAX;
|
---|
| 183 | driveType = 0;
|
---|
| 184 | }
|
---|
| 185 | };
|
---|
| 186 |
|
---|
| 187 | /** @} */
|
---|
| 188 | #endif
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | //AGCOPYRIGHTBEGIN
|
---|
| 192 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 193 | // Copyright © 2005 AGEIA Technologies.
|
---|
| 194 | // All rights reserved. www.ageia.com
|
---|
| 195 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 196 | //AGCOPYRIGHTEND
|
---|
| 197 |
|
---|