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


C++ Fvector::invert方法代码示例

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


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

示例1: PathDIrPoint

void CPHMovementControl::PathDIrPoint(const xr_vector<DetailPathManager::STravelPathPoint> &path,  int index,  float distance,  float precesition, Fvector &dir  )
{
	Fvector to_path_point;
	Fvector corrected_path_dir;CorrectPathDir(GetPathDir(),path,index,corrected_path_dir);
	to_path_point.sub(vPathPoint,vPosition);	//_new position
	float mag=to_path_point.magnitude();

	if(mag<EPS) //near the point
	{  
		if(0==index||m_path_size-1==index) //on path eidge
		{
			dir.set(corrected_path_dir);//??
			return;
		}
		dir.sub(path[index].position,path[index-1].position);
		dir.normalize_safe();
		dir.add(corrected_path_dir);
		dir.normalize_safe();
	}
	to_path_point.mul(1.f/mag);
	if(m_path_size-1==index)//on_path_edge
	{
		dir.set(to_path_point);
		return;
	}


	if(mag<EPS||fis_zero(dXZMag(to_path_point),EPS))
	{
		dir.set(corrected_path_dir);
		return;//mean dir
	}
	
	Fvector tangent;
	tangent.crossproduct(Fvector().set(0,1,0),to_path_point);

	VERIFY(!fis_zero(tangent.magnitude()));
	tangent.normalize();
	if(dir.square_magnitude()>EPS)
	{
		if(tangent.dotproduct(dir)<0.f)tangent.invert();
	}
	else
	{
		if(tangent.dotproduct(corrected_path_dir)<0.f)tangent.invert();
	}

	if(mag>FootRadius())to_path_point.mul(precesition);
	else to_path_point.mul(mag*precesition);
	dir.add(tangent,to_path_point);
	dir.normalize_safe();
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:52,代码来源:PHMovementControl.cpp

示例2:

IC float PLC_energy	(Fvector& P, Fvector& N, light* L, float E)
{
	Fvector Ldir;
	if (L->flags.type==IRender_Light::DIRECT)
	{
		// Cos
		Ldir.invert	(L->direction);
		float D		= Ldir.dotproduct( N );
		if( D <=0 )						return 0;
		
		// Trace Light
		float A		= D*E;
		return A;
	} else {
		// Distance
		float sqD	= P.distance_to_sqr(L->position);
		if (sqD > (L->range*L->range))	return 0;
		
		// Dir
		Ldir.sub	(L->position,P);
		Ldir.normalize_safe();
		float D		= Ldir.dotproduct( N );
		if( D <=0 )						return 0;
		
		// Trace Light
		float R		= _sqrt		(sqD);
		float att	= 1-(1/(1+R));
		float A		= D * E * att;
		return A;
	}
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:31,代码来源:LightShadows.cpp

示例3: Update

void CCameraLook::Update(Fvector& point, Fvector& /**noise_dangle/**/)
{
	vPosition.set		(point);
	Fmatrix mR;
	mR.setHPB			(-yaw,-pitch,-roll);

	vDirection.set		(mR.k);
	vNormal.set			(mR.j);

	if (m_Flags.is(flRelativeLink)){
		parent->XFORM().transform_dir(vDirection);
		parent->XFORM().transform_dir(vNormal);
	}
	Fvector				vDir;
	collide::rq_result	R;

	float				covariance = VIEWPORT_NEAR*6.f;
	vDir.invert			(vDirection);
	g_pGameLevel->ObjectSpace.RayPick( point, vDir, dist+covariance, collide::rqtBoth, R, parent);

	float d				= psCamSlideInert*prev_d+(1.f-psCamSlideInert)*(R.range-covariance);
	prev_d = d;
	
	vPosition.mul		(vDirection,-d-VIEWPORT_NEAR);
	vPosition.add		(point);

}
开发者ID:2asoft,项目名称:xray,代码行数:27,代码来源:cameralook.cpp

示例4: CalcCondition

//void CEntity::Hit			(float perc, Fvector &dir, CObject* who, s16 element,Fvector position_in_object_space, float impulse, ALife::EHitType hit_type) 
void	CEntity::Hit		(SHit* pHDS)
{

//	if (bDebug)				Log("Process HIT: ", *cName());

	// *** process hit calculations
	// Calc impulse
	Fvector					vLocalDir;
	float					m = pHDS->dir.magnitude();
	VERIFY					(m>EPS);
	
	// convert impulse into local coordinate system
	Fmatrix					mInvXForm;
	mInvXForm.invert		(XFORM());
	mInvXForm.transform_dir	(vLocalDir,pHDS->dir);
	vLocalDir.invert		();

	// hit impulse
	if(pHDS->impulse) HitImpulse				(pHDS->impulse,pHDS->dir,vLocalDir); // @@@: WT
	
	// Calc amount (correct only on local player)
	float lost_health = CalcCondition(pHDS->damage());

	// Signal hit
	if(BI_NONE!=pHDS->bone())	HitSignal(lost_health,vLocalDir,pHDS->who,pHDS->boneID);

	// If Local() - perform some logic
	if (Local() && !g_Alive() && !AlreadyDie() && (m_killer_id == ALife::_OBJECT_ID(-1))) {
		KillEntity	(pHDS->whoID);
	}
	//must be last!!! @slipch
	inherited::Hit(pHDS);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:34,代码来源:Entity.cpp

示例5: trace_geometry

bool CSnork::trace_geometry(const Fvector &d, float &range)
{
	Fvector				dir;
	float				h, p;

	Fvector				Pl,Pc,Pr;
	Fvector				center;
	Center				(center);

	range				= trace (d);
	if (range > TRACE_RANGE) return false;
	
	float angle			= asin(1.f / range);

	// trace center ray
	dir					= d;

	dir.getHP			(h,p);
	p					+= angle;
	dir.setHP			(h,p);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pc.mad				(center, dir, range);

	// trace left ray
	Fvector				temp_p;
	temp_p.mad			(Pc, XFORM().i, Radius() / 2);
	dir.sub				(temp_p, center);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pl.mad				(center, dir, range);

	// trace right ray
	Fvector inv			= XFORM().i; 
	inv.invert			();
	temp_p.mad			(Pc, inv, Radius() / 2);
	dir.sub				(temp_p, center);
	dir.normalize_safe	();

	range				= trace (dir);
	if (range > TRACE_RANGE) return false;

	Pr.mad				(center, dir, range);

	float				h1,p1,h2,p2;

	Fvector().sub(Pl, Pc).getHP(h1,p1);
	Fvector().sub(Pc, Pr).getHP(h2,p2);

	return (fsimilar(h1,h2,0.1f) && fsimilar(p1,p2,0.1f));
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:57,代码来源:snork.cpp

示例6: intersectRayIdentitySphere

IC float intersectRayIdentitySphere(const Fvector& rO, const Fvector& rV)
{
    Fvector Q;
    Q.invert(rO);

    float c = Q.magnitude();
    float v = Q.dotproduct(rV);
    float d = 1 - (c*c - v*v);

    // If there was no intersection, return -1
    if (d < 0.0) return (-1.0f);

    // Return the distance to the [first] intersecting point
    return (v - _sqrt(d));
}
开发者ID:Frankie-666,项目名称:xray-16,代码行数:15,代码来源:motion_simulator.cpp

示例7: GetControlDir

bool CElevatorState::GetControlDir(Fvector& dir)
{
	bool ret=true;
	VERIFY(m_ladder&&m_character);
	Fvector d;
	float dist;
	switch(m_state)
	{
	case	clbDepart		: 
	case	clbNoLadder		:
	case	clbNone			: 		break;			
	case 	clbNearUp		:		dist= m_ladder->DDUpperP(m_character,d);
									if(	dXZDotNormalized(d,m_character->CamDir())>look_angle_cosine&&
										!fis_zero(dist,EPS_L)&&m_character->ControlAccel().dotproduct(d)>0.f) dir.set(d);
									break;						
	case 	clbNearDown		:		
									dist=m_ladder->DDLowerP(m_character,d);
									if(dXZDotNormalized(d,m_character->CamDir())>look_angle_cosine&&
									   !fis_zero(dist,EPS_L)&&m_character->ControlAccel().dotproduct(d)>0.f) dir.set(d);
									break;					
	case 	clbClimbingUp	:		m_ladder->DDAxis(dir);
									m_ladder->DDToAxis(m_character,d);
									dir.add(d);dir.normalize();
									break;					
	case 	clbClimbingDown	:		m_ladder->DDToAxis(m_character,d);
									if(m_ladder->BeforeLadder(m_character)||d.dotproduct(dir)>0.f)
									{
										m_ladder->DDAxis(dir);
										dir.invert();
										dir.add(d);dir.normalize();
									}
									else 
									{
#ifdef DEBUG
										if(ph_dbg_draw_mask.test(phDbgLadder))
										{
											Msg("no c dir");
										}
#endif
										ret=false;
									}
									break;				
	}
	return ret;
}
开发者ID:2asoft,项目名称:xray,代码行数:45,代码来源:ElevatorState.cpp

示例8: OrientToNorm

IC BOOL OrientToNorm(Fvector& local_norm, Fmatrix33& form, Fvector& hs)
{
    Fvector * ax_pointer= (Fvector*)&form;
    int 	max_proj=0,min_size=0;
    for (u32 k=1; k<3; k++){
    	if (_abs(local_norm[k])>_abs(local_norm[max_proj]))
        	max_proj=k;
        if (hs[k]<hs[min_size])
        	min_size=k; 
    }
    if (min_size!=max_proj) return FALSE;
    if (local_norm[max_proj]<0.f){
    	local_norm.invert();
        ax_pointer[max_proj].invert();
        ax_pointer[(max_proj+1)%3].invert();
    }
    return TRUE;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:18,代码来源:ESceneObjectToolsExportBreakable.cpp

示例9: DDSideToAxis

float CClimableObject::DDSideToAxis(CPHCharacter *actor,Fvector &dir)const
{
	VERIFY(actor);
	DToAxis(actor,dir);
	Fvector side;side.set(m_side);to_mag_and_dir(side);
	float dot=side.dotproduct(dir);
	if(dot>0.f)
	{
		dir.set(side);
		return dot;
	}
	else
	{
		dir.set(side);
		dir.invert();
		return -dot;
	}
	
}
开发者ID:2asoft,项目名称:xray,代码行数:19,代码来源:ClimableObject.cpp

示例10: float

r_aabb_ssa		r_pixel_calculator::calculate	(dxRender_Visual* V)	{
	r_aabb_ssa	result			= {0};
	float		area			= float(_sqr(rt_dimensions));

	// 
	u32	id				[6]		;
	for (u32 face=0; face<6; face++)	{
		// setup matrices
		Fmatrix						mProject,mView	;
		Fvector						vFrom			;
		Fbox						aabb			;

		// camera - left-to-right
		mView.build_camera_dir		(vFrom.invert(cmDir[face]).mul(100.f),	cmDir[face],	cmNorm[face])	;
		aabb.xform					(V->vis.box,mView);
		D3DXMatrixOrthoOffCenterLH	( (D3DXMATRIX*)&mProject, aabb.min.x, aabb.max.x, aabb.min.y, aabb.max.y, aabb.min.z, aabb.max.z );
		RCache.set_xform_world		(Fidentity);
		RCache.set_xform_view		(mView);
		RCache.set_xform_project	(mProject);

		// render-0
		Device.Clear				();	// clear-ZB
		RCache.set_Shader			(V->shader);
		V->Render					(1.f);

		// render-1
		RImplementation.HWOCC.occq_begin	(id[face]);
		V->Render							(1.f);
		RImplementation.HWOCC.occq_end		(id[face]);
	}

	// 
	for (u32 it=0; it<6; it++)	{
		float	pixels	= (float)RImplementation.HWOCC.occq_get	(id[it]);
		float	coeff	= clampr(pixels/area,float(0),float(1));
		Msg		("[%d]ssa_c: %1.3f,%f/%f",it,coeff,pixels,area);
		result.ssa	[it]= (u8)clampr(iFloor(coeff*255.f+0.5f),int(0),int(255));
	}

	return result	;
}
开发者ID:2asoft,项目名称:xray-16,代码行数:41,代码来源:r__pixel_calculator.cpp

示例11: GoalMatrix

void CIKLimb::GoalMatrix(Matrix &M,SCalculateData* cd)
{
		VERIFY(cd->m_tri&&cd->m_tri_hight!=-dInfinity);
		const Fmatrix &obj=*cd->m_obj;
		CDB::TRI	*tri=cd->m_tri;
		CKinematics *K=cd->m_K;
		Fvector*	pVerts	= Level().ObjectSpace.GetStaticVerts();
		Fvector normal;
		normal.mknormal	(pVerts[tri->verts[0]],pVerts[tri->verts[1]],pVerts[tri->verts[2]]);
		VERIFY(!fis_zero(normal.magnitude()));

		Fmatrix iobj;iobj.invert(obj);iobj.transform_dir(normal);

		Fmatrix xm;xm.set(K->LL_GetTransform(m_bones[2]));

		//Fvector dbg;
		//dbg.set(Fvector().mul(normal,normal.y*tri_hight
		//	-normal.dotproduct(xm.i)*m_toe_position.x
		//	-normal.dotproduct(xm.j)*m_toe_position.y
		//	-normal.dotproduct(xm.k)*m_toe_position.z-m_toe_position.x
		//	));
		
		normal.invert();
		Fvector ax;ax.crossproduct(normal,xm.i);
		float s=ax.magnitude();
		if(!fis_zero(s))
		{
			ax.mul(1.f/s);

			xm.mulA_43(Fmatrix().rotation(ax,asinf(-s)));
		}

		Fvector otri;iobj.transform_tiny(otri,pVerts[tri->verts[0]]);
		float tp=normal.dotproduct(otri);
		Fvector add;
		add.set(Fvector().mul(normal,-m_toe_position.x+tp-xm.c.dotproduct(normal)));

		xm.c.add(add);
		
	
		Fmatrix H;
		CBoneData& bd=K->LL_GetData(m_bones[0]);
		H.set(bd.bind_transform);
	
		H.mulA_43(K->LL_GetTransform(bd.GetParentID()));
		H.c.set(K->LL_GetTransform(m_bones[0]).c);

	
#ifdef DEBUG
		if(ph_dbg_draw_mask.test(phDbgIKAnimGoalOnly))	xm.set(K->LL_GetTransform(m_bones[2]));
		if(ph_dbg_draw_mask.test(phDbgDrawIKGoal))
		{
			Fmatrix DBGG;
			DBGG.mul_43(obj,xm);
			DBG_DrawMatrix(DBGG,0.2f);

			
			DBGG.mul_43(obj,H);
			DBG_DrawMatrix(DBGG,0.2f);
		}
#endif
		H.invert();
		Fmatrix G; 
		G.mul_43(H,xm);
		XM2IM(G,M);
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:66,代码来源:IKLimb.cpp

示例12: Game


//.........这里部分代码省略.........
					m_sndShockEffector = xr_new<SndShockEffector>();
					m_sndShockEffector->Start(this, float(S._handle()->length_ms()), HDS.damage() );
				}
			}
			else
				bPlaySound = false;
		}
		if (bPlaySound && !b_snd_hit_playing) 
		{
			Fvector point		= Position();
			point.y				+= CameraHeight();
			S.play_at_pos		(this, point);
		};
	}

	
	//slow actor, only when he gets hit
	if(HDS.hit_type == ALife::eHitTypeWound || HDS.hit_type == ALife::eHitTypeStrike)
	{
		hit_slowmo				= HDS.damage();
		clamp					(hit_slowmo,0.0f,1.f);
	}
	else
		hit_slowmo = 0.f;
	//---------------------------------------------------------------
	if (Level().CurrentViewEntity() == this && !g_pGamePersistent->bDedicatedServer && HDS.hit_type == ALife::eHitTypeFireWound)
	{
		CObject* pLastHitter = Level().Objects.net_Find(m_iLastHitterID);
		CObject* pLastHittingWeapon = Level().Objects.net_Find(m_iLastHittingWeaponID);
		HitSector(pLastHitter, pLastHittingWeapon);
	};

	if ((mstate_real&mcSprint) && Level().CurrentControlEntity() == this && 
		HDS.hit_type != ALife::eHitTypeTelepatic &&
		HDS.hit_type != ALife::eHitTypeRadiation 
		)
	{
//		mstate_real	&=~mcSprint;
		mstate_wishful	&=~mcSprint;
	};
	if(!g_pGamePersistent->bDedicatedServer)
	{
		HitMark			(HDS.damage(), HDS.dir, HDS.who, HDS.bone(), HDS.p_in_bone_space, HDS.impulse, HDS.hit_type);
	}

	switch (GameID())
	{
	case GAME_SINGLE:		
		{
			float hit_power	= HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);

			if (GodMode())//psActorFlags.test(AF_GODMODE))
			{
				HDS.power = 0.0f;
//				inherited::Hit(0.f,dir,who,element,position_in_bone_space,impulse, hit_type);
				inherited::Hit(&HDS);
				return;
			}
			else 
			{
				//inherited::Hit		(hit_power,dir,who,element,position_in_bone_space, impulse, hit_type);
				HDS.power = hit_power;
				inherited::Hit(&HDS);
			};
		}
		break;
	default:
		{
			m_bWasBackStabbed = false;
			if (HDS.hit_type == ALife::eHitTypeWound_2 && Check_for_BackStab_Bone(HDS.bone()))
			{
				// convert impulse into local coordinate system
				Fmatrix					mInvXForm;
				mInvXForm.invert		(XFORM());
				Fvector					vLocalDir;
				mInvXForm.transform_dir	(vLocalDir,HDS.dir);
				vLocalDir.invert		();

				Fvector a	= {0,0,1};
				float res = a.dotproduct(vLocalDir);
				if (res < -0.707)
				{
					game_PlayerState* ps = Game().GetPlayerByGameID(ID());
					if (!ps || !ps->testFlag(GAME_PLAYER_FLAG_INVINCIBLE))						
						m_bWasBackStabbed = true;
				}
			};
			
			float hit_power = 0;

			if (m_bWasBackStabbed) hit_power = 100000;
			else hit_power	= HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);

			HDS.power = hit_power;
			inherited::Hit (&HDS);
			//inherited::Hit	(hit_power,dir,who,element,position_in_bone_space, impulse, hit_type, 0.0f);
		}		
		break;
	}
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:101,代码来源:Actor.cpp

