本文整理汇总了C++中PrismaticJoint::GetWorldAnchorA方法的典型用法代码示例。如果您正苦于以下问题:C++ PrismaticJoint::GetWorldAnchorA方法的具体用法?C++ PrismaticJoint::GetWorldAnchorA怎么用?C++ PrismaticJoint::GetWorldAnchorA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrismaticJoint
的用法示例。
在下文中一共展示了PrismaticJoint::GetWorldAnchorA方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseDrag
bool SelectJointOP::OnMouseDrag(int x, int y)
{
if (SelectBodyOP::OnMouseDrag(x, y))
return true;
if (m_selected)
{
sm::vec2 pos = m_stage->TransPosScrToProj(x, y);
switch (m_selected->m_type)
{
case Joint::e_revoluteJoint:
{
RevoluteJoint* joint = static_cast<RevoluteJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_prismaticJoint:
{
PrismaticJoint* joint = static_cast<PrismaticJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_distanceJoint:
{
DistanceJoint* joint = static_cast<DistanceJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_pulleyJoint:
{
PulleyJoint* joint = static_cast<PulleyJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
const float disGA = sm::dis_pos_to_pos(pos, joint->m_ground_anchor_a),
disGB = sm::dis_pos_to_pos(pos, joint->m_ground_anchor_b);
float dis = std::min(std::min(disA, disB), std::min(disGA, disGB));
if (dis == disA)
joint->SetLocalAnchorA(pos);
else if (dis == disB)
joint->SetLocalAnchorB(pos);
else if (dis == disGA)
joint->m_ground_anchor_a = pos;
else
joint->m_ground_anchor_b = pos;
}
break;
case Joint::e_gearJoint:
{
}
break;
case Joint::e_wheelJoint:
{
WheelJoint* joint = static_cast<WheelJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_weldJoint:
{
WeldJoint* joint = static_cast<WeldJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_frictionJoint:
{
FrictionJoint* joint = static_cast<FrictionJoint*>(m_selected);
const float disA = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorA()),
disB = sm::dis_pos_to_pos(pos, joint->GetWorldAnchorB());
if (disA < disB)
joint->SetLocalAnchorA(pos);
else
joint->SetLocalAnchorB(pos);
}
break;
case Joint::e_ropeJoint:
//.........这里部分代码省略.........