cocos2d-x节点(b2FrictionJoint.h)API

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

cocos2d-x节点(b2FrictionJoint.h)API

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

//摩擦joints(接头)的定义.可以设置最大摩擦力,最大力矩

///cocos2d-x-3.0alpha0/external/Box2D/Dynamics/Joints
//摩擦joints(接头)的定义.可以设置最大摩擦力,最大力矩

#ifndef B2_FRICTION_JOINT_H
#define B2_FRICTION_JOINT_H

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

/// 摩擦joints(接头)的定义.
struct b2FrictionJointDef : public b2JointDef
{
    b2FrictionJointDef()
    {
        type = e_frictionJoint;
        localAnchorA.SetZero();
        localAnchorB.SetZero();
        maxForce = 0.0f;
        maxTorque = 0.0f;
    }

    /// 初始化 bodies, anchors(锚点), axis(轴), and reference angle using the world
    /// anchor(锚点) and world axis(轴).
    void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);

    /// 本地锚点相对 bodyA's 原点.
    b2Vec2 localAnchorA;

    /// 本地锚点相对 bodyB's 原点.
    b2Vec2 localAnchorB;

    /// 最大摩擦力,单位是 N.
    float32 maxForce;

    /// 最大摩擦力矩,单位是 N-m.
    float32 maxTorque;
};

/// 摩擦 joints(接头). 这是 top-down 摩擦.
/// 它提供了二维平移摩擦和摩擦角
class b2FrictionJoint : 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; }

    /// Set 最大的摩擦力单位是 N.
    void SetMaxForce(float32 force);

    /// 获取最大的摩擦力单位是 N.
    float32 GetMaxForce() const;

    /// Set 最大摩擦力矩,单位是 N*m.
    void SetMaxTorque(float32 torque);

    /// Get 最大摩擦力矩,单位是 N*m.
    float32 GetMaxTorque() const;

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

protected:

    friend class b2Joint;

    b2FrictionJoint(const b2FrictionJointDef* def);

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

    b2Vec2 m_localAnchorA;
    b2Vec2 m_localAnchorB;

    // Solver shared
    b2Vec2 m_linearImpulse;
    float32 m_angularImpulse;
    float32 m_maxForce;
    float32 m_maxTorque;

    // 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;
    b2Mat22 m_linearMass;
    float32 m_angularMass;
};

#endif


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