Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef B2_GEAR_JOINT_H
00020 #define B2_GEAR_JOINT_H
00021
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023
00026 struct b2GearJointDef : public b2JointDef
00027 {
00028 b2GearJointDef()
00029 {
00030 type = e_gearJoint;
00031 joint1 = NULL;
00032 joint2 = NULL;
00033 ratio = 1.0f;
00034 }
00035
00037 b2Joint* joint1;
00038
00040 b2Joint* joint2;
00041
00044 float32 ratio;
00045 };
00046
00056 class b2GearJoint : public b2Joint
00057 {
00058 public:
00059 b2Vec2 GetAnchorA() const;
00060 b2Vec2 GetAnchorB() const;
00061
00062 b2Vec2 GetReactionForce(float32 inv_dt) const;
00063 float32 GetReactionTorque(float32 inv_dt) const;
00064
00066 b2Joint* GetJoint1() { return m_joint1; }
00067
00069 b2Joint* GetJoint2() { return m_joint2; }
00070
00072 void SetRatio(float32 ratio);
00073 float32 GetRatio() const;
00074
00076 void Dump();
00077
00078 protected:
00079
00080 friend class b2Joint;
00081 b2GearJoint(const b2GearJointDef* data);
00082
00083 void InitVelocityConstraints(const b2SolverData& data);
00084 void SolveVelocityConstraints(const b2SolverData& data);
00085 bool SolvePositionConstraints(const b2SolverData& data);
00086
00087 b2Joint* m_joint1;
00088 b2Joint* m_joint2;
00089
00090 b2JointType m_typeA;
00091 b2JointType m_typeB;
00092
00093
00094
00095 b2Body* m_bodyC;
00096 b2Body* m_bodyD;
00097
00098
00099 b2Vec2 m_localAnchorA;
00100 b2Vec2 m_localAnchorB;
00101 b2Vec2 m_localAnchorC;
00102 b2Vec2 m_localAnchorD;
00103
00104 b2Vec2 m_localAxisC;
00105 b2Vec2 m_localAxisD;
00106
00107 float32 m_referenceAngleA;
00108 float32 m_referenceAngleB;
00109
00110 float32 m_constant;
00111 float32 m_ratio;
00112
00113 float32 m_impulse;
00114
00115
00116 int32 m_indexA, m_indexB, m_indexC, m_indexD;
00117 b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD;
00118 float32 m_mA, m_mB, m_mC, m_mD;
00119 float32 m_iA, m_iB, m_iC, m_iD;
00120 b2Vec2 m_JvAC, m_JvBD;
00121 float32 m_JwA, m_JwB, m_JwC, m_JwD;
00122 float32 m_mass;
00123 };
00124
00125 #endif