Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletDynamics/ConstraintSolver/btHingeConstraint.h @ 1963

Last change on this file since 1963 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 4.0 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
57        bool            m_angularOnly;
58        bool            m_enableAngularMotor;
59        bool            m_solveLimit;
60
61       
62public:
63
64        btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB, btVector3& axisInA,btVector3& axisInB);
65
66        btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA);
67       
68        btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btTransform& rbAFrame, const btTransform& rbBFrame);
69
70        btHingeConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
71
72        btHingeConstraint();
73
74        virtual void    buildJacobian();
75
76        virtual void    solveConstraint(btScalar        timeStep);
77
78        void    updateRHS(btScalar      timeStep);
79
80        const btRigidBody& getRigidBodyA() const
81        {
82                return m_rbA;
83        }
84        const btRigidBody& getRigidBodyB() const
85        {
86                return m_rbB;
87        }
88
89        void    setAngularOnly(bool angularOnly)
90        {
91                m_angularOnly = angularOnly;
92        }
93
94        void    enableAngularMotor(bool enableMotor,btScalar targetVelocity,btScalar maxMotorImpulse)
95        {
96                m_enableAngularMotor  = enableMotor;
97                m_motorTargetVelocity = targetVelocity;
98                m_maxMotorImpulse = maxMotorImpulse;
99        }
100
101        void    setLimit(btScalar low,btScalar high,btScalar _softness = 0.9f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
102        {
103                m_lowerLimit = low;
104                m_upperLimit = high;
105
106                m_limitSoftness =  _softness;
107                m_biasFactor = _biasFactor;
108                m_relaxationFactor = _relaxationFactor;
109
110        }
111
112        btScalar        getLowerLimit() const
113        {
114                return m_lowerLimit;
115        }
116
117        btScalar        getUpperLimit() const
118        {
119                return m_upperLimit;
120        }
121
122
123        btScalar getHingeAngle();
124
125
126        const btTransform& getAFrame() { return m_rbAFrame; }; 
127        const btTransform& getBFrame() { return m_rbBFrame; };
128
129        inline int getSolveLimit()
130        {
131                return m_solveLimit;
132        }
133
134        inline btScalar getLimitSign()
135        {
136                return m_limitSign;
137        }
138
139        inline bool getAngularOnly() 
140        { 
141                return m_angularOnly; 
142        }
143        inline bool getEnableAngularMotor() 
144        { 
145                return m_enableAngularMotor; 
146        }
147        inline btScalar getMotorTargetVelosity() 
148        { 
149                return m_motorTargetVelocity; 
150        }
151        inline btScalar getMaxMotorImpulse() 
152        { 
153                return m_maxMotorImpulse; 
154        }
155
156};
157
158#endif //HINGECONSTRAINT_H
Note: See TracBrowser for help on using the repository browser.