Bullet Collision Detection & Physics Library
btGeneric6DofSpringConstraint.cpp
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
19
22{
23 init();
24}
25
28{
29 init();
30}
31
33{
35
36 for (int i = 0; i < 6; i++)
37 {
38 m_springEnabled[i] = false;
41 m_springDamping[i] = btScalar(1.f);
42 }
43}
44
46{
47 btAssert((index >= 0) && (index < 6));
48 m_springEnabled[index] = onOff;
49 if (index < 3)
50 {
52 }
53 else
54 {
56 }
57}
58
60{
61 btAssert((index >= 0) && (index < 6));
63}
64
66{
67 btAssert((index >= 0) && (index < 6));
68 m_springDamping[index] = damping;
69}
70
72{
74 int i;
75
76 for (i = 0; i < 3; i++)
77 {
79 }
80 for (i = 0; i < 3; i++)
81 {
83 }
84}
85
87{
88 btAssert((index >= 0) && (index < 6));
90 if (index < 3)
91 {
93 }
94 else
95 {
97 }
98}
99
101{
102 btAssert((index >= 0) && (index < 6));
103 m_equilibriumPoint[index] = val;
104}
105
107{
108 // it is assumed that calculateTransforms() have been called before this call
109 int i;
110 //btVector3 relVel = m_rbB.getLinearVelocity() - m_rbA.getLinearVelocity();
111 for (i = 0; i < 3; i++)
112 {
113 if (m_springEnabled[i])
114 {
115 // get current position of constraint
117 // calculate difference
119 // spring force is (delta * m_stiffness) according to Hooke's Law
124 }
125 }
126 for (i = 0; i < 3; i++)
127 {
128 if (m_springEnabled[i + 3])
129 {
130 // get current position of constraint
132 // calculate difference
134 // spring force is (-delta * m_stiffness) according to Hooke's Law
139 }
140 }
141}
142
144{
145 // this will be called by constraint solver at the constraint setup stage
146 // set current motor parameters
148 // do the rest of job for constraint setup
150}
151
153{
156 btVector3 xAxis = yAxis.cross(zAxis); // we want right coordinate system
157
160 frameInW.getBasis().setValue(xAxis[0], yAxis[0], zAxis[0],
161 xAxis[1], yAxis[1], zAxis[1],
162 xAxis[2], yAxis[2], zAxis[2]);
163
164 // now get constraint frame in local coordinate systems
167
169}
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:27
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btScalar btFabs(btScalar x)
Definition btScalar.h:497
#define btAssert(x)
Definition btScalar.h:153
@ D6_SPRING_CONSTRAINT_TYPE
btGeneric6DofConstraint between two rigidbodies each with a pivotpoint that descibes the axis locatio...
btTransform m_frameInA
relative_frames
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
btTransform m_frameInB
the constraint space w.r.t body B
btTranslationalLimitMotor m_linearLimits
Linear_Limit_parameters.
btRotationalLimitMotor m_angularLimits[3]
hinge_parameters
virtual void setAxis(const btVector3 &axis1, const btVector3 &axis2)
virtual void getInfo2(btConstraintInfo2 *info)
internal method used by the constraint solver, don't use them directly
void internalUpdateSprings(btConstraintInfo2 *info)
void setDamping(int index, btScalar damping)
void setStiffness(int index, btScalar stiffness)
btGeneric6DofSpringConstraint(btRigidBody &rbA, btRigidBody &rbB, const btTransform &frameInA, const btTransform &frameInB, bool useLinearReferenceFrameA)
The btRigidBody is the main class for rigid body objects.
Definition btRigidBody.h:60
const btTransform & getCenterOfMassTransform() const
btScalar m_targetVelocity
target motor velocity
btScalar m_maxMotorForce
max force on motor
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition btTransform.h:30
btTransform inverse() const
Return the inverse of this transform.
void setIdentity()
Set this transformation to the identity.
btVector3 m_maxMotorForce
max force on motor
btVector3 m_targetVelocity
target motor velocity
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btVector3 cross(const btVector3 &v) const
Return the cross product between this and another vector.
Definition btVector3.h:380
btVector3 normalized() const
Return a normalized version of this vector.
Definition btVector3.h:949