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


C++ CFrustum类代码示例

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


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

示例1: u_EventGen

void CActor::PickupModeUpdate()
{
	if(!m_bPickupMode) return;
	if (GameID() != GAME_SINGLE) return;

	//подбирание объекта
	if(inventory().m_pTarget && inventory().m_pTarget->Useful() &&
		m_pUsableObject && m_pUsableObject->nonscript_usable() &&
		!Level().m_feel_deny.is_object_denied(smart_cast<CGameObject*>(inventory().m_pTarget)) )
	{
		NET_Packet P;
		u_EventGen(P, GE_OWNERSHIP_TAKE, ID());
		P.w_u16(inventory().m_pTarget->object().ID());
		u_EventSend(P);
	}

	//. ????? GetNearest ?????
	feel_touch_update	(Position(), /*inventory().GetTakeDist()*/m_fPickupInfoRadius);
	
	CFrustum frustum;
	frustum.CreateFromMatrix(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);
	//. slow (ray-query test)
	for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++)
		if (CanPickItem(frustum,Device.vCameraPosition,*it)) PickupInfoDraw(*it);
}
开发者ID:Karlan88,项目名称:xray,代码行数:25,代码来源:Actor_Feel.cpp

示例2: Game

void CActor::PickupModeUpdate()
{
	if(!m_bPickupMode)				return; // kUSE key pressed
	if(!IsGameTypeSingle())			return;

	//подбирание объекта
	if(	m_pObjectWeLookingAt									&& 
		m_pObjectWeLookingAt->cast_inventory_item()				&& 
		m_pObjectWeLookingAt->cast_inventory_item()->Useful()	&&
		m_pUsableObject											&& 
		!m_pUsableObject->nonscript_usable()					&&
		!Level().m_feel_deny.is_object_denied(m_pObjectWeLookingAt) )
	{
		m_pUsableObject->use(this);
		Game().SendPickUpEvent(ID(), m_pObjectWeLookingAt->ID());
	}

	feel_touch_update	(Position(), m_fPickupInfoRadius);
	
	CFrustum frustum;
	frustum.CreateFromMatrix(Device.mFullTransform, FRUSTUM_P_LRTB|FRUSTUM_P_FAR);

	for(xr_vector<CObject*>::iterator it = feel_touch.begin(); it != feel_touch.end(); it++)
	{
		if (CanPickItem(frustum, Device.vCameraPosition, *it)) 
			PickupInfoDraw(*it);
	}
}
开发者ID:zcaliptium,项目名称:xray-16,代码行数:28,代码来源:Actor_Feel.cpp

示例3: GetTransform

void CInstanceMesh::Render()
{
  if ( !mStaticMesh || !GetActive() )
    return;

  Math::Mat44f lTransform = GetTransform();
  mCenter = lTransform* mStaticMesh->GetAABB().GetCenter();

  if( mIsDynamic )
  {    
      mPhysicActor->GetMat44( lTransform );
      Math::Vect3f lUp( 0.0f, -mStaticMesh->GetAABB().GetCenter().y, 0.0f );

      Math::Mat44f lCenterTransform;
      lCenterTransform.SetIdentity();

      lCenterTransform.Translate( lUp );
      lTransform = lTransform * lCenterTransform;
  }

  CFrustum lCameraFrustum = CameraMInstance->GetCurrentCamera()->GetFrustum();
  CGraphicsManager* lGM = GraphicsInstance;
  if ( lCameraFrustum.SphereVisible( D3DXVECTOR3( mCenter.u ), mRadius ) )
  {
    lGM ->SetTransform( lTransform );
    mStaticMesh->Render( lGM  );
    lGM ->SetTransform( Math::Mat44f() );
  }
}
开发者ID:mvuab-g1-14-15,项目名称:AlmostHuman,代码行数:29,代码来源:InstanceMesh.cpp

示例4:

	void	Vision::feel_vision_query	(Fmatrix& mFull, Fvector& P)
	{
		CFrustum								Frustum		;
		Frustum.CreateFromMatrix				(mFull,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);

		// Traverse object database
		r_spatial.clear_not_free				();
		g_SpatialSpace->q_frustum
			(
			r_spatial,
			0,
			STYPE_VISIBLEFORAI,
			Frustum
			);

		// Determine visibility for dynamic part of scene
		seen.clear_and_reserve					()	;
		for (u32 o_it=0; o_it<r_spatial.size(); o_it++)
		{
			ISpatial*	spatial								= r_spatial					[o_it];
			CObject*	object								= spatial->dcast_CObject	();
			if (object && feel_vision_isRelevant(object))	seen.push_back				(object);
		}
		if (seen.size()>1) 
		{
			std::sort							(seen.begin(),seen.end());
			xr_vector<CObject*>::iterator end	= std::unique	(seen.begin(),seen.end());
			if (end!=seen.end()) seen.erase		(end,seen.end());
		}
	}
