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


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

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


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

示例1: MGunFireStart

void CHelicopter::MGunFireStart()
{
	if(!m_use_mgun_on_attack)
		return;

	if(FALSE==IsWorking() && m_enemy.bUseFireTrail){
		//start calc fire trail
		m_enemy.fStartFireTime			= Device.fTimeGlobal;
		Fvector fp = get_CurrentFirePoint();
		Fvector ep = m_enemy.destEnemyPos;

		//calc min firetrail length
		float h = fp.y-ep.y;
		if(h>0.0f){
			float dl =h*tan(m_lim_x_rot.y);
			float ds = fp.distance_to_xz(ep);
			if(ds>dl){
				float half_trail = ds-dl;
				m_enemy.fire_trail_length_curr = half_trail*2.0f;
				clamp(m_enemy.fire_trail_length_curr,0.0f,m_enemy.fire_trail_length_des);
//				Msg("Start fire. Desired length=%f, cur_length=%f",m_enemy.fire_trail_length_des,m_enemy.fire_trail_length_curr);
			}else
				m_enemy.fire_trail_length_curr	= m_enemy.fire_trail_length_des;
		}else
			m_enemy.fire_trail_length_curr	= m_enemy.fire_trail_length_des;
	}

	CShootingObject::FireStart	();
}
开发者ID:2asoft,项目名称:xray,代码行数:29,代码来源:HelicopterWeapon.cpp

示例2: mark_nodes_in_direction

float CLevelGraph::mark_nodes_in_direction(u32 start_vertex_id, const Fvector &start_point, const Fvector &finish_point, xr_vector<u32> &tpaStack, xr_vector<bool> *tpaMarks) const
{
	SContour				_contour;
	const_iterator			I,E;
	int						saved_index, iPrevIndex = -1, iNextNode;
	Fvector					temp_point = start_point;
	float					fDistance = start_point.distance_to(finish_point), fCurDistance = 0.f;
	u32						dwCurNode = start_vertex_id;

	while (!inside(vertex(dwCurNode),finish_point) && (fCurDistance < (fDistance + EPS_L))) {
		begin				(dwCurNode,I,E);
		saved_index			= -1;
		contour				(_contour,dwCurNode);
		for ( ; I != E; ++I) {
			iNextNode = value(dwCurNode,I);
			if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode))
				choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index);
		}

		if (saved_index > -1) {
			fCurDistance	= start_point.distance_to_xz(temp_point);
			iPrevIndex		= dwCurNode;
			dwCurNode		= saved_index;
		}
		else
			return(fCurDistance);

		if (tpaMarks)
			(*tpaMarks)[dwCurNode]	= true;
		tpaStack.push_back	(dwCurNode);
	}

	return					(fCurDistance);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:34,代码来源:level_graph_vertex.cpp

示例3: check_position_in_direction

float CLevelGraph::check_position_in_direction(u32 start_vertex_id, const Fvector &start_position, const Fvector &finish_position, const float max_distance) const
{
	SContour				_contour;
	const_iterator			I,E;
	int						saved_index, iPrevIndex = -1, iNextNode;
	Fvector					start_point = start_position, temp_point = start_position, finish_point = finish_position;
	float					fCurDistance = 0.f, fDistance = start_position.distance_to_xz(finish_position);
	u32						dwCurNode = start_vertex_id;

	while (!inside(vertex(dwCurNode),finish_position) && (fCurDistance < (fDistance + EPS_L))) {
		begin				(dwCurNode,I,E);
		saved_index			= -1;
		contour				(_contour,dwCurNode);
		for ( ; I != E; ++I) {
			iNextNode = value(dwCurNode,I);
			if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode))
				choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index);
		}

		if (saved_index > -1) {
			fCurDistance	= start_point.distance_to_xz(temp_point);
			iPrevIndex		= dwCurNode;
			dwCurNode		= saved_index;
		}
		else
			return			(max_distance);
	}

	if (inside(vertex(dwCurNode),finish_position) && (_abs(vertex_plane_y(*vertex(dwCurNode),finish_position.x,finish_position.z) - finish_position.y) < .5f))
		return				(start_point.distance_to_xz(finish_position));
	else
		return				(max_distance);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:33,代码来源:level_graph_vertex.cpp

示例4: enemy_inaccessible

static
bool enemy_inaccessible (CBaseMonster * const object)
{
	CEntityAlive const * enemy		=	object->EnemyMan.get_enemy();
	if ( !enemy )
		return							false;

	Fvector const enemy_pos			=	enemy->Position();
	Fvector const enemy_vert_pos	=	ai().level_graph().vertex_position(enemy->ai_location().level_vertex_id());
	
	float const xz_dist_to_vertex	=	enemy_vert_pos.distance_to_xz(enemy_pos);
	float const y_dist_to_vertex	=	_abs(enemy_vert_pos.y - enemy_pos.y);

	if ( xz_dist_to_vertex > 0.5f && y_dist_to_vertex > 3.f )
		return							true;

	if ( xz_dist_to_vertex > 1.2f )
		return							true;

	if ( !object->Home->at_home(enemy_pos) )
		return							true;

	if ( !accessible_epsilon(object, enemy_pos, 1.5f) )
		return							true;

	if ( !ai().level_graph().valid_vertex_position(enemy_pos) )
		return							true;
	
	if ( !ai().level_graph().valid_vertex_id(enemy->ai_location().level_vertex_id()) )
		return							true;
	
	return								false;
}
开发者ID:BubbaXXX,项目名称:xray-16,代码行数:33,代码来源:base_monster.cpp

