Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
00017 #define BT_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];
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();
00049 void setEquilibriumPoint(int index);
00050 void setEquilibriumPoint(int index, btScalar val);
00051
00052 virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
00053
00054 virtual void getInfo2 (btConstraintInfo2* info);
00055
00056 virtual int calculateSerializeBufferSize() const;
00058 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
00059
00060 };
00061
00062
00064 struct btGeneric6DofSpringConstraintData
00065 {
00066 btGeneric6DofConstraintData m_6dofData;
00067
00068 int m_springEnabled[6];
00069 float m_equilibriumPoint[6];
00070 float m_springStiffness[6];
00071 float m_springDamping[6];
00072 };
00073
00074 SIMD_FORCE_INLINE int btGeneric6DofSpringConstraint::calculateSerializeBufferSize() const
00075 {
00076 return sizeof(btGeneric6DofSpringConstraintData);
00077 }
00078
00080 SIMD_FORCE_INLINE const char* btGeneric6DofSpringConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
00081 {
00082 btGeneric6DofSpringConstraintData* dof = (btGeneric6DofSpringConstraintData*)dataBuffer;
00083 btGeneric6DofConstraint::serialize(&dof->m_6dofData,serializer);
00084
00085 int i;
00086 for (i=0;i<6;i++)
00087 {
00088 dof->m_equilibriumPoint[i] = m_equilibriumPoint[i];
00089 dof->m_springDamping[i] = m_springDamping[i];
00090 dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0;
00091 dof->m_springStiffness[i] = m_springStiffness[i];
00092 }
00093 return "btGeneric6DofConstraintData";
00094 }
00095
00096 #endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
00097