Bullet Collision Detection & Physics Library
btGeneric6DofSpringConstraint.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
3Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
17#define BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
18
19
21#include "btTypedConstraint.h"
23
24#ifdef BT_USE_DOUBLE_PRECISION
25#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintDoubleData2
26#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintDoubleData2"
27#else
28#define btGeneric6DofSpringConstraintData2 btGeneric6DofSpringConstraintData
29#define btGeneric6DofSpringConstraintDataName "btGeneric6DofSpringConstraintData"
30#endif //BT_USE_DOUBLE_PRECISION
31
32
33
35
43
45{
46protected:
47 bool m_springEnabled[6];
48 btScalar m_equilibriumPoint[6];
49 btScalar m_springStiffness[6];
50 btScalar m_springDamping[6]; // between 0 and 1 (1 == no damping)
51 void init();
52 void internalUpdateSprings(btConstraintInfo2* info);
53public:
54
56
57 btGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
58 btGeneric6DofSpringConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
59 void enableSpring(int index, bool onOff);
60 void setStiffness(int index, btScalar stiffness);
61 void setDamping(int index, btScalar damping);
62 void setEquilibriumPoint(); // set the current constraint position/orientation as an equilibrium point for all DOF
63 void setEquilibriumPoint(int index); // set the current constraint position/orientation as an equilibrium point for given DOF
64 void setEquilibriumPoint(int index, btScalar val);
65
66 bool isSpringEnabled(int index) const
67 {
68 return m_springEnabled[index];
69 }
70
71 btScalar getStiffness(int index) const
72 {
73 return m_springStiffness[index];
74 }
75
76 btScalar getDamping(int index) const
77 {
78 return m_springDamping[index];
79 }
80
82 {
83 return m_equilibriumPoint[index];
84 }
85
86 virtual void setAxis( const btVector3& axis1, const btVector3& axis2);
87
88 virtual void getInfo2 (btConstraintInfo2* info);
89
90 virtual int calculateSerializeBufferSize() const;
92 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
93
94};
95
96
98{
100
105};
106
108{
110
115};
116
117
119{
121}
122
124SIMD_FORCE_INLINE const char* btGeneric6DofSpringConstraint::serialize(void* dataBuffer, btSerializer* serializer) const
125{
127 btGeneric6DofConstraint::serialize(&dof->m_6dofData,serializer);
128
129 int i;
130 for (i=0;i<6;i++)
131 {
132 dof->m_equilibriumPoint[i] = m_equilibriumPoint[i];
133 dof->m_springDamping[i] = m_springDamping[i];
134 dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0;
135 dof->m_springStiffness[i] = m_springStiffness[i];
136 }
138}
139
140#endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H
141
#define btGeneric6DofSpringConstraintDataName
#define btGeneric6DofSpringConstraintData2
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:292
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis locatio...
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
Generic 6 DOF constraint that allows to set spring motors to any translational and rotational DOF.
btScalar getEquilibriumPoint(int index) const
virtual const char * serialize(void *dataBuffer, btSerializer *serializer) const
fills the dataBuffer and returns the struct name (and 0 on failure)
The btRigidBody is the main class for rigid body objects.
Definition: btRigidBody.h:63
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:34
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:84