Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialFS09/src/bullet/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h @ 10256

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

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios
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
15Written by: Marcus Hennix
16*/
17
18
19
20#ifndef CONETWISTCONSTRAINT_H
21#define CONETWISTCONSTRAINT_H
22
23#include "LinearMath/btVector3.h"
24#include "btJacobianEntry.h"
25#include "btTypedConstraint.h"
26
27class btRigidBody;
28
29
30///btConeTwistConstraint can be used to simulate ragdoll joints (upper arm, leg etc)
31class btConeTwistConstraint : public btTypedConstraint
32{
33#ifdef IN_PARALLELL_SOLVER
34public:
35#endif
36        btJacobianEntry m_jac[3]; //3 orthogonal linear constraints
37
38        btTransform m_rbAFrame; 
39        btTransform m_rbBFrame;
40
41        btScalar        m_limitSoftness;
42        btScalar        m_biasFactor;
43        btScalar        m_relaxationFactor;
44
45        btScalar        m_swingSpan1;
46        btScalar        m_swingSpan2;
47        btScalar        m_twistSpan;
48
49        btVector3   m_swingAxis;
50        btVector3       m_twistAxis;
51
52        btScalar        m_kSwing;
53        btScalar        m_kTwist;
54
55        btScalar        m_twistLimitSign;
56        btScalar        m_swingCorrection;
57        btScalar        m_twistCorrection;
58
59        btScalar        m_accSwingLimitImpulse;
60        btScalar        m_accTwistLimitImpulse;
61
62        bool            m_angularOnly;
63        bool            m_solveTwistLimit;
64        bool            m_solveSwingLimit;
65
66       
67public:
68
69        btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTransform& rbAFrame, const btTransform& rbBFrame);
70       
71        btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
72
73        btConeTwistConstraint();
74
75        virtual void    buildJacobian();
76
77        virtual void    solveConstraint(btScalar        timeStep);
78
79        void    updateRHS(btScalar      timeStep);
80
81        const btRigidBody& getRigidBodyA() const
82        {
83                return m_rbA;
84        }
85        const btRigidBody& getRigidBodyB() const
86        {
87                return m_rbB;
88        }
89
90        void    setAngularOnly(bool angularOnly)
91        {
92                m_angularOnly = angularOnly;
93        }
94
95        void    setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan,  btScalar _softness = 0.8f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
96        {
97                m_swingSpan1 = _swingSpan1;
98                m_swingSpan2 = _swingSpan2;
99                m_twistSpan  = _twistSpan;
100
101                m_limitSoftness =  _softness;
102                m_biasFactor = _biasFactor;
103                m_relaxationFactor = _relaxationFactor;
104        }
105
106        const btTransform& getAFrame() { return m_rbAFrame; }; 
107        const btTransform& getBFrame() { return m_rbBFrame; };
108
109        inline int getSolveTwistLimit()
110        {
111                return m_solveTwistLimit;
112        }
113
114        inline int getSolveSwingLimit()
115        {
116                return m_solveTwistLimit;
117        }
118
119        inline btScalar getTwistLimitSign()
120        {
121                return m_twistLimitSign;
122        }
123
124};
125
126#endif //CONETWISTCONSTRAINT_H
Note: See TracBrowser for help on using the repository browser.