cococococos 2 d-xノード(b 2 Weld Joint.h)API


本論文はhttp://blog.csdn.net/runaying ,引用は出典を明記しなければならない!
cococococos 2 d-xノード(b 2 Weld Joint.h)API
みなさんがよりよく勉強できるように、私のブログを見ることを強くおすすめします. Cocos 2 d-X権威ガイドノート
//Weld(溶接)jointsは二つのbodiesを一緒に貼り付けることができます.ウエルド(溶接)jointsは少し歪んでいるかもしれません.
//island制約ソルバは近似的なので
///cocos2d-x-3.0alpha0/external/Box2D/Dynamics/Joints
/// Weld(  )joints(  )      bodies      . Weld(  )joints(  )      
///    island          

#ifndef B2_WELD_JOINT_H
#define B2_WELD_JOINT_H

#include <Box2D/Dynamics/Joints/b2Joint.h>

/// Weld(  )joints(  )  .          ,       ,      
///    reaction(  )            
struct b2WeldJointDef : public b2JointDef
{
    b2WeldJointDef()
    {
        type = e_weldJoint;
        localAnchorA.Set(0.0f, 0.0f);
        localAnchorB.Set(0.0f, 0.0f);
        referenceAngle = 0.0f;
        frequencyHz = 0.0f;
        dampingRatio = 0.0f;
    }

    /// Initialize the bodies, anchors, and reference(  ) angle using a world
    /// anchor point.
    void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);

    ///     bodyA's        .
    b2Vec2 localAnchorA;

    ///     bodyB's        .
    b2Vec2 localAnchorB;

    /// The bodyB angle minus(  ) bodyA angle in the reference state (radians).     //  
    float32 referenceAngle;
    
    /// The mass-spring-damper(   -    -   ) frequency(  ) in Hertz. Rotation(  ) only.
    ///     0         
    float32 frequencyHz;

    /// The damping ratio. 0 = no damping, 1 = critical damping.        //  
    float32 dampingRatio;
};

/// Weld(  )joints(  )      bodies      . Weld(  )joints(  )      
///    island          
class b2WeldJoint : public b2Joint
{
public:
    b2Vec2 GetAnchorA() const;
    b2Vec2 GetAnchorB() const;

    b2Vec2 GetReactionForce(float32 inv_dt) const;
    float32 GetReactionTorque(float32 inv_dt) const;

    ///     bodyA's        .
    const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }

    ///     bodyB's        .
    const b2Vec2& GetLocalAnchorB() const  { return m_localAnchorB; }

    /// Get the reference angle.    //  
    float32 GetReferenceAngle() const { return m_referenceAngle; }

    /// Set/get frequency in Hz.        //  
    void SetFrequency(float32 hz) { m_frequencyHz = hz; }
    float32 GetFrequency() const { return m_frequencyHz; }

    /// Set/get damping ratio.          //    
    void SetDampingRatio(float32 ratio) { m_dampingRatio = ratio; }
    float32 GetDampingRatio() const { return m_dampingRatio; }

    ///        b2Log.
    void Dump();

protected:

    friend class b2Joint;

    b2WeldJoint(const b2WeldJointDef* def);

    void InitVelocityConstraints(const b2SolverData& data);
    void SolveVelocityConstraints(const b2SolverData& data);
    bool SolvePositionConstraints(const b2SolverData& data);

    float32 m_frequencyHz;
    float32 m_dampingRatio;
    float32 m_bias;

    // Solver shared
    b2Vec2 m_localAnchorA;
    b2Vec2 m_localAnchorB;
    float32 m_referenceAngle;
    float32 m_gamma;
    b2Vec3 m_impulse;

    // Solver temp
    int32 m_indexA;
    int32 m_indexB;
    b2Vec2 m_rA;
    b2Vec2 m_rB;
    b2Vec2 m_localCenterA;
    b2Vec2 m_localCenterB;
    float32 m_invMassA;
    float32 m_invMassB;
    float32 m_invIA;
    float32 m_invIB;
    b2Mat33 m_mass;
};

#endif