b2MotorJoint.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2006-2012 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_MOTOR_JOINT_H
00020 #define B2_MOTOR_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00025 struct b2MotorJointDef : public b2JointDef
00026 {
00027         b2MotorJointDef()
00028         {
00029                 type = e_motorJoint;
00030                 linearOffset.SetZero();
00031                 angularOffset = 0.0f;
00032                 maxForce = 1.0f;
00033                 maxTorque = 1.0f;
00034                 correctionFactor = 0.3f;
00035         }
00036 
00038         void Initialize(b2Body* bodyA, b2Body* bodyB);
00039 
00041         b2Vec2 linearOffset;
00042 
00044         float32 angularOffset;
00045         
00047         float32 maxForce;
00048 
00050         float32 maxTorque;
00051 
00053         float32 correctionFactor;
00054 };
00055 
00059 class b2MotorJoint : public b2Joint
00060 {
00061 public:
00062         b2Vec2 GetAnchorA() const;
00063         b2Vec2 GetAnchorB() const;
00064 
00065         b2Vec2 GetReactionForce(float32 inv_dt) const;
00066         float32 GetReactionTorque(float32 inv_dt) const;
00067 
00069         void SetLinearOffset(const b2Vec2& linearOffset);
00070         const b2Vec2& GetLinearOffset() const;
00071 
00073         void SetAngularOffset(float32 angularOffset);
00074         float32 GetAngularOffset() const;
00075 
00077         void SetMaxForce(float32 force);
00078 
00080         float32 GetMaxForce() const;
00081 
00083         void SetMaxTorque(float32 torque);
00084 
00086         float32 GetMaxTorque() const;
00087 
00089         void SetCorrectionFactor(float32 factor);
00090 
00092         float32 GetCorrectionFactor() const;
00093 
00095         void Dump();
00096 
00097 protected:
00098 
00099         friend class b2Joint;
00100 
00101         b2MotorJoint(const b2MotorJointDef* def);
00102 
00103         void InitVelocityConstraints(const b2SolverData& data);
00104         void SolveVelocityConstraints(const b2SolverData& data);
00105         bool SolvePositionConstraints(const b2SolverData& data);
00106 
00107         // Solver shared
00108         b2Vec2 m_linearOffset;
00109         float32 m_angularOffset;
00110         b2Vec2 m_linearImpulse;
00111         float32 m_angularImpulse;
00112         float32 m_maxForce;
00113         float32 m_maxTorque;
00114         float32 m_correctionFactor;
00115 
00116         // Solver temp
00117         int32 m_indexA;
00118         int32 m_indexB;
00119         b2Vec2 m_rA;
00120         b2Vec2 m_rB;
00121         b2Vec2 m_localCenterA;
00122         b2Vec2 m_localCenterB;
00123         b2Vec2 m_linearError;
00124         float32 m_angularError;
00125         float32 m_invMassA;
00126         float32 m_invMassB;
00127         float32 m_invIA;
00128         float32 m_invIB;
00129         b2Mat22 m_linearMass;
00130         float32 m_angularMass;
00131 };
00132 
00133 #endif


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 22:08:34