00001 /* 00002 Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org 00003 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc. 00004 00005 This software is provided 'as-is', without any express or implied warranty. 00006 In no event will the authors be held liable for any damages arising from the use of this software. 00007 Permission is granted to anyone to use this software for any purpose, 00008 including commercial applications, and to alter it and redistribute it freely, 00009 subject to the following restrictions: 00010 00011 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. 00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 00013 3. This notice may not be removed or altered from any source distribution. 00014 */ 00015 00016 #ifndef GENERIC_6DOF_SPRING_CONSTRAINT_H 00017 #define GENERIC_6DOF_SPRING_CONSTRAINT_H 00018 00019 00020 #include "LinearMath/btVector3.h" 00021 #include "btTypedConstraint.h" 00022 #include "btGeneric6DofConstraint.h" 00023 00024 00026 00034 00035 class btGeneric6DofSpringConstraint : public btGeneric6DofConstraint 00036 { 00037 protected: 00038 bool m_springEnabled[6]; 00039 btScalar m_equilibriumPoint[6]; 00040 btScalar m_springStiffness[6]; 00041 btScalar m_springDamping[6]; // between 0 and 1 (1 == no damping) 00042 void internalUpdateSprings(btConstraintInfo2* info); 00043 public: 00044 btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); 00045 void enableSpring(int index, bool onOff); 00046 void setStiffness(int index, btScalar stiffness); 00047 void setDamping(int index, btScalar damping); 00048 void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF 00049 void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF 00050 virtual void getInfo2 (btConstraintInfo2* info); 00051 }; 00052 00053 #endif // GENERIC_6DOF_SPRING_CONSTRAINT_H 00054