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


C++ Fplane类代码示例

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


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

示例1: RayPick

bool CLevelTool::RayPick(const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n)
{
    if (Scene->ObjCount()&&(UI->GetEState()==esEditScene)){
        SRayPickInfo pinf;
        pinf.inf.range	= dist;
        if (Scene->RayPickObject(dist, start,dir,OBJCLASS_SCENEOBJECT,&pinf,0)){ 
        	dist		= pinf.inf.range;
        	if (pt) 	pt->set(pinf.pt); 
            if (n){	
                const Fvector* PT[3];
                pinf.e_mesh->GetFacePT(pinf.inf.id, PT);
            	n->mknormal(*PT[0],*PT[1],*PT[2]);
            }
            return true;
        }
    }
    Fvector N={0.f,-1.f,0.f};
    Fvector P={0.f,0.f,0.f};
    Fplane PL; PL.build(P,N);
    float d;
    if (PL.intersectRayDist(start,dir,d)&&(d<=dist)){
        dist = d;
        if (pt) pt->mad(start,dir,dist); 
        if (n)	n->set(N);
        return true;
    }else return false;
}
开发者ID:2asoft,项目名称:xray,代码行数:27,代码来源:UI_LevelTools.cpp

示例2: pitch_correction

void CControlDirection::pitch_correction()
{
	if (!m_object->ability_pitch_correction()) return;

	// extended feature to pitch by path (wall climbing)
	// distance between two travel point must be more than 1.f
	if (m_object->control().path_builder().is_moving_on_path() && 
		(m_object->movement().detail().path().size() > m_object->movement().detail().curr_travel_point_index() + 1)) {
		
		const DetailPathManager::STravelPathPoint	cur_point	= m_object->movement().detail().path()[m_object->movement().detail().curr_travel_point_index()];
		const DetailPathManager::STravelPathPoint	next_point	= m_object->movement().detail().path()[m_object->movement().detail().curr_travel_point_index()+1];
		
		if (cur_point.position.distance_to_sqr(next_point.position) > 1) {
			// получаем искомый вектор направления
			Fvector						target_dir;
			target_dir.sub				(next_point.position,cur_point.position);
			m_data.pitch.target_angle	= -target_dir.getP();
			return;
		}
	}
	
	// get current plane
	u32					node = m_object->ai_location().level_vertex_id();
	Fplane				P;	
	pvDecompress		(P.n,ai().level_graph().vertex(node)->plane());
	P.d					= -P.n.dotproduct(ai().level_graph().vertex_position(node));

	Fvector				position_on_plane;
	P.project			(position_on_plane,m_object->Position());

	// находим проекцию точки, лежащей на векторе текущего направления
	Fvector				dir_point, proj_point;
	dir_point.mad		(position_on_plane, m_object->Direction(), 1.f);
	P.project			(proj_point,dir_point);

	// получаем искомый вектор направления
	Fvector				target_dir;
	target_dir.sub		(proj_point,position_on_plane);

	float				yaw,pitch;
	target_dir.getHP	(yaw,pitch);

	m_data.pitch.target_angle = -pitch;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:44,代码来源:control_direction.cpp

示例3: RayPick

BOOL CEffect_Thunderbolt::RayPick(const Fvector& s, const Fvector& d, float& dist)
{
	BOOL bRes 	= TRUE;
#ifdef _EDITOR
    bRes 				= Tools->RayPick	(s,d,dist,0,0);
#else
	collide::rq_result	RQ;
	CObject* E 			= g_pGameLevel->CurrentViewEntity();
	bRes 				= g_pGameLevel->ObjectSpace.RayPick(s,d,dist,collide::rqtBoth,RQ,E);	
    if (bRes) dist	 	= RQ.range;
    else{
        Fvector N	={0.f,-1.f,0.f};
        Fvector P	={0.f,0.f,0.f};
        Fplane PL; PL.build(P,N);
        float dst	=dist;
        if (PL.intersectRayDist(s,d,dst)&&(dst<=dist)){dist=dst; return true;}else return false;
    }
#endif
    return bRes;
}
开发者ID:2asoft,项目名称:xray,代码行数:20,代码来源:thunderbolt.cpp

示例4: CreateFromPortal

void CFrustum::CreateFromPortal(sPoly* poly, Fvector& vPN, Fvector& vBase, Fmatrix& mFullXFORM)
{
    Fplane P;
    P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);

    if (poly->size()>6)
    {
        SimplifyPoly_AABB(poly, P);
        P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
    }

    // Check plane orientation relative to viewer
    // and reverse if needed
    if (P.classify(vBase) < 0)
    {
        std::reverse(poly->begin(), poly->end());
        P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
    }

    // Base creation
    CreateFromPoints(poly->begin(), poly->size(), vBase);

    // Near clipping plane
    _add(P);

    // Far clipping plane
    Fmatrix& M = mFullXFORM;
    P.n.x = -(M._14 - M._13);
    P.n.y = -(M._24 - M._23);
    P.n.z = -(M._34 - M._33);
    P.d = -(M._44 - M._43);
    float denom = 1.0f / P.n.magnitude();
    P.n.x *= denom;
    P.n.y *= denom;
    P.n.z *= denom;
    P.d *= denom;
    _add(P);
}
开发者ID:BubbaXXX,项目名称:xray-16,代码行数:38,代码来源:Frustum.cpp