开发者ID:2asoft,项目名称:xray,代码行数:30,代码来源:Feel_Vision.cpp

示例5: Intersect

///////////////////////////////////////////////////////////////////////////////
// Intersect with frustum by repeated slicing
void CBrush::Intersect(const CFrustum& frustum, CBrush& result) const
{
	ENSURE(&result != this);

	if (!frustum.GetNumPlanes())
	{
		result = *this;
		return;
	}

	CBrush buf;
	const CBrush* prev = this;
	CBrush* next;

	// Repeatedly slice this brush with each plane of the frustum, alternating between 'result' and 'buf' to 
	// save intermediate results. Set up the starting brush so that the final version always ends up in 'result'.

	if (frustum.GetNumPlanes() & 1)
		next = &result;
	else
		next = &buf;

	for(size_t i = 0; i < frustum.GetNumPlanes(); ++i)
	{
		prev->Slice(frustum[i], *next);
		prev = next;
		if (prev == &buf)
			next = &result;
		else
			next = &buf;
	}

	ENSURE(prev == &result);
}
开发者ID:TiriliPiitPiit,项目名称:0ad,代码行数:36,代码来源:Brush.cpp

示例6: UpdateSlotBBox

void EDetailManager::UpdateSlotBBox(int sx, int sz, DetailSlot& slot)
{
	Fbox bbox;
    Frect rect;
    GetSlotRect			(rect,sx,sz);
    bbox.min.set		(rect.x1, m_BBox.min.y, rect.y1);
    bbox.max.set		(rect.x2, m_BBox.max.y, rect.y2);

    SBoxPickInfoVec pinf;
    ETOOLS::box_options(0);
    if (Scene->BoxPickObjects(bbox,pinf,&m_SnapObjects)){
		bbox.grow		(EPS_L_VAR);
    	Fplane			frustum_planes[4];
		frustum_planes[0].build(bbox.min,left_vec);
		frustum_planes[1].build(bbox.min,back_vec);
		frustum_planes[2].build(bbox.max,right_vec);
		frustum_planes[3].build(bbox.max,fwd_vec);

        CFrustum frustum;
        frustum.CreateFromPlanes(frustum_planes,4);

        float y_min		= flt_max;
        float y_max		= flt_min;
		for (SBoxPickInfoIt it=pinf.begin(); it!=pinf.end(); it++){
        	for (int k=0; k<(int)it->inf.size(); k++){
                float range;
                Fvector verts[3];
                it->e_obj->GetFaceWorld(it->s_obj->_Transform(),it->e_mesh,it->inf[k].id,verts);
                sPoly sSrc	(verts,3);
                sPoly sDest;
                sPoly* sRes = frustum.ClipPoly(sSrc, sDest);
                if (sRes){
                    for (u32 k=0; k<sRes->size(); k++){
                        float H = (*sRes)[k].y;
                        if (H>y_max) y_max = H+0.03f;
                        if (H<y_min) y_min = H-0.03f;
                    }
                    slot.w_y	(y_min,y_max-y_min);
                    slot.w_id(0,DetailSlot::ID_Empty);
                    slot.w_id(1,DetailSlot::ID_Empty);
                    slot.w_id(2,DetailSlot::ID_Empty);
                    slot.w_id(3,DetailSlot::ID_Empty);
                }
            }
	    }
    }else{
    	ZeroMemory(&slot,sizeof(DetailSlot));
    	slot.w_id(0,DetailSlot::ID_Empty);
    	slot.w_id(1,DetailSlot::ID_Empty);
    	slot.w_id(2,DetailSlot::ID_Empty);
    	slot.w_id(3,DetailSlot::ID_Empty);
    }
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:53,代码来源:ESceneDOTools_Generate.cpp

示例7:

void __stdcall	CHOM::MT_RENDER()
{
	MT.Enter					();
	bool b_main_menu_is_active = (g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive() );
	if (MT_frame_rendered!=Device.dwFrame && !b_main_menu_is_active)
	{
		CFrustum					ViewBase;
		ViewBase.CreateFromMatrix	(Device.mFullTransform, FRUSTUM_P_LRTB + FRUSTUM_P_FAR);
		Enable						();
		Render						(ViewBase);
	}
	MT.Leave					();
}
开发者ID:2asoft,项目名称:xray-16,代码行数:13,代码来源:HOM.cpp

示例8: EnumerateObjects

///////////////////////////////////////////////////////////
// This callback is part of the Scene interface
// Submit all objects visible in the given frustum
void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c)
{
	{
	PROFILE3("submit terrain");

	CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain();
	float waterHeight = g_Renderer.GetWaterManager()->m_WaterHeight + 0.001f;
	const ssize_t patchesPerSide = pTerrain->GetPatchesPerSide();

	// find out which patches will be drawn
	for (ssize_t j=0; j<patchesPerSide; ++j)
	{
		for (ssize_t i=0; i<patchesPerSide; ++i)
		{
			CPatch* patch=pTerrain->GetPatch(i,j);	// can't fail

			// If the patch is underwater, calculate a bounding box that also contains the water plane
			CBoundingBoxAligned bounds = patch->GetWorldBounds();
			if(bounds[1].Y < waterHeight)
				bounds[1].Y = waterHeight;

			if (!m->Culling || frustum.IsBoxVisible(bounds))
				c->Submit(patch);
		}
	}
	}

	m->Game->GetSimulation2()->RenderSubmit(*c, frustum, m->Culling);
}
开发者ID:krichter722,项目名称:0ad,代码行数:32,代码来源:GameView.cpp

