当前位置: 首页>>代码示例>>C++>>正文


C++ PrismaticJoint::GetWorldAnchorB方法代码示例

本文整理汇总了C++中PrismaticJoint::GetWorldAnchorB方法的典型用法代码示例。如果您正苦于以下问题:C++ PrismaticJoint::GetWorldAnchorB方法的具体用法?C++ PrismaticJoint::GetWorldAnchorB怎么用?C++ PrismaticJoint::GetWorldAnchorB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PrismaticJoint的用法示例。


在下文中一共展示了PrismaticJoint::GetWorldAnchorB方法的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:
//.........这里部分代码省略.........
开发者ID:xzrunner,项目名称:easyeditor,代码行数:101,代码来源:SelectJointOP.cpp


注:本文中的PrismaticJoint::GetWorldAnchorB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。