Update Joint
This commit is contained in:
parent
b0b02ddf62
commit
6d77d9ed74
|
|
@ -580,6 +580,7 @@ namespace kiwano
|
||||||
raw_joint_ = static_cast<b2WeldJoint*>(GetB2Joint());
|
raw_joint_ = static_cast<b2WeldJoint*>(GetB2Joint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// WheelJoint
|
// WheelJoint
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,8 @@ namespace kiwano
|
||||||
Joint(World* world, b2JointDef* joint_def);
|
Joint(World* world, b2JointDef* joint_def);
|
||||||
virtual ~Joint();
|
virtual ~Joint();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 初始化关节
|
||||||
void Init(World* world, b2JointDef* joint_def);
|
void Init(World* world, b2JointDef* joint_def);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -125,10 +127,10 @@ namespace kiwano
|
||||||
/// @brief 固定距离关节参数
|
/// @brief 固定距离关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor_a; ///< 物体A的锚点位置
|
Point anchor_a; ///< 关节在物体A上的连接点
|
||||||
Point anchor_b; ///< 物体B的锚点位置
|
Point anchor_b; ///< 关节在物体B上的连接点
|
||||||
float frequency_hz; ///< 弹簧阻尼器频率
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio; ///< 阻尼比
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -164,16 +166,25 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置关节长度
|
/// @brief 设置关节长度
|
||||||
void SetLength(float length);
|
void SetLength(float length);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节长度
|
||||||
float GetLength() const;
|
float GetLength() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置弹簧阻尼器频率 [赫兹]
|
/// @brief 设置弹簧响应速度 [赫兹]
|
||||||
void SetFrequency(float hz);
|
void SetFrequency(float hz);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取弹簧响应速度 [赫兹]
|
||||||
float GetFrequency() const;
|
float GetFrequency() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置阻尼比
|
/// @brief 设置阻尼率
|
||||||
void SetDampingRatio(float ratio);
|
void SetDampingRatio(float ratio);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取阻尼率
|
||||||
float GetDampingRatio() const;
|
float GetDampingRatio() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -189,9 +200,9 @@ namespace kiwano
|
||||||
public:
|
public:
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor;
|
Point anchor; ///< 摩擦作用点
|
||||||
float max_force;
|
float max_force; ///< 最大摩擦力
|
||||||
float max_torque;
|
float max_torque; ///< 最大扭力
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -222,13 +233,19 @@ namespace kiwano
|
||||||
FrictionJoint(World* world, Param const& param);
|
FrictionJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大摩擦力
|
/// @brief 设置最大摩擦力
|
||||||
void SetMaxForce(float force);
|
void SetMaxForce(float force);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大摩擦力
|
||||||
float GetMaxForce() const;
|
float GetMaxForce() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大转矩
|
/// @brief 设置最大转矩
|
||||||
void SetMaxTorque(float torque);
|
void SetMaxTorque(float torque);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大转矩
|
||||||
float GetMaxTorque() const;
|
float GetMaxTorque() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -246,8 +263,8 @@ namespace kiwano
|
||||||
/// @brief 齿轮关节参数
|
/// @brief 齿轮关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
JointPtr joint_a; ///< 关节A
|
JointPtr joint_a; ///< 关节A(旋转关节/平移关节)
|
||||||
JointPtr joint_b; ///< 关节B
|
JointPtr joint_b; ///< 关节B(旋转关节/平移关节)
|
||||||
float ratio; ///< 齿轮传动比
|
float ratio; ///< 齿轮传动比
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
|
|
@ -277,6 +294,9 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定齿轮传动比
|
/// @brief 设定齿轮传动比
|
||||||
void SetRatio(float ratio);
|
void SetRatio(float ratio);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取齿轮传动比
|
||||||
float GetRatio() const;
|
float GetRatio() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -327,13 +347,19 @@ namespace kiwano
|
||||||
MotorJoint(World* world, Param const& param);
|
MotorJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大摩擦力
|
/// @brief 设置最大摩擦力
|
||||||
void SetMaxForce(float force);
|
void SetMaxForce(float force);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大摩擦力
|
||||||
float GetMaxForce() const;
|
float GetMaxForce() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大转矩
|
/// @brief 设置最大转矩
|
||||||
void SetMaxTorque(float torque);
|
void SetMaxTorque(float torque);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大转矩
|
||||||
float GetMaxTorque() const;
|
float GetMaxTorque() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -351,12 +377,12 @@ namespace kiwano
|
||||||
/// @brief 平移关节参数
|
/// @brief 平移关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor; ///< 锚点位置
|
Point anchor; ///< 关节位置
|
||||||
Vec2 axis; ///< 平移轴向量
|
Vec2 axis; ///< 物体A滑动的方向
|
||||||
bool enable_limit; ///< 关节限制开关
|
bool enable_limit; ///< 是否启用限制
|
||||||
float lower_translation; ///< 关节下限
|
float lower_translation; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
|
||||||
float upper_translation; ///< 关节上限
|
float upper_translation; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
|
||||||
bool enable_motor; ///< 马达开关
|
bool enable_motor; ///< 是否启用马达
|
||||||
float max_motor_force; ///< 最大马达力 [N]
|
float max_motor_force; ///< 最大马达力 [N]
|
||||||
float motor_speed; ///< 马达转速 [degree/s]
|
float motor_speed; ///< 马达转速 [degree/s]
|
||||||
|
|
||||||
|
|
@ -418,27 +444,45 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 是否启用关节限制
|
/// @brief 是否启用关节限制
|
||||||
bool IsLimitEnabled() const;
|
bool IsLimitEnabled() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置是否启用关节限制
|
||||||
void EnableLimit(bool flag);
|
void EnableLimit(bool flag);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置关节限制
|
/// @brief 获取平移最小限制
|
||||||
float GetLowerLimit() const;
|
float GetLowerLimit() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取平移最大限制
|
||||||
float GetUpperLimit() const;
|
float GetUpperLimit() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置关节限制
|
||||||
void SetLimits(float lower, float upper);
|
void SetLimits(float lower, float upper);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 是否启用马达
|
/// @brief 是否启用马达
|
||||||
bool IsMotorEnabled() const;
|
bool IsMotorEnabled() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置是否启用马达
|
||||||
void EnableMotor(bool flag);
|
void EnableMotor(bool flag);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置马达转速 [degree/s]
|
/// @brief 设置马达转速 [degree/s]
|
||||||
void SetMotorSpeed(float speed);
|
void SetMotorSpeed(float speed);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取马达转速 [degree/s]
|
||||||
float GetMotorSpeed() const;
|
float GetMotorSpeed() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大马达力 [N]
|
/// @brief 设置最大马达力 [N]
|
||||||
void SetMaxMotorForce(float force);
|
void SetMaxMotorForce(float force);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大马达力 [N]
|
||||||
float GetMaxMotorForce() const;
|
float GetMaxMotorForce() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -456,11 +500,11 @@ namespace kiwano
|
||||||
/// @brief 滑轮关节参数
|
/// @brief 滑轮关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor_a; ///<
|
Point anchor_a; ///< 关节在物体A上的作用点
|
||||||
Point anchor_b; ///<
|
Point anchor_b; ///< 关节在物体B上的作用点
|
||||||
Point ground_anchor_a; ///<
|
Point ground_anchor_a; ///< 物体A对应的滑轮的位置
|
||||||
Point ground_anchor_b; ///<
|
Point ground_anchor_b; ///< 物体B对应的滑轮的位置
|
||||||
float ratio; ///<
|
float ratio; ///< 滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -496,15 +540,32 @@ namespace kiwano
|
||||||
PulleyJoint(World* world, b2PulleyJointDef* def);
|
PulleyJoint(World* world, b2PulleyJointDef* def);
|
||||||
PulleyJoint(World* world, Param const& param);
|
PulleyJoint(World* world, Param const& param);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 物体A对应的滑轮的位置
|
||||||
Point GetGroundAnchorA() const;
|
Point GetGroundAnchorA() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 物体B对应的滑轮的位置
|
||||||
Point GetGroundAnchorB() const;
|
Point GetGroundAnchorB() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取滑轮传动比
|
||||||
float GetRatio() const;
|
float GetRatio() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取物体A与滑轮的距离
|
||||||
float GetLengthA() const;
|
float GetLengthA() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取物体B与滑轮的距离
|
||||||
float GetLengthB() const;
|
float GetLengthB() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取物体A与滑轮的当前距离
|
||||||
float GetCurrentLengthA() const;
|
float GetCurrentLengthA() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取物体B与滑轮的当前距离
|
||||||
float GetCurrentLengthB() const;
|
float GetCurrentLengthB() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -518,15 +579,17 @@ namespace kiwano
|
||||||
: public Joint
|
: public Joint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 旋转关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor;
|
Point anchor; ///< 关节位置
|
||||||
bool enable_limit;
|
bool enable_limit; ///< 是否启用限制
|
||||||
float lower_angle;
|
float lower_angle; ///< 移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
|
||||||
float upper_angle;
|
float upper_angle; ///< 移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
|
||||||
bool enable_motor;
|
bool enable_motor; ///< 是否启用马达
|
||||||
float max_motor_torque;
|
float max_motor_torque; ///< 最大马达力 [N]
|
||||||
float motor_speed;
|
float motor_speed; ///< 马达转速 [degree/s]
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -568,28 +631,60 @@ namespace kiwano
|
||||||
RevoluteJoint(World* world, b2RevoluteJointDef* def);
|
RevoluteJoint(World* world, b2RevoluteJointDef* def);
|
||||||
RevoluteJoint(World* world, Param const& param);
|
RevoluteJoint(World* world, Param const& param);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取参考角
|
||||||
float GetReferenceAngle() const;
|
float GetReferenceAngle() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节角度
|
||||||
float GetJointAngle() const;
|
float GetJointAngle() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节速度
|
||||||
float GetJointSpeed() const;
|
float GetJointSpeed() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 是否启用关节限制
|
||||||
bool IsLimitEnabled() const;
|
bool IsLimitEnabled() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置是否启用关节限制
|
||||||
void EnableLimit(bool flag);
|
void EnableLimit(bool flag);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取平移最小限制
|
||||||
float GetLowerLimit() const;
|
float GetLowerLimit() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取平移最大限制
|
||||||
float GetUpperLimit() const;
|
float GetUpperLimit() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置关节限制
|
||||||
void SetLimits(float lower, float upper);
|
void SetLimits(float lower, float upper);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 是否启用马达
|
||||||
bool IsMotorEnabled() const;
|
bool IsMotorEnabled() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置是否启用马达
|
||||||
void EnableMotor(bool flag);
|
void EnableMotor(bool flag);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置马达转速 [degree/s]
|
/// @brief 设置马达转速 [degree/s]
|
||||||
void SetMotorSpeed(float speed);
|
void SetMotorSpeed(float speed);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取马达转速 [degree/s]
|
||||||
float GetMotorSpeed() const;
|
float GetMotorSpeed() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大马达转矩 [N/m]
|
/// @brief 设置最大马达转矩 [N/m]
|
||||||
void SetMaxMotorTorque(float torque);
|
void SetMaxMotorTorque(float torque);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大马达转矩 [N/m]
|
||||||
float GetMaxMotorTorque() const;
|
float GetMaxMotorTorque() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -603,11 +698,13 @@ namespace kiwano
|
||||||
: public Joint
|
: public Joint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 绳关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point local_anchor_a;
|
Point local_anchor_a; ///< 关节在物体A上的连接点
|
||||||
Point local_anchor_b;
|
Point local_anchor_b; ///< 关节在物体B上的连接点
|
||||||
float max_length;
|
float max_length; ///< 绳索最大长度
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -637,7 +734,12 @@ namespace kiwano
|
||||||
RopeJoint(World* world, b2RopeJointDef* def);
|
RopeJoint(World* world, b2RopeJointDef* def);
|
||||||
RopeJoint(World* world, Param const& param);
|
RopeJoint(World* world, Param const& param);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置关节最大长度
|
||||||
void SetMaxLength(float length);
|
void SetMaxLength(float length);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节最大长度
|
||||||
float GetMaxLength() const;
|
float GetMaxLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -651,11 +753,13 @@ namespace kiwano
|
||||||
: public Joint
|
: public Joint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 焊接关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor;
|
Point anchor; ///< 焊接位置
|
||||||
float frequency_hz;
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio;
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -686,13 +790,23 @@ namespace kiwano
|
||||||
WeldJoint(World* world, Param const& param);
|
WeldJoint(World* world, Param const& param);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置弹簧阻尼器频率 [赫兹]
|
/// @brief 获取物体B相对于物体A的角度
|
||||||
|
float GetReferenceAngle() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置弹簧响应速度 [赫兹]
|
||||||
void SetFrequency(float hz);
|
void SetFrequency(float hz);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取弹簧响应速度 [赫兹]
|
||||||
float GetFrequency() const;
|
float GetFrequency() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置阻尼比
|
/// @brief 设置阻尼率
|
||||||
void SetDampingRatio(float ratio);
|
void SetDampingRatio(float ratio);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取阻尼率
|
||||||
float GetDampingRatio() const;
|
float GetDampingRatio() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -706,15 +820,17 @@ namespace kiwano
|
||||||
: public Joint
|
: public Joint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 轮关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point anchor;
|
Point anchor; ///< 轮关节位置
|
||||||
Vec2 axis;
|
Vec2 axis; ///< 物体A滑动方向
|
||||||
bool enable_motor;
|
bool enable_motor; ///< 是否启用马达
|
||||||
float max_motor_torque;
|
float max_motor_torque; ///< 最大马达力 [N]
|
||||||
float motor_speed;
|
float motor_speed; ///< 马达转速 [degree/s]
|
||||||
float frequency_hz;
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio;
|
float damping_ratio; ///< 弹簧阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -756,28 +872,60 @@ namespace kiwano
|
||||||
WheelJoint(World* world, b2WheelJointDef* def);
|
WheelJoint(World* world, b2WheelJointDef* def);
|
||||||
WheelJoint(World* world, Param const& param);
|
WheelJoint(World* world, Param const& param);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节当前的平移距离
|
||||||
float GetJointTranslation() const;
|
float GetJointTranslation() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节当前的线性速度
|
||||||
float GetJointLinearSpeed() const;
|
float GetJointLinearSpeed() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节当前的角度
|
||||||
float GetJointAngle() const;
|
float GetJointAngle() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取关节当前的旋转速度
|
||||||
float GetJointAngularSpeed() const;
|
float GetJointAngularSpeed() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 是否启用马达
|
||||||
bool IsMotorEnabled() const;
|
bool IsMotorEnabled() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置是否启用马达
|
||||||
void EnableMotor(bool flag);
|
void EnableMotor(bool flag);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置马达转速 [degree/s]
|
/// @brief 设置马达转速 [degree/s]
|
||||||
void SetMotorSpeed(float speed);
|
void SetMotorSpeed(float speed);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取马达转速 [degree/s]
|
||||||
float GetMotorSpeed() const;
|
float GetMotorSpeed() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大马达转矩 [N/m]
|
/// @brief 设置最大马达转矩 [N/m]
|
||||||
void SetMaxMotorTorque(float torque);
|
void SetMaxMotorTorque(float torque);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大马达转矩 [N/m]
|
||||||
float GetMaxMotorTorque() const;
|
float GetMaxMotorTorque() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置弹簧响应速度
|
||||||
void SetSpringFrequencyHz(float hz);
|
void SetSpringFrequencyHz(float hz);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取弹簧响应速度
|
||||||
float GetSpringFrequencyHz() const;
|
float GetSpringFrequencyHz() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置弹簧阻尼率
|
||||||
void SetSpringDampingRatio(float ratio);
|
void SetSpringDampingRatio(float ratio);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取弹簧阻尼率
|
||||||
float GetSpringDampingRatio() const;
|
float GetSpringDampingRatio() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -792,12 +940,14 @@ namespace kiwano
|
||||||
: public Joint
|
: public Joint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 鼠标关节参数
|
||||||
struct Param : public Joint::ParamBase
|
struct Param : public Joint::ParamBase
|
||||||
{
|
{
|
||||||
Point target;
|
Point target; ///< 关节作用目标位置
|
||||||
float max_force;
|
float max_force; ///< 作用在物体A上的最大力
|
||||||
float frequency_hz;
|
float frequency_hz; ///< 响应速度,数值越高关节响应的速度越快,看上去越坚固
|
||||||
float damping_ratio;
|
float damping_ratio; ///< 阻尼率,值越大关节运动阻尼越大
|
||||||
|
|
||||||
Param(
|
Param(
|
||||||
Body* body_a,
|
Body* body_a,
|
||||||
|
|
@ -826,16 +976,25 @@ namespace kiwano
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设定最大摩擦力 [N]
|
/// @brief 设定最大摩擦力 [N]
|
||||||
void SetMaxForce(float force);
|
void SetMaxForce(float force);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取最大摩擦力 [N]
|
||||||
float GetMaxForce() const;
|
float GetMaxForce() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置响应速度 [hz]
|
/// @brief 设置响应速度 [hz]
|
||||||
void SetFrequency(float hz);
|
void SetFrequency(float hz);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取响应速度 [hz]
|
||||||
float GetFrequency() const;
|
float GetFrequency() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置阻尼比
|
/// @brief 设置阻尼率
|
||||||
void SetDampingRatio(float ratio);
|
void SetDampingRatio(float ratio);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取阻尼率
|
||||||
float GetDampingRatio() const;
|
float GetDampingRatio() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -871,10 +1030,12 @@ namespace kiwano
|
||||||
inline void RevoluteJoint::SetMotorSpeed(float speed) { KGE_ASSERT(raw_joint_); raw_joint_->SetMotorSpeed(math::Degree2Radian(speed)); }
|
inline void RevoluteJoint::SetMotorSpeed(float speed) { KGE_ASSERT(raw_joint_); raw_joint_->SetMotorSpeed(math::Degree2Radian(speed)); }
|
||||||
inline float RevoluteJoint::GetMotorSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetMotorSpeed()); }
|
inline float RevoluteJoint::GetMotorSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetMotorSpeed()); }
|
||||||
|
|
||||||
|
inline float WeldJoint::GetReferenceAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetReferenceAngle()); }
|
||||||
inline void WeldJoint::SetFrequency(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetFrequency(hz); }
|
inline void WeldJoint::SetFrequency(float hz) { KGE_ASSERT(raw_joint_); raw_joint_->SetFrequency(hz); }
|
||||||
inline float WeldJoint::GetFrequency() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetFrequency(); }
|
inline float WeldJoint::GetFrequency() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetFrequency(); }
|
||||||
inline void WeldJoint::SetDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetDampingRatio(ratio); }
|
inline void WeldJoint::SetDampingRatio(float ratio) { KGE_ASSERT(raw_joint_); raw_joint_->SetDampingRatio(ratio); }
|
||||||
inline float WeldJoint::GetDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetDampingRatio(); }
|
inline float WeldJoint::GetDampingRatio() const { KGE_ASSERT(raw_joint_); return raw_joint_->GetDampingRatio(); }
|
||||||
|
|
||||||
inline float WheelJoint::GetJointAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngle()); }
|
inline float WheelJoint::GetJointAngle() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngle()); }
|
||||||
inline float WheelJoint::GetJointAngularSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngularSpeed()); }
|
inline float WheelJoint::GetJointAngularSpeed() const { KGE_ASSERT(raw_joint_); return math::Radian2Degree(raw_joint_->GetJointAngularSpeed()); }
|
||||||
inline bool WheelJoint::IsMotorEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsMotorEnabled(); }
|
inline bool WheelJoint::IsMotorEnabled() const { KGE_ASSERT(raw_joint_); return raw_joint_->IsMotorEnabled(); }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue