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


C++ Float3::Distance方法代码示例

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


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

示例1:

		Air::Engine::enumMouseRayCastType ObjectController::ChangeType( const Float3& vStart,const Float3& vDir )
		{
			Float44 matWorldInv	=	m_WorldMatrix;
			matWorldInv.Inverse();
			Float3 vNewStart	= matWorldInv*vStart;
			Float3 vNewDir		=	matWorldInv*(vStart+vDir)	-	vNewStart;
			vNewDir.Normalize();

			float	fDistance	=	vStart.Distance(m_WorldMatrix.GetPosition())*0.1;

			//if(m_WorldBound.RayCast(vStart,vDir))
			{
				switch(m_ControlMode){
					case eMCM_Select:{

								 }break;
					case eMCM_Move:
					case eMCM_Scale:{
						BoundingBox AXIS[3];
						AXIS[0].vMin	=	Float3(0,-0.05,-0.05)*fDistance;
						AXIS[0].vMax	=	Float3(1,0.05,0.05)*fDistance;

						AXIS[1].vMin	=	Float3(-0.05,0,-0.05)*fDistance;
						AXIS[1].vMax	=	Float3(0.05,1,0.05)*fDistance;

						AXIS[2].vMin	=	Float3(-0.05,-0.05,0)*fDistance;
						AXIS[2].vMax	=	Float3(0.05,0.05,1)*fDistance;

						for(int i=0;i<3;i++){
							if(AXIS[i].RayCast(vNewStart,vNewDir)){
								m_RayCastType	=	enumMouseRayCastType(i+1);
#if 0
								char str[64];
								sprintf_s(str,"%d\n",m_RayCastType);
								OutputDebugStringA(str);
#endif
								break;
							}else{
								m_RayCastType	=	eMRCT_None;
							}
						}

								}break;
					case eMCM_Rotate:{
						BoundingBox AXIS[3];
						AXIS[0].vMin	=	Float3(-0.01,-1,-1)*fDistance;
						AXIS[0].vMax	=	Float3(0.01,1,1)*fDistance;

						AXIS[1].vMin	=	Float3(-1,-0.01,-1)*fDistance;
						AXIS[1].vMax	=	Float3(1,0.01,1)*fDistance;

						AXIS[2].vMin	=	Float3(-1,-1,-0.01)*fDistance;
						AXIS[2].vMax	=	Float3(1,1,0.01)*fDistance;

						float fDis[3]={10000,10000,10000};
						bool bHit	=	false;
						for(int i=0;i<3;i++){
							if(AXIS[i].RayCast(vNewStart,vNewDir,&fDis[i],NULL)){
								Float3 hitPos	=	vNewDir*fDis[i]+vNewStart;
								float dis	=	(hitPos.Distance(Float3(0,0,0)))/fDistance;
								if(dis < 1.0	&& dis > 0.8f){
									bHit	=	true;
								}else{
									fDis[i]	=	10000.0f;
								}
							}	
						}
						if(bHit){
							m_RayCastType	=	eMRCT_X;
							for(int i=1;i<3;i++){
								if(fDis[i]	<	fDis[0]){
									fDis[0]	=	fDis[i];
									m_RayCastType	=	enumMouseRayCastType(i+1);
								}
							}
#if 0
							char str[64];
							sprintf_s(str,"%d\n",m_RayCastType);
							OutputDebugStringA(str);
#endif

						}else{
							m_RayCastType	=	eMRCT_None;
						}
								 }break;
				}
			}

			return m_RayCastType;
		}
开发者ID:ingeyu,项目名称:airengine,代码行数:90,代码来源:AirHelperRenderable.cpp


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