示例9: ACEASSERT

/**
* CABT::renderTree
* @date Modified Apr 17, 2006
*/
void CABT::renderTree(CFrustum& oFrustum, SABTNode* pNode, bool bContained)
{
	ACEASSERT(pNode);

	// Process subnodes
	CFrustum::EFrustumTest eTest = CFrustum::TEST_IN;
	eTest = oFrustum.containsAABB(pNode->m_oAABB);
	if(eTest == CFrustum::TEST_OUT)
		return;

	// Draw geometry, if the node is a leaf.
	if(pNode->m_bIsLeaf)
	{
		for(size_t v = 0; v < pNode->m_nVertCount/3; ++v)
			m_pRenderQueue->addRenderable(&pNode->m_pTris[v]);

		m_nNumTrianglesRendered += pNode->m_nVertCount / 3;

#ifdef _DEBUG
		static int i = 0;
		if(true)
		{
			drawBoundingBox(pNode->m_oAABB, D3DCOLOR_XRGB(255, 0, 0));
		}

#endif
	}

	if(pNode->m_pLeft) renderTree(oFrustum, pNode->m_pLeft, eTest == CFrustum::TEST_IN);
	if(pNode->m_pRight) renderTree(oFrustum, pNode->m_pRight, eTest == CFrustum::TEST_IN);
}
开发者ID:mattrudder,项目名称:AckZombies,代码行数:35,代码来源:ABT.CPP

示例10: renderTree

/**
* CABT::renderTree
* @date Modified Apr 17, 2006
*/
void CABT::renderTree(CFrustum& oFrustum)
{
	if(!m_pRoot)
		return;

	m_nNumTrianglesRendered = 0;
	renderTree(oFrustum, m_pRoot);
	m_pRenderQueue->renderAll(oFrustum.getViewPosition());
}
开发者ID:mattrudder,项目名称:AckZombies,代码行数:13,代码来源:ABT.CPP

示例11: _IsInFrustum

int ZQuadTree::_IsInFrustum(CGeoMapData &pHeightMap, Point &bottomLeft, CFrustum& pFrustum)
{
	bool b[4];
	bool bInSphere;

	bInSphere = pFrustum.SphereInFrustum(bottomLeft.x + m_nCenter.x, bottomLeft.y + m_nCenter.y, 0, m_fRadius);
	if(!bInSphere) return FRUSTUM_OUT;

	b[0] = pFrustum.PointInFrustum(bottomLeft.x + m_nCorner[0].x, bottomLeft.y + m_nCorner[0].y, 0);
	b[1] = pFrustum.PointInFrustum(bottomLeft.x + m_nCorner[1].x, bottomLeft.y + m_nCorner[1].y, 0);
	b[2] = pFrustum.PointInFrustum(bottomLeft.x + m_nCorner[2].x, bottomLeft.y + m_nCorner[2].y, 0);
	b[3] = pFrustum.PointInFrustum(bottomLeft.x + m_nCorner[3].x, bottomLeft.y + m_nCorner[3].y, 0);

	if(b[0] + b[1] + b[2] + b[3] == 4)
		return FRUSTUM_COMPLETELY_IN;

	return FRUSTUM_PRTIALLY_IN;
}
开发者ID:GiantBaby90,项目名称:LandMark,代码行数:18,代码来源:ZquadTree.cpp

