Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/external/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.h @ 6271

Last change on this file since 6271 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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/* Hinge Constraint by Dirk Gregorius. Limits added by Marcus Hennix at Starbreeze Studios */
17
18#ifndef HINGECONSTRAINT_H
19#define HINGECONSTRAINT_H
20
21#include "LinearMath/btVector3.h"
22#include "btJacobianEntry.h"
23#include "btTypedConstraint.h"
24
25class btRigidBody;
26
27/// hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space
28/// axis defines the orientation of the hinge axis
29class btHingeConstraint : public btTypedConstraint
30{
31#ifdef IN_PARALLELL_SOLVER
32public:
33#endif
34        btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
35        btJacobianEntry m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor
36
37        btTransform m_rbAFrame; // constraint axii. Assumes z is hinge axis.
38        btTransform m_rbBFrame;
39
40        btScalar        m_motorTargetVelocity;
41        btScalar        m_maxMotorImpulse;
42
43        btScalar        m_limitSoftness; 
44        btScalar        m_biasFactor; 
45        btScalar    m_relaxationFactor; 
46
47        btScalar    m_lowerLimit;       
48        btScalar    m_upperLimit;       
49       
50        btScalar        m_kHinge;
51
52        btScalar        m_limitSign;
53        btScalar        m_correction;
54
55        btScalar        m_accLimitImpulse;
56        btScalar        m_hingeAngle;
57        btScalar    m_referenceSign;
58
59        bool            m_angularOnly;
60        bool            m_enableAngularMotor;
61        bool            m_solveLimit;
62        bool            m_useSolveConstraintObsolete;
63        bool            m_useReferenceFrameA;
64
65       
66public:
67
68        btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, btVector3& axisInA,btVector3& axisInB, bool useReferenceFrameA = false);
69
70        btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA, bool useReferenceFrameA = false);
71       
72        btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame, bool useReferenceFrameA = false);
73
74        btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame, bool useReferenceFrameA = false);
75
76        btHingeConstraint();
77
78        virtual void    buildJacobian();
79
80        virtual void getInfo1 (btConstraintInfo1* info);
81
82        virtual void getInfo2 (btConstraintInfo2* info);
83       
84        virtual void    solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar        timeStep);
85
86        void    updateRHS(btScalar      timeStep);
87
88        const btRigidBody& getRigidBodyA() const
89        {
90                return m_rbA;
91        }
92        const btRigidBody& getRigidBodyB() const
93        {
94                return m_rbB;
95        }
96
97        btRigidBody& getRigidBodyA()   
98        {               
99                return m_rbA;   
100        }       
101
102        btRigidBody& getRigidBodyB()   
103        {               
104                return m_rbB;   
105        }       
106       
107        void    setAngularOnly(bool angularOnly)
108        {
109                m_angularOnly = angularOnly;
110        }
111
112        void    enableAngularMotor(bool enableMotor,btScalar targetVelocity,btScalar maxMotorImpulse)
113        {
114                m_enableAngularMotor  = enableMotor;
115                m_motorTargetVelocity = targetVelocity;
116                m_maxMotorImpulse = maxMotorImpulse;
117        }
118
119        void    setLimit(btScalar low,btScalar high,btScalar _softness = 0.9f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
120        {
121                m_lowerLimit = low;
122                m_upperLimit = high;
123
124                m_limitSoftness =  _softness;
125                m_biasFactor = _biasFactor;
126                m_relaxationFactor = _relaxationFactor;
127
128        }
129
130        btScalar        getLowerLimit() const
131        {
132                return m_lowerLimit;
133        }
134
135        btScalar        getUpperLimit() const
136        {
137                return m_upperLimit;
138        }
139
140
141        btScalar getHingeAngle();
142
143        void testLimit();
144
145
146        const btTransform& getAFrame() { return m_rbAFrame; }; 
147        const btTransform& getBFrame() { return m_rbBFrame; };
148
149        inline int getSolveLimit()
150        {
151                return m_solveLimit;
152        }
153
154        inline btScalar getLimitSign()
155        {
156                return m_limitSign;
157        }
158
159        inline bool getAngularOnly() 
160        { 
161                return m_angularOnly; 
162        }
163        inline bool getEnableAngularMotor() 
164        { 
165                return m_enableAngularMotor; 
166        }
167        inline btScalar getMotorTargetVelosity() 
168        { 
169                return m_motorTargetVelocity; 
170        }
171        inline btScalar getMaxMotorImpulse() 
172        { 
173                return m_maxMotorImpulse; 
174        }
175
176};
177
178#endif //HINGECONSTRAINT_H
Note: See TracBrowser for help on using the repository browser.