| Box2D 2.2.1 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

b2MouseJoint.h

    00001 /*
    00002 * Copyright (c) 2006-2007 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_MOUSE_JOINT_H
    00020 #define B2_MOUSE_JOINT_H
    00021
    00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
    00023
    00026 struct b2MouseJointDef : public b2JointDef
    00027 {
    00028         b2MouseJointDef()
    00029         {
    00030                 type = e_mouseJoint;
    00031                 target.Set(0.0f, 0.0f);
    00032                 maxForce = 0.0f;
    00033                 frequencyHz = 5.0f;
    00034                 dampingRatio = 0.7f;
    00035         }
    00036
    00039         b2Vec2 target;
    00040
    00044         float32 maxForce;
    00045
    00047         float32 frequencyHz;
    00048
    00050         float32 dampingRatio;
    00051 };
    00052
    00060 class b2MouseJoint : public b2Joint
    00061 {
    00062 public:
    00063
    00065         b2Vec2 GetAnchorA() const;
    00066
    00068         b2Vec2 GetAnchorB() const;
    00069
    00071         b2Vec2 GetReactionForce(float32 inv_dt) const;
    00072
    00074         float32 GetReactionTorque(float32 inv_dt) const;
    00075
    00077         void SetTarget(const b2Vec2& target);
    00078         const b2Vec2& GetTarget() const;
    00079
    00081         void SetMaxForce(float32 force);
    00082         float32 GetMaxForce() const;
    00083
    00085         void SetFrequency(float32 hz);
    00086         float32 GetFrequency() const;
    00087
    00089         void SetDampingRatio(float32 ratio);
    00090         float32 GetDampingRatio() const;
    00091
    00093         void Dump() { b2Log("Mouse joint dumping is not supported.\n"); }
    00094
    00095 protected:
    00096         friend class b2Joint;
    00097
    00098         b2MouseJoint(const b2MouseJointDef* def);
    00099
    00100         void InitVelocityConstraints(const b2SolverData& data);
    00101         void SolveVelocityConstraints(const b2SolverData& data);
    00102         bool SolvePositionConstraints(const b2SolverData& data);
    00103
    00104         b2Vec2 m_localAnchorB;
    00105         b2Vec2 m_targetA;
    00106         float32 m_frequencyHz;
    00107         float32 m_dampingRatio;
    00108         float32 m_beta;
    00109
    00110         // Solver shared
    00111         b2Vec2 m_impulse;
    00112         float32 m_maxForce;
    00113         float32 m_gamma;
    00114
    00115         // Solver temp
    00116         int32 m_indexA;
    00117         int32 m_indexB;
    00118         b2Vec2 m_rB;
    00119         b2Vec2 m_localCenterB;
    00120         float32 m_invMassB;
    00121         float32 m_invIB;
    00122         b2Mat22 m_mass;
    00123         b2Vec2 m_C;
    00124 };
    00125
    00126 #endif

All Classes Files Functions Variables Enumerations Enumerator Defines