示例5: farthest_vertex_in_direction

float CLevelGraph::farthest_vertex_in_direction(u32 start_vertex_id, const Fvector &start_point, const Fvector &finish_point, u32 &finish_vertex_id, xr_vector<bool> *tpaMarks, bool check_accessability) const
{
	SContour				_contour;
	const_iterator			I,E;
	int						saved_index, iPrevIndex = -1, iNextNode;
	Fvector					temp_point = start_point;
	float					fDistance = start_point.distance_to(finish_point), fCurDistance = 0.f;
	u32						dwCurNode = start_vertex_id;

	while (!inside(vertex(dwCurNode),finish_point) && (fCurDistance < (fDistance + EPS_L))) {
		begin				(dwCurNode,I,E);
		saved_index			= -1;
		contour				(_contour,dwCurNode);
		for ( ; I != E; ++I) {
			iNextNode		= value(dwCurNode,I);
			if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode))
				choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index);
		}

		if (saved_index > -1) {
			if (check_accessability && !is_accessible(saved_index))
				return		(fCurDistance);

			fCurDistance	= start_point.distance_to_xz(temp_point);
			iPrevIndex		= dwCurNode;
			dwCurNode		= saved_index;
		}
		else
			return			(fCurDistance);

		if (tpaMarks)
			(*tpaMarks)[dwCurNode]	= true;
		finish_vertex_id	= dwCurNode;
	}
	return					(fCurDistance);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:36,代码来源:level_graph_vertex.cpp

示例6: choose_point

void CLevelGraph::choose_point(const Fvector &start_point, const Fvector &finish_point, const SContour &_contour, int node_id, Fvector &temp_point, int &saved_index) const
{
	SContour					tNextContour;
	SSegment					tNextSegment;
	Fvector						tCheckPoint1 = start_point, tCheckPoint2 = start_point, tIntersectPoint;
	contour						(tNextContour,node_id);
	intersect					(tNextSegment,tNextContour,_contour);
	u32							dwIntersect = intersect(start_point.x,start_point.z,finish_point.x,finish_point.z,tNextSegment.v1.x,tNextSegment.v1.z,tNextSegment.v2.x,tNextSegment.v2.z,&tIntersectPoint.x,&tIntersectPoint.z);
	if (!dwIntersect)
		return;
	for (int i=0; i<4; ++i) {
		switch (i) {
			case 0 : {
				tCheckPoint1	= tNextContour.v1;
				tCheckPoint2	= tNextContour.v2;
				break;
					 }
			case 1 : {
				tCheckPoint1	= tNextContour.v2;
				tCheckPoint2	= tNextContour.v3;
				break;
					 }
			case 2 : {
				tCheckPoint1	= tNextContour.v3;
				tCheckPoint2	= tNextContour.v4;
				break;
					 }
			case 3 : {
				tCheckPoint1	= tNextContour.v4;
				tCheckPoint2	= tNextContour.v1;
				break;
					 }
			default : NODEFAULT;
		}
		dwIntersect				= intersect(start_point.x,start_point.z,finish_point.x,finish_point.z,tCheckPoint1.x,tCheckPoint1.z,tCheckPoint2.x,tCheckPoint2.z,&tIntersectPoint.x,&tIntersectPoint.z);
		if (dwIntersect == LevelGraph::eLineIntersectionIntersect) {
			if (finish_point.distance_to_xz(tIntersectPoint) < finish_point.distance_to_xz(temp_point) + EPS_L) {
				temp_point = tIntersectPoint;
				saved_index = node_id;
			}
		}
		else
			if (dwIntersect == LevelGraph::eLineIntersectionEqual) {
				if (start_point.distance_to_xz(tCheckPoint1) > start_point.distance_to_xz(temp_point))
					if (start_point.distance_to_xz(tCheckPoint1) > start_point.distance_to_xz(tCheckPoint2)) {
						temp_point = tCheckPoint1;
						saved_index = node_id;
					}
					else {
						temp_point = tCheckPoint2;
						saved_index = node_id;
					}
				else
					if (start_point.distance_to_xz(tCheckPoint2) > start_point.distance_to_xz(temp_point)) {
						temp_point = tCheckPoint2;
						saved_index = node_id;
					}

			}
	}
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:61,代码来源:level_graph_vertex.cpp


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