[7983] | 1 | /* |
---|
| 2 | Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org |
---|
| 3 | Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. |
---|
| 4 | |
---|
| 5 | This software is provided 'as-is', without any express or implied warranty. |
---|
| 6 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
| 7 | Permission is granted to anyone to use this software for any purpose, |
---|
| 8 | including commercial applications, and to alter it and redistribute it freely, |
---|
| 9 | subject to the following restrictions: |
---|
| 10 | |
---|
| 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. |
---|
| 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
| 13 | 3. This notice may not be removed or altered from any source distribution. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #ifndef GENERIC_6DOF_SPRING_CONSTRAINT_H |
---|
| 17 | #define GENERIC_6DOF_SPRING_CONSTRAINT_H |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #include "LinearMath/btVector3.h" |
---|
| 21 | #include "btTypedConstraint.h" |
---|
| 22 | #include "btGeneric6DofConstraint.h" |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | /// Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF |
---|
| 26 | |
---|
| 27 | /// DOF index used in enableSpring() and setStiffness() means: |
---|
| 28 | /// 0 : translation X |
---|
| 29 | /// 1 : translation Y |
---|
| 30 | /// 2 : translation Z |
---|
| 31 | /// 3 : rotation X (3rd Euler rotational around new position of X axis, range [-PI+epsilon, PI-epsilon] ) |
---|
| 32 | /// 4 : rotation Y (2nd Euler rotational around new position of Y axis, range [-PI/2+epsilon, PI/2-epsilon] ) |
---|
| 33 | /// 5 : rotation Z (1st Euler rotational around Z axis, range [-PI+epsilon, PI-epsilon] ) |
---|
| 34 | |
---|
| 35 | class btGeneric6DofSpringConstraint : public btGeneric6DofConstraint |
---|
| 36 | { |
---|
| 37 | protected: |
---|
| 38 | bool m_springEnabled[6]; |
---|
| 39 | btScalar m_equilibriumPoint[6]; |
---|
| 40 | btScalar m_springStiffness[6]; |
---|
| 41 | btScalar m_springDamping[6]; // between 0 and 1 (1 == no damping) |
---|
| 42 | void internalUpdateSprings(btConstraintInfo2* info); |
---|
| 43 | public: |
---|
| 44 | btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); |
---|
| 45 | void enableSpring(int index, bool onOff); |
---|
| 46 | void setStiffness(int index, btScalar stiffness); |
---|
| 47 | void setDamping(int index, btScalar damping); |
---|
| 48 | void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF |
---|
| 49 | void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF |
---|
| 50 | void setEquilibriumPoint(int index, btScalar val); |
---|
| 51 | virtual void getInfo2 (btConstraintInfo2* info); |
---|
| 52 | }; |
---|
| 53 | |
---|
| 54 | #endif // GENERIC_6DOF_SPRING_CONSTRAINT_H |
---|
| 55 | |
---|