示例12: MK_Frustum

void MK_Frustum(CFrustum& F, float FOV, float _FAR, float A, Fvector &P, Fvector &D, Fvector &U)
{
    float YFov	= deg2rad(FOV);
    float XFov	= deg2rad(FOV/A);

    // calc window extents in camera coords
    float wR=tanf(XFov*0.5f);
    float wL=-wR;
    float wT=tanf(YFov*0.5f);
    float wB=-wT;

    // calc x-axis (viewhoriz) and store cop
    // here we are assuring that vectors are perpendicular & normalized
    Fvector			R,COP;
    D.normalize		();
    R.crossproduct	(D,U);
    R.normalize		();
    U.crossproduct	(R,D);
    U.normalize		();
    COP.set			(P);

    // calculate the corner vertices of the window
    Fvector			sPts[4];  // silhouette points (corners of window)
    Fvector			Offset,T;
    Offset.add		(D,COP);

    sPts[0].mul(R,wR);
    T.mad(Offset,U,wT);
    sPts[0].add(T);
    sPts[1].mul(R,wL);
    T.mad(Offset,U,wT);
    sPts[1].add(T);
    sPts[2].mul(R,wL);
    T.mad(Offset,U,wB);
    sPts[2].add(T);
    sPts[3].mul(R,wR);
    T.mad(Offset,U,wB);
    sPts[3].add(T);

    // find projector direction vectors (from cop through silhouette pts)
    Fvector ProjDirs[4];
    ProjDirs[0].sub(sPts[0],COP);
    ProjDirs[1].sub(sPts[1],COP);
    ProjDirs[2].sub(sPts[2],COP);
    ProjDirs[3].sub(sPts[3],COP);

    Fvector _F[4];
    _F[0].mad(COP, ProjDirs[0], _FAR);
    _F[1].mad(COP, ProjDirs[1], _FAR);
    _F[2].mad(COP, ProjDirs[2], _FAR);
    _F[3].mad(COP, ProjDirs[3], _FAR);

    F.CreateFromPoints(_F,4,COP);
}
开发者ID:vasilenkomike,项目名称:xray,代码行数:54,代码来源:dbg_draw_frustum.cpp

示例13: FrustumPick

bool CGroupObject::FrustumPick(const CFrustum& frustum)
{
    if (m_Objects.empty()){
        Fbox 		bb;
        GetBox		(bb);
        u32 mask	= u32(-1); 
        return (frustum.testAABB(bb.data(),mask));
    }else{
        for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++)
            if ((*it)->FrustumPick(frustum)) return true;
    }
    return false;
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:13,代码来源:GroupObject.cpp

示例14: FrustumPick

bool CEditShape::FrustumPick(const CFrustum& frustum)
{
	const Fmatrix& M	= _Transform();
	for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){
		switch (it->type){
		case cfSphere:{
		    Fvector 	C;
            Fsphere&	T	= it->data.sphere;
		    M.transform_tiny(C,T.P);
        	if (frustum.testSphere_dirty(C,T.R*FScale.x)) return true;
		}break;
		case cfBox:{
        	Fbox 			box;
            box.identity	();
            Fmatrix B		= it->data.box;
            B.mulA_43 		(_Transform());
            box.xform		(B);
			u32 mask		= 0xff;
            if (frustum.testAABB(box.data(),mask)) return true;
		}break;
		}
    }
	return false;
}
开发者ID:2asoft,项目名称:xray,代码行数:24,代码来源:EShape.cpp

示例15: CreateFromClipPoly

BOOL CFrustum::CreateFromClipPoly(Fvector* p, int count, Fvector& vBase, CFrustum& clip)
{
	VERIFY(count<FRUSTUM_MAXPLANES);
	VERIFY(count>=3);

	sPoly	poly1	(p,count);
	sPoly	poly2;
	sPoly*	dest	= clip.ClipPoly(poly1,poly2);

	// here we end up with complete frustum-polygon in 'dest'
	if (0==dest)	return false;

	CreateFromPoints(dest->begin(),dest->size(),vBase);
	return	true;
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:15,代码来源:Frustum.cpp


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