b2MouseJoint.h
Go to the documentation of this file.
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 
00096         void ShiftOrigin(const b2Vec2& newOrigin);
00097 
00098 protected:
00099         friend class b2Joint;
00100 
00101         b2MouseJoint(const b2MouseJointDef* def);
00102 
00103         void InitVelocityConstraints(const b2SolverData& data);
00104         void SolveVelocityConstraints(const b2SolverData& data);
00105         bool SolvePositionConstraints(const b2SolverData& data);
00106 
00107         b2Vec2 m_localAnchorB;
00108         b2Vec2 m_targetA;
00109         float32 m_frequencyHz;
00110         float32 m_dampingRatio;
00111         float32 m_beta;
00112         
00113         // Solver shared
00114         b2Vec2 m_impulse;
00115         float32 m_maxForce;
00116         float32 m_gamma;
00117 
00118         // Solver temp
00119         int32 m_indexA;
00120         int32 m_indexB;
00121         b2Vec2 m_rB;
00122         b2Vec2 m_localCenterB;
00123         float32 m_invMassB;
00124         float32 m_invIB;
00125         b2Mat22 m_mass;
00126         b2Vec2 m_C;
00127 };
00128 
00129 #endif


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