cocos2d-x节点(b2GearJoint.h)API

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

cocos2d-x节点(b2GearJoint.h)API

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

//齿轮joints(接头),这个定义需要两个现有的旋转/移动 joints(接头)

///cocos2d-x-3.0alpha0/external/Box2D/Dynamics/Joints
//齿轮joints(接头),这个定义需要两个现有的 旋转/移动 joints(接头)

#ifndef B2_GEAR_JOINT_H
#define B2_GEAR_JOINT_H

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

/// 齿轮joints(接头)定义. 这个定义需要两个现有的
/// revolute or prismatic joints(接头)(任意组合都可以工作).        //  旋转/移动
struct b2GearJointDef : public b2JointDef
{
    b2GearJointDef()
    {
        type = e_gearJoint;
        joint1 = NULL;
        joint2 = NULL;
        ratio = 1.0f;
    }

    /// 第一个 revolute/prismatic joints(接头)连接到齿轮joints(接头).      //  旋转/移动
    b2Joint* joint1;

    /// 第二个 revolute/prismatic joints(接头)连接到齿轮joints(接头).      //  旋转/移动
    b2Joint* joint2;

    /// 齿轮比.
    /// @see b2GearJoint for explanation.
    float32 ratio;
};

//一个齿轮joints(接头)可以把两个 joints(接头)连接在一起。两个 joints(接头)一个可以 revolute 另一个可以 prismatic        旋转/移动
///  您指定的齿轮比率一起绑定运动:
/// coordinate1 + ratio * coordinate2 = constant        //协调,比率,不变
/// 该比率可以是正向或负向。如果一个 joints(接头)是 旋转的joints(接头),另一个 joints(接头) 是移动的joints(接头),
/// 那么该比率将具有单位长度或者 1/length 单元
/// @warning 如果 joints(接头)1或者 joints(接头)被破坏了,你需要手动销毁这个齿轮joints(接头)
class b2GearJoint : public b2Joint
{
public:
    b2Vec2 GetAnchorA() const;
    b2Vec2 GetAnchorB() const;

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

    /// Get the first joint.
    b2Joint* GetJoint1() { return m_joint1; }

    /// Get the second joint.
    b2Joint* GetJoint2() { return m_joint2; }

    /// Set/Get齿轮比率.
    void SetRatio(float32 ratio);
    float32 GetRatio() const;

    /// 把 joints(接头)的阻尼输出到 dmLog
    void Dump();

protected:

    friend class b2Joint;
    b2GearJoint(const b2GearJointDef* data);

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

    b2Joint* m_joint1;
    b2Joint* m_joint2;

    b2JointType m_typeA;
    b2JointType m_typeB;

    // Body A is connected to body C
    // Body B is connected to body D    //连接
    b2Body* m_bodyC;
    b2Body* m_bodyD;

    // Solver shared
    b2Vec2 m_localAnchorA;
    b2Vec2 m_localAnchorB;
    b2Vec2 m_localAnchorC;
    b2Vec2 m_localAnchorD;

    b2Vec2 m_localAxisC;
    b2Vec2 m_localAxisD;

    float32 m_referenceAngleA;
    float32 m_referenceAngleB;

    float32 m_constant;
    float32 m_ratio;

    float32 m_impulse;

    // Solver temp
    int32 m_indexA, m_indexB, m_indexC, m_indexD;
    b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD;
    float32 m_mA, m_mB, m_mC, m_mD;
    float32 m_iA, m_iB, m_iC, m_iD;
    b2Vec2 m_JvAC, m_JvBD;
    float32 m_JwA, m_JwB, m_JwC, m_JwD;
    float32 m_mass;
};

#endif


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