示例13: AddWallmark

void CKinematics::AddWallmark(const Fmatrix* parent_xform, const Fvector3& start, const Fvector3& dir, ref_shader shader, float size)
{
	Fvector S,D,normal		= {0,0,0};
	// transform ray from world to model
	Fmatrix P;	P.invert	(*parent_xform);
	P.transform_tiny		(S,start);
	P.transform_dir			(D,dir);
	// find pick point
	float dist				= flt_max;
	BOOL picked				= FALSE;

	DEFINE_VECTOR			(Fobb,OBBVec,OBBVecIt);
	OBBVec					cache_obb;
	cache_obb.resize		(LL_BoneCount());

	for (u16 k=0; k<LL_BoneCount(); k++){
		CBoneData& BD		= LL_GetData(k);
		if (LL_GetBoneVisible(k)&&!BD.shape.flags.is(SBoneShape::sfNoPickable)){
			Fobb& obb		= cache_obb[k];
			obb.transform	(BD.obb,LL_GetBoneInstance(k).mTransform);
			if (CDB::TestRayOBB(S,D, obb))
				for (u32 i=0; i<children.size(); i++)
					if (LL_GetChild(i)->PickBone(normal,dist,S,D,k)) picked=TRUE;
		}
	}
	if (!picked) return; 
 
	// calculate contact point
	Fvector cp;	cp.mad		(S,D,dist); 
 
	// collect collide boxes
	Fsphere test_sphere;
    test_sphere.set			(cp,size); 
	U16Vec					test_bones;
	test_bones.reserve		(LL_BoneCount());
	for (k=0; k<LL_BoneCount(); k++){
		CBoneData& BD		= LL_GetData(k);  
		if (LL_GetBoneVisible(k)&&!BD.shape.flags.is(SBoneShape::sfNoPickable)){
			Fobb& obb		= cache_obb[k];
			if (CDB::TestSphereOBB(test_sphere, obb))
				test_bones.push_back(k);
		}
	}

	// find similar wm
	for (u32 wm_idx=0; wm_idx<wallmarks.size(); wm_idx++){
		intrusive_ptr<CSkeletonWallmark>& wm = wallmarks[wm_idx];		
		if (wm->Similar(shader,cp,0.02f)){ 
			if (wm_idx<wallmarks.size()-1) 
				wm = wallmarks.back();
			wallmarks.pop_back();
			break;
		}
	}

	// ok. allocate wallmark
	intrusive_ptr<CSkeletonWallmark>		wm = xr_new<CSkeletonWallmark>(this,parent_xform,shader,cp,Device.fTimeGlobal);
	wm->m_LocalBounds.set		(cp,size*2.f);
	wm->XFORM()->transform_tiny	(wm->m_Bounds.P,cp);
	wm->m_Bounds.R				= wm->m_Bounds.R; 

	Fvector tmp; tmp.invert		(D);
	normal.add(tmp).normalize	();

	// build UV projection matrix
	Fmatrix						mView,mRot;
	BuildMatrix					(mView,1/(0.9f*size),normal,cp);
	mRot.rotateZ				(::Random.randF(deg2rad(-20.f),deg2rad(20.f)));
	mView.mulA_43				(mRot);

	// fill vertices
	for (u32 i=0; i<children.size(); i++){
		CSkeletonX* S		= LL_GetChild(i);
		for (U16It b_it=test_bones.begin(); b_it!=test_bones.end(); b_it++)
			S->FillVertices		(mView,*wm,normal,size,*b_it);
	}

	wallmarks.push_back		(wm);
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:79,代码来源:SkeletonCustom.cpp

示例14: Idle_AssignAction

void CMonsterSquad::Idle_AssignAction(ENTITY_VEC &members)
{
	// получить цель лидера
	SMemberGoal &goal = GetGoal(leader);

	if (goal.type == MG_WalkGraph) {
		
		front.clear();	back.clear();	left.clear();	right.clear();

		for (ENTITY_VEC_IT IT = members.begin(); IT != members.end(); IT++) {
			if ((*IT) == leader) continue;
			
			front.push_back	(*IT);
			back.push_back	(*IT);
			left.push_back	(*IT);
			right.push_back	(*IT);
		}

		Fvector front_pos;
		Fvector back_pos;
		Fvector left_pos;
		Fvector right_pos;

		Fvector dir = leader->Direction();
		front_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(front.begin(),front.end(), CPredicateSideSort(front_pos));

		dir.invert();
		back_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(back.begin(),back.end(), CPredicateSideSort(back_pos));

		dir = leader->XFORM().i;
		right_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(right.begin(),right.end(), CPredicateSideSort(right_pos));

		dir.invert();
		left_pos.mad(leader->Position(), dir, CENTER_CIRCLE_DIST);
		std::sort(left.begin(),left.end(), CPredicateSideSort(left_pos));

		SSquadCommand command;
		command.type		= SC_FOLLOW;
		command.entity		= leader;	
		command.direction	= leader->Direction();
		
		u8 cur_type = 0;
		while (!front.empty()) {
			float	random_r;
			Fvector random_dir;

			random_dir.random_dir	();
			random_r				= Random.randF(CIRCLE_RADIUS_MIN, CIRCLE_RADIUS_MAX);

			const CEntity *entity = 0;
			switch (cur_type) {
				case 0: // front
					entity = front.back	(); front.pop_back();
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					command.position.mad	(front_pos, random_dir, random_r);
					break;
				case 1: // back
					entity = back.back	(); back.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					command.position.mad	(back_pos, random_dir, random_r);
					break;
				case 2: // left
					entity = left.back	(); left.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<right.size(); i++)	if (right[i] == entity) {right[i] = right.back(); right.pop_back(); break;}
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					command.position.mad	(left_pos, random_dir, random_r);
					break;
				case 3: // right
					entity = right.back	(); right.pop_back();
					for (u32 i=0; i<front.size(); i++)	if (front[i] == entity) {front[i] = front.back(); front.pop_back(); break;}
					for (u32 i=0; i<left.size(); i++)	if (left[i] == entity) {left[i] = left.back(); left.pop_back(); break;}
					for (u32 i=0; i<back.size(); i++)	if (back[i] == entity) {back[i] = back.back(); back.pop_back(); break;}
					command.position.mad	(right_pos, random_dir, random_r);
					break;
				default:
					NODEFAULT;
			}
			
			cur_type++;
			if (cur_type > 3) cur_type = 0;

			UpdateCommand(entity, command);
		}
	
	} else if (goal.type == MG_Rest) {
		// пересчитать положение в команде в соответствие с целью лидера
		for (ENTITY_VEC_IT it = members.begin(); it != members.end(); it++) {
			if ((*it) == leader) continue;

			SSquadCommand command;
			command.type		= SC_REST;
			command.position	= leader->Position();
//.........这里部分代码省略.........
开发者ID:AntonioModer,项目名称:xray-16,代码行数:101,代码来源:ai_monster_squad_rest.cpp


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