cocos2d-x节点(b2WeldJoint.h)API

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-x节点(b2WeldJoint.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

/// Weld(焊接)joints(接头)可以把两个 bodies粘贴在一起. Weld(焊接)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


你可能感兴趣的:(api,cocos2d,cocos2dx,cocos2d-x)