示例5: object

bool CSpaceRestrictorWrapper::inside				(const Fvector &position, float radius) const
{
	Fsphere							sphere;
	sphere.P						= position;
	sphere.R						= radius;

	typedef CShapeData::ShapeVec	ShapeVec;
	ShapeVec::const_iterator		I = object().shapes.begin();
	ShapeVec::const_iterator		E = object().shapes.end();
	for ( ; I != E; ++I) {
		switch ((*I).type) {
			case 0 : {
				Fsphere				temp;
				m_xform.transform_tiny(temp.P,(*I).data.sphere.P);
				temp.R				= (*I).data.sphere.R;
				if (sphere.intersect(temp))
					return			(true);

				continue;
			}
			case 1 : {
				Fmatrix				temp;
				temp.mul_43			(m_xform,(*I).data.box);

				// Build points
				Fvector				vertices;
				Fvector				points[8];
				Fplane				plane;

				vertices.set(-.5f, -.5f, -.5f);	temp.transform_tiny(points[0],vertices);
				vertices.set(-.5f, -.5f, +.5f);	temp.transform_tiny(points[1],vertices);
				vertices.set(-.5f, +.5f, +.5f);	temp.transform_tiny(points[2],vertices);
				vertices.set(-.5f, +.5f, -.5f);	temp.transform_tiny(points[3],vertices);
				vertices.set(+.5f, +.5f, +.5f);	temp.transform_tiny(points[4],vertices);
				vertices.set(+.5f, +.5f, -.5f);	temp.transform_tiny(points[5],vertices);
				vertices.set(+.5f, -.5f, +.5f);	temp.transform_tiny(points[6],vertices);
				vertices.set(+.5f, -.5f, -.5f);	temp.transform_tiny(points[7],vertices);

				plane.build(points[0],points[3],points[5]);	if (plane.classify(sphere.P)>sphere.R) break;
				plane.build(points[1],points[2],points[3]);	if (plane.classify(sphere.P)>sphere.R) break;
				plane.build(points[6],points[5],points[4]);	if (plane.classify(sphere.P)>sphere.R) break;
				plane.build(points[4],points[2],points[1]);	if (plane.classify(sphere.P)>sphere.R) break;
				plane.build(points[3],points[2],points[4]);	if (plane.classify(sphere.P)>sphere.R) break;
				plane.build(points[1],points[0],points[6]);	if (plane.classify(sphere.P)>sphere.R) break;
				return				(true);
			}
			default :				NODEFAULT;
		}
	}

	return							(false);
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:52,代码来源:space_restrictor_wrapper.cpp

示例6: switch

bool object::inside			(Fvector const &position) const
{
	CCF_Shape						*shape = static_cast<CCF_Shape*>(collidable.model);
	VERIFY							(shape);

	typedef xr_vector<CCF_Shape::shape_def>	Shapes;
	Shapes::const_iterator			i = shape->shapes.begin();
	Shapes::const_iterator			e = shape->shapes.end();
	for ( ; i != e; ++i) {
		switch ((*i).type) {
			case 0 : {
				if ((*i).data.sphere.P.distance_to(position) <= (*i).data.sphere.R)
					return			(true);

				continue;
			}
			case 1 : {
				Fmatrix				matrix;
				const Fmatrix		&box = (*i).data.box;
				matrix.mul_43		(XFORM(),box);
				Fvector				A,B[8];
				Fplane				plane;
				A.set				(-.5f, -.5f, -.5f);	matrix.transform_tiny(B[0],A);
				A.set				(-.5f, -.5f, +.5f);	matrix.transform_tiny(B[1],A);
				A.set				(-.5f, +.5f, +.5f);	matrix.transform_tiny(B[2],A);
				A.set				(-.5f, +.5f, -.5f);	matrix.transform_tiny(B[3],A);
				A.set				(+.5f, +.5f, +.5f);	matrix.transform_tiny(B[4],A);
				A.set				(+.5f, +.5f, -.5f);	matrix.transform_tiny(B[5],A);
				A.set				(+.5f, -.5f, +.5f);	matrix.transform_tiny(B[6],A);
				A.set				(+.5f, -.5f, -.5f);	matrix.transform_tiny(B[7],A);

				plane.build			(B[0],B[3],B[5]); if (plane.classify(position) <= 0.f) return (true);
				plane.build			(B[1],B[2],B[3]); if (plane.classify(position) <= 0.f) return (true);
				plane.build			(B[6],B[5],B[4]); if (plane.classify(position) <= 0.f) return (true);
				plane.build			(B[4],B[2],B[1]); if (plane.classify(position) <= 0.f) return (true);
				plane.build			(B[3],B[2],B[4]); if (plane.classify(position) <= 0.f) return (true);
				plane.build			(B[1],B[0],B[6]); if (plane.classify(position) <= 0.f) return (true);

				continue;
			}
			default : NODEFAULT;
		}
	}

	return							(false);
}
开发者ID:2asoft,项目名称:xray,代码行数:46,代码来源:smart_cover_object.cpp

示例7: CreateNode


//.........这里部分代码省略.........
//		Msg		("Partial chasm at [%f,%f,%f].",vAt.x,vAt.y,vAt.z);
		return	FALSE;
	}

	// *** Calc normal
	Fvector vNorm;
	vNorm.set(0,0,0);
	for (u32 n=0; n<normals.size(); n++)
		vNorm.add(normals[n]);
	vNorm.div(float(normals.size()));
	vNorm.normalize();
	/*
	{
		// second algorithm (Magic)
		Fvector N,O;
		N.set(vNorm);
		O.set(points[0]);
		Mgc::OrthogonalPlaneFit(
			points.size(),(Mgc::Vector3*)points.begin(),
			*((Mgc::Vector3*)&O),
			*((Mgc::Vector3*)&N)
		);
		if (N.y<0) N.invert();
		N.normalize();
		vNorm.lerp(vNorm,N,.3f);
		vNorm.normalize();
	}
	*/

 
	// *** Align plane
	Fvector vOffs;
	vOffs.set(0,-1000,0);
	Fplane PL; 	PL.build(vOffs,vNorm);
	for (u32 p=0; p<points.size(); p++)
	{
		float dist = PL.classify(points[p]);
		if (dist>0) {
			vOffs = points[p];
			PL.build(vOffs,vNorm);
		}
	}

	// *** Create node and register it
	N.Sector		=Sector;						// sector
	N.Plane.build	(vOffs,vNorm);					// build plane
	D.set			(0,1,0);
	N.Plane.intersectRayPoint(PointDown,D,N.Pos);	// "project" position

	// *** Validate results
	vNorm.set(0,1,0);
	if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f)))  return FALSE;

	float y_old = vAt.y;
	float y_new = N.Pos.y;
	if (y_old>y_new) {
		// down
		if (y_old-y_new > g_params.fCanDOWN ) return FALSE;
	} else {
		// up
		if (y_new-y_old > g_params.fCanUP	) return FALSE;
	}
 
	// *** Validate plane
	{
		Fvector PLP; D.set(0,-1,0);
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:67,代码来源:compiler_build.cpp

示例8: UI

void CLevelGraph::draw_nodes	()
{
	CGameObject*	O	= smart_cast<CGameObject*> (Level().CurrentEntity());
	Fvector	POSITION	= O->Position();
	POSITION.y += 0.5f;

	// display
	Fvector P			= POSITION;

//	CPosition			Local;
//	vertex_position		(Local,P);

	u32 ID				= O->ai_location().level_vertex_id();

	CGameFont* F		= UI().Font().pFontDI;
	F->SetHeightI		(.02f);
	F->OutI				(0.f,0.5f,"%f,%f,%f",VPUSH(P));
//	float				x,z;
//	unpack_xz			(Local,x,z);
//	F->Out				(0.f,0.55f,"%3d,%4d,%3d -> %d",	iFloor(x),iFloor(Local.y()),iFloor(z),u32(ID));

	svector<u32,128>	linked;
	{
		const_iterator	i,e;
		begin			(ID,i,e);
		for(; i != e; ++i)
			linked.push_back(value(ID,i));
	}

	// render
	float	sc		= header().cell_size()/16;
	float	st		= 0.98f*header().cell_size()/2;
	float	tt		= 0.01f;

	Fvector	DUP;		DUP.set(0,1,0);

	//RCache.set_Shader	(sh_debug);
	DRender->SetShader(sh_debug);

	F->SetColor			(color_rgba(255,255,255,255));

	//////////////////////////////////////////////////////////////////////////
	Fvector min_position,max_position;
	max_position = min_position = Device.vCameraPosition;
	min_position.sub(30.f);
	max_position.add(30.f);
	
	CLevelGraph::const_vertex_iterator	 I, E;
	if (valid_vertex_position(min_position))
		I = std::lower_bound(begin(),end(),vertex_position(min_position).xz(),&vertex::predicate2);
	else
		I = begin();

	if (valid_vertex_position(max_position)) {
		E = std::upper_bound(begin(),end(),vertex_position(max_position).xz(),&vertex::predicate);
		if (E != end()) ++E;
	}
	else
		E = end();

	//////////////////////////////////////////////////////////////////////////

	for ( ; I != E; ++I)
	{
		const CLevelGraph::CVertex&	N	= *I;
		Fvector			PC;
		PC				= vertex_position(N);

		u32 Nid			= vertex_id(I);

		if (Device.vCameraPosition.distance_to(PC)>30) continue;

		float			sr	= header().cell_size();
		if (::Render->ViewBase.testSphere_dirty(PC,sr)) {
			
			u32	LL = 255;
			
			u32	CC		= D3DCOLOR_XRGB(0,0,255);
			u32	CT		= D3DCOLOR_XRGB(LL,LL,LL);
			u32	CH		= D3DCOLOR_XRGB(0,128,0);

			BOOL	bHL		= FALSE;
			if (Nid==u32(ID))	{ bHL = TRUE; CT = D3DCOLOR_XRGB(0,255,0); }
			else {
				for (u32 t=0; t<linked.size(); ++t) {
					if (linked[t]==Nid) { bHL = TRUE; CT = CH; break; }
				}
			}

			// unpack plane
			Fplane PL; Fvector vNorm;
			pvDecompress(vNorm,N.plane());
			PL.build	(PC,vNorm);

			// create vertices
			Fvector		v,v1,v2,v3,v4;
			v.set(PC.x-st,PC.y,PC.z-st);	PL.intersectRayPoint(v,DUP,v1);	v1.mad(v1,PL.n,tt);	// minX,minZ
			v.set(PC.x+st,PC.y,PC.z-st);	PL.intersectRayPoint(v,DUP,v2);	v2.mad(v2,PL.n,tt);	// maxX,minZ
			v.set(PC.x+st,PC.y,PC.z+st);	PL.intersectRayPoint(v,DUP,v3);	v3.mad(v3,PL.n,tt);	// maxX,maxZ
			v.set(PC.x-st,PC.y,PC.z+st);	PL.intersectRayPoint(v,DUP,v4);	v4.mad(v4,PL.n,tt);	// minX,maxZ
//.........这里部分代码省略.........
开发者ID:AntonioModer,项目名称:xray-16,代码行数:101,代码来源:level_graph_debug2.cpp

示例9: Msg


//.........这里部分代码省略.........
//		Msg		("Partial chasm at [%f,%f,%f].",vAt.x,vAt.y,vAt.z);
		return	FALSE;
	}

	// *** Calc normal
	Fvector vNorm;
	vNorm.set(0,0,0);
	for (DWORD n=0; n<normals.size(); n++)
		vNorm.add(normals[n]);
	vNorm.div(float(normals.size()));
	vNorm.normalize();
	/*
	{
		// second algorithm (Magic)
		Fvector N,O;
		N.set(vNorm);
		O.set(points[0]);
		Mgc::OrthogonalPlaneFit(
			points.size(),(Mgc::Vector3*)points.begin(),
			*((Mgc::Vector3*)&O),
			*((Mgc::Vector3*)&N)
		);
		if (N.y<0) N.invert();
		N.normalize();
		vNorm.lerp(vNorm,N,.3f);
		vNorm.normalize();
	}
	*/

 
	// *** Align plane
	Fvector vOffs;
	vOffs.set(0,-1000,0);
	Fplane PL; 	PL.build(vOffs,vNorm);
	for (DWORD p=0; p<points.size(); p++)
	{
		float dist = PL.classify(points[p]);
		if (dist>0) {
			vOffs = points[p];
			PL.build(vOffs,vNorm);
		}
	}

	// *** Create node and register it
	N.Plane.build	(vOffs,vNorm);					// build plane
	D.set			(0,1,0);
	N.Plane.intersectRayPoint(PointDown,D,N.Pos);	// "project" position

	// *** Validate results
	vNorm.set(0,1,0);
	if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f)))  return FALSE;

	float y_old = vAt.y;
	float y_new = N.Pos.y;
	if (y_old>y_new) {
		// down
		if (y_old-y_new > m_Params.fCanDOWN ) return FALSE;
	} else {
		// up
		if (y_new-y_old > m_Params.fCanUP	) return FALSE;
	}
 
	// *** Validate plane
	{
		Fvector PLP; D.set(0,-1,0);
		int num_successed_rays = 0;
开发者ID:2asoft,项目名称:xray,代码行数:67,代码来源:ESceneAIMapTools_Generate.cpp

示例10: if

void CLightShadows::render	()
{
	// Gain access to collision-DB
	CDB::MODEL*		DB		= g_pGameLevel->ObjectSpace.GetStaticModel();
	CDB::TRI*		TRIS	= DB->get_tris();
	Fvector*		VERTS	= DB->get_verts();

	int			slot_line	= S_rt_size/S_size;
	
	// Projection and xform
	float _43					=	Device.mProject._43;
	Device.mProject._43			-=	0.002f; 
	RCache.set_xform_world		(Fidentity);
	RCache.set_xform_project	(Device.mProject);
	Fvector	View				= Device.vCameraPosition;
	
	// Render shadows
	RCache.set_Shader			(sh_World);
	RCache.set_Geometry			(geom_World);
	int batch					= 0;
	u32 Offset					= 0;
	FVF::LIT* pv				= (FVF::LIT*) RCache.Vertex.Lock	(batch_size*3,geom_World->vb_stride,Offset);
	for (u32 s_it=0; s_it<shadows.size(); s_it++)
	{
		Device.Statistic->RenderDUMP_Srender.Begin	();
		shadow&		S			=	shadows[s_it];
		float		Le			=	S.L->color.intensity()*S.E;
		int			s_x			=	S.slot%slot_line;
		int			s_y			=	S.slot/slot_line;
		Fvector2	t_scale, t_offset;
		t_scale.set	(float(S_size)/float(S_rt_size),float(S_size)/float(S_rt_size));
		t_scale.mul (.5f);
		t_offset.set(float(s_x)/float(slot_line),float(s_y)/float(slot_line));
		t_offset.x	+= .5f/S_rt_size;
		t_offset.y	+= .5f/S_rt_size;
		
		// Search the cache
		cache_item*						CI		= 0; BOOL	bValid = FALSE;
		cache_item						CI_what; CI_what.O	= S.O; CI_what.L = S.L; CI_what.tris=0;
		xr_vector<cache_item>::iterator	CI_ptr	= std::lower_bound(cache.begin(),cache.end(),CI_what,cache_search);
		if (CI_ptr==cache.end())		
		{	// empty ?
			CI_ptr	= cache.insert		(CI_ptr,CI_what);
			CI		= &*CI_ptr;
			bValid	= FALSE;
		} else {
			if (CI_ptr->O != CI_what.O  || CI_ptr->L != CI_what.L)	
			{	// we found something different
				CI_ptr	= cache.insert		(CI_ptr,CI_what);
				CI		= &*CI_ptr;
				bValid	= FALSE;
			} else {
				// Everything, OK. Check if info is still relevant...
				CI		= &*CI_ptr;
				bValid	= TRUE;
				if (!CI->Op.similar(CI->O->renderable.xform.c))	bValid = FALSE;
				else if (!CI->Lp.similar(CI->L->position))		bValid = FALSE;
			}
		}
		CI->time				= Device.dwTimeGlobal;	// acess time

		if (!bValid)			{
			// Frustum
			CFrustum				F;
			F.CreateFromMatrix		(S.M,FRUSTUM_P_ALL);

			// Query
			xrc.frustum_options		(0);
			xrc.frustum_query		(DB,F);
			if (0==xrc.r_count())	continue;

			// Clip polys by frustum
			tess.clear				();
			for (CDB::RESULT* p = xrc.r_begin(); p!=xrc.r_end(); p++)
			{
				VERIFY((p->id>=0)&&(p->id<DB->get_tris_count()));
				// 
				CDB::TRI&	t		= TRIS[p->id];
				if (t.suppress_shadows) continue;
				sPoly		A,B;
				A.push_back			(VERTS[t.verts[0]]);
				A.push_back			(VERTS[t.verts[1]]);
				A.push_back			(VERTS[t.verts[2]]);

				// Calc plane, throw away degenerate tris and invisible to light polygons
				Fplane				P;	float mag = 0;
				Fvector				t1,t2,n;
				t1.sub				(A[0],A[1]);
				t2.sub				(A[0],A[2]);
				n.crossproduct		(t1,t2);
				mag	= n.square_magnitude();
				if (mag<EPS_S)						continue;
				n.mul				(1.f/_sqrt(mag));
				P.build_unit_normal	(A[0],n);
				float	DOT_Fade	= P.classify(S.L->position);
				if (DOT_Fade<0)		continue;

				// Clip polygon
				sPoly*		clip	= F.ClipPoly	(A,B);
				if (0==clip)		continue;
//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,代码来源:LightShadows.cpp

示例11: render_selected

void CGlowManager::render_selected()
{
	// 2. Sort by shader
	std::sort		(Selected.begin(),Selected.end(),glow_compare);

	FVF::LIT		*pv;

	u32				pos = 0, count;
	ref_shader		T;

	Fplane			NP;
	NP.build		(Device.vCameraPosition,Device.vCameraDirection);

	float		dlim2	= MAX_GlowsDist2;
	for (;pos<Selected.size();) 
	{
		T		= ((CGlow*)Selected[pos]._get())->shader;
		count	= 0;
		while	((pos+count<Selected.size()) && (((CGlow*)Selected[pos+count]._get())->shader==T)) count++;

		u32		vOffset;
		u32		end		= pos+count;
		FVF::LIT* pvs	= pv = (FVF::LIT*) RCache.Vertex.Lock(count*4,hGeom->vb_stride,vOffset);
		for (; pos<end; pos++)
		{
			// Cull invisible 
			CGlow&	G					= *( (CGlow*)Selected[pos]._get() );
			if (G.fade<=1.f)			continue;

			// Now perform dotproduct if need it
			float	scale	= 1.f, dist_sq;
			Fvector	dir;
			dir.sub			(Device.vCameraPosition,G.position);
			dist_sq			= dir.square_magnitude();
			if (G.direction.square_magnitude()>EPS)	{
				dir.div			(_sqrt(dist_sq));
				scale			= dir.dotproduct(G.direction);
			}
			if (G.fade*scale<=1.f)		continue;

			// near fade
			float dist_np	= NP.distance(G.position)-VIEWPORT_NEAR;
			float snear		= dist_np/0.15f;	clamp	(snear,0.f,1.f);
			scale			*=	snear;
			if (G.fade*scale<=1.f)		continue;

			u32 C			= iFloor(G.fade*scale*(1-(dist_sq/dlim2)));
			u32 clr			= color_rgba(C,C,C,C);
			Fvector	gp		;
					gp.mad	(G.position,dir,G.radius*scale);
			FillSprite		(pv,G.position,G.radius,clr);
		}
		int vCount				= int(pv-pvs);
		RCache.Vertex.Unlock	(vCount,hGeom->vb_stride);
		if (vCount) {
			RCache.set_Shader		(T);
			RCache.set_Geometry		(hGeom);
			RCache.Render			(D3DPT_TRIANGLELIST,vOffset,0,vCount,0,vCount/2);
		}
	}
	Selected.clear_not_free			();
}
开发者ID:2asoft,项目名称:xray,代码行数:62,代码来源:GlowManager.cpp


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