| Box2D 2.2.1 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

b2PulleyJoint.h

    00001 /*
    00002 * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
    00003 *
    00004 * This software is provided 'as-is', without any express or implied
    00005 * warranty.  In no event will the authors be held liable for any damages
    00006 * arising from the use of this software.
    00007 * Permission is granted to anyone to use this software for any purpose,
    00008 * including commercial applications, and to alter it and redistribute it
    00009 * freely, subject to the following restrictions:
    00010 * 1. The origin of this software must not be misrepresented; you must not
    00011 * claim that you wrote the original software. If you use this software
    00012 * in a product, an acknowledgment in the product documentation would be
    00013 * appreciated but is not required.
    00014 * 2. Altered source versions must be plainly marked as such, and must not be
    00015 * misrepresented as being the original software.
    00016 * 3. This notice may not be removed or altered from any source distribution.
    00017 */
    00018
    00019 #ifndef B2_PULLEY_JOINT_H
    00020 #define B2_PULLEY_JOINT_H
    00021
    00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
    00023
    00024 const float32 b2_minPulleyLength = 2.0f;
    00025
    00028 struct b2PulleyJointDef : public b2JointDef
    00029 {
    00030         b2PulleyJointDef()
    00031         {
    00032                 type = e_pulleyJoint;
    00033                 groundAnchorA.Set(-1.0f, 1.0f);
    00034                 groundAnchorB.Set(1.0f, 1.0f);
    00035                 localAnchorA.Set(-1.0f, 0.0f);
    00036                 localAnchorB.Set(1.0f, 0.0f);
    00037                 lengthA = 0.0f;
    00038                 lengthB = 0.0f;
    00039                 ratio = 1.0f;
    00040                 collideConnected = true;
    00041         }
    00042
    00044         void Initialize(b2Body* bodyA, b2Body* bodyB,
    00045                                         const b2Vec2& groundAnchorA, const b2Vec2& groundAnchorB,
    00046                                         const b2Vec2& anchorA, const b2Vec2& anchorB,
    00047                                         float32 ratio);
    00048
    00050         b2Vec2 groundAnchorA;
    00051
    00053         b2Vec2 groundAnchorB;
    00054
    00056         b2Vec2 localAnchorA;
    00057
    00059         b2Vec2 localAnchorB;
    00060
    00062         float32 lengthA;
    00063
    00065         float32 lengthB;
    00066
    00068         float32 ratio;
    00069 };
    00070
    00079 class b2PulleyJoint : public b2Joint
    00080 {
    00081 public:
    00082         b2Vec2 GetAnchorA() const;
    00083         b2Vec2 GetAnchorB() const;
    00084
    00085         b2Vec2 GetReactionForce(float32 inv_dt) const;
    00086         float32 GetReactionTorque(float32 inv_dt) const;
    00087
    00089         b2Vec2 GetGroundAnchorA() const;
    00090
    00092         b2Vec2 GetGroundAnchorB() const;
    00093
    00095         float32 GetLengthA() const;
    00096
    00098         float32 GetLengthB() const;
    00099
    00101         float32 GetRatio() const;
    00102
    00104         void Dump();
    00105
    00106 protected:
    00107
    00108         friend class b2Joint;
    00109         b2PulleyJoint(const b2PulleyJointDef* data);
    00110
    00111         void InitVelocityConstraints(const b2SolverData& data);
    00112         void SolveVelocityConstraints(const b2SolverData& data);
    00113         bool SolvePositionConstraints(const b2SolverData& data);
    00114
    00115         b2Vec2 m_groundAnchorA;
    00116         b2Vec2 m_groundAnchorB;
    00117         float32 m_lengthA;
    00118         float32 m_lengthB;
    00119
    00120         // Solver shared
    00121         b2Vec2 m_localAnchorA;
    00122         b2Vec2 m_localAnchorB;
    00123         float32 m_constant;
    00124         float32 m_ratio;
    00125         float32 m_impulse;
    00126
    00127         // Solver temp
    00128         int32 m_indexA;
    00129         int32 m_indexB;
    00130         b2Vec2 m_uA;
    00131         b2Vec2 m_uB;
    00132         b2Vec2 m_rA;
    00133         b2Vec2 m_rB;
    00134         b2Vec2 m_localCenterA;
    00135         b2Vec2 m_localCenterB;
    00136         float32 m_invMassA;
    00137         float32 m_invMassB;
    00138         float32 m_invIA;
    00139         float32 m_invIB;
    00140         float32 m_mass;
    00141 };
    00142
    00143 #endif

All Classes Files Functions Variables Enumerations Enumerator Defines