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


C++ CBaseObject::GetAttachmentPosition方法代码示例

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


在下文中一共展示了CBaseObject::GetAttachmentPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddAction


//.........这里部分代码省略.........
					movieCtler.RecordNewAction(actionKey->ToString());
				}
#endif
			}
			break;
		case S_MOUNT:
			{
				// Deprecated 2008.6.19. 
				OUTPUT_LOG("warning: S_MOUNT action deprecated, but still used\n");
				BipedWayPoint ptnew(BipedWayPoint::COMMAND_MOUNT);
				ptnew.m_sTarget = (pData)?(const char*)pData:"";
				CBaseObject* pMountTargetObj=NULL;
				int nMountID = 0;
				if(!ptnew.m_sTarget.empty())
				{
					// use target if it is specified
					pMountTargetObj = CGlobals::GetScene()->GetGlobalObject(ptnew.m_sTarget);
					if(pMountTargetObj)
					{
						// check to see if it has an attachment ID 0, which is the default mount position.
						if(!pMountTargetObj->HasAttachmentPoint(0))
							pMountTargetObj = NULL;
					}
				}
				else
				{
					// if there is no target specified, just find the nearest one
					// we will mount on the closet mount point if the target is empty.
					OBJECT_FILTER_CALLBACK pFilterFunc = g_fncPickingAll;
					DVector3 vPos = pBiped->GetPosition();
					float fMinDistSq = FLOAT_POS_INFINITY;

					list<CBaseObject*> output;
					CShapeSphere sphere(vPos, MIN_MOUNT_DISTANCE_SQ);
					int nCount = CGlobals::GetScene()->GetObjectsBySphere(output, sphere, pFilterFunc);
					if(nCount>0)
					{
						static const int MountIDs [] = {0, ATT_ID_MOUNT1,ATT_ID_MOUNT2,ATT_ID_MOUNT3,ATT_ID_MOUNT4,ATT_ID_MOUNT5,ATT_ID_MOUNT6,ATT_ID_MOUNT7,ATT_ID_MOUNT8,ATT_ID_MOUNT9,
							ATT_ID_MOUNT10, ATT_ID_MOUNT11,ATT_ID_MOUNT12,ATT_ID_MOUNT13,ATT_ID_MOUNT14,ATT_ID_MOUNT15,ATT_ID_MOUNT16,ATT_ID_MOUNT17,ATT_ID_MOUNT18,ATT_ID_MOUNT19,ATT_ID_MOUNT20,};
						int nListSize = sizeof(MountIDs)/sizeof(int);
						Vector3 vPos2;

						list<CBaseObject*>::iterator itCur, itEnd = output.end();
						for(itCur = output.begin(); itCur!=itEnd; ++itCur)
						{
							CBaseObject* pObj = (*itCur);

							
							for (int i=0;i<nListSize && pObj->GetAttachmentPosition(vPos2, MountIDs[i]); ++i)
							{
								// here we compare distance between model origin and the attachment position. multiple attachment points on the same object are supported
								float fDistSq = (vPos2-vPos).squaredLength();
								if(fMinDistSq>fDistSq)
								{
									fMinDistSq = fDistSq;
									pMountTargetObj = pObj;
									nMountID = MountIDs[i];
								}
							}
						}
					}
				}
				
				if(pMountTargetObj!=NULL)
				{
					CBipedStateManager* pState = pMountTargetObj->GetBipedStateManager();
					if(pState==0 || !pState->IsMounted())
					{
						// add mount.
						ptnew.vPos = Vector3(0,0,0);
						ptnew.fFacing = 0;
						ptnew.m_nReserved0 = nMountID;
						pBiped->RemoveWayPoint();
						pBiped->AddWayPoint(ptnew);

						// remove previous mount target. is this the best way to do it?
						pBiped->DeleteAllRefsByTag(0);
						pBiped->AddReference(pMountTargetObj, 0);
						// Set mounted state.
						SetMounted(true);

						if(IsRecording())
						{
							// record the state
							ParaScripting::ParaMovieCtrler movieCtler = (ParaScripting::ParaCharacter(pBiped)).GetMovieController();
							movieCtler.RecordNewAction("_mount");
						}
					}
				}
				break;
			}
		case S_FLY_DOWNWARD:
			PushUniqueState(STATE_FLY_DOWNWARD);
			break;
		default:
			break;
		}
	}	
	return GetLastState();
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:101,代码来源:BipedStateManager.cpp


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