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


C++ ManualObject::beginUpdate方法代码示例

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


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

示例1: Update

///---------------------------------------------------------------------------------------------------------------
//  Update HUD
///---------------------------------------------------------------------------------------------------------------
void CHud::Update(int carId, float time)
{
	PROFILER.beginBlock("g.hud");

	
	//  update HUD elements for all cars that have a viewport (local or replay)
	//-----------------------------------------------------------------------------------
	int cnt = std::min(6/**/, (int)app->carModels.size());  // all cars
	int cntC = std::min(4/**/, cnt - (app->isGhost2nd && !app->bRplPlay ? 1 : 0));  // all vis plr
	int c;
	
	//  gui viewport - done once for all
	if (carId == -1)
	for (c = 0; c < cntC; ++c)
	if (app->carModels[c]->eType == CarModel::CT_LOCAL)
	{
		//  hud rpm,vel
		float vel=0.f, rpm=0.f, clutch=1.f;  int gear=1;
		GetVals(c,&vel,&rpm,&clutch,&gear);
		
		//  update all mini pos tri
		for (int i=0; i < cnt; ++i)
			UpdRot(c, i, vel, rpm);
	}

	///  all minimap car pos-es rot
	const static Real tc[4][2] = {{0,1}, {1,1}, {0,0}, {1,0}};
	const float z = pSet->size_minipos;  // tri size
	
	if (carId == -1 && moPos)
	{	moPos->beginUpdate(0);

		const int plr = app->mSplitMgr->mNumViewports;
		for (int v = 0; v < plr; ++v)  // all viewports
		{
			const Hud& h = hud[v];
			const float sc = pSet->size_minimap * app->mSplitMgr->mDims[v].avgsize;
			const Vector3& pos = h.ndMap->getPosition();
			
			for (c = 0; c < cntC; ++c)  // all mini pos for one car
			{
				const SMiniPos& sp = h.vMiniPos[c];
				const ColourValue& clr = app->carModels[c]->color;

				for (int p=0; p < 4; ++p)  // all 4 points
				{
					float x = pos.x + (sp.x + sp.px[p]*z)*sc;
					float y = pos.y + (sp.y + sp.py[p]*z)*sc*asp;
					moPos->position(x, y, 0);
					moPos->textureCoord(tc[p][0], tc[p][1]);
					moPos->colour(clr);
		}	}	}
		
		int ii = plr * cntC;
		for (int i=0; i < ii; ++i)
		{	int n = i*4;
			moPos->quad(n,n+1,n+3,n+2);
		}
		moPos->end();
	}

	//  track% local, updated always
	for (c = 0; c < cntC; ++c)
	{	CarModel* cm = app->carModels[c];
		if (cm->eType == CarModel::CT_LOCAL ||
			cm->eType == CarModel::CT_REPLAY)
			cm->UpdTrackPercent();
	}
	
	if (carId == -1 || app->carModels.empty())
	{
		PROFILER.endBlock("g.hud");
		return;
	}

	#ifdef DEBUG
	assert(carId >= 0);
	assert(carId < app->carModels.size());
	#endif


	CarModel* pCarM = app->carModels[carId];
	CAR* pCar = pCarM ? pCarM->pCar : 0;

	float vel=0.f, rpm=0.f, clutch=1.f;  int gear=1;
	GetVals(carId,&vel,&rpm,&clutch,&gear);
	Hud& h = hud[carId];


	///  multiplayer
	// -----------------------------------------------------------------------------------
	static float tm = 0.f;  tm += time;
	if (tm > 0.2f /**/&& app->mClient/**/)  // not every frame, each 0.2s
	// if (pSet->game.isNetw) ..
	{
		//  sort winners
		std::list<CarModel*> cms;
//.........这里部分代码省略.........
开发者ID:HaohaoLau,项目名称:stuntrally,代码行数:101,代码来源:Hud_Update.cpp

示例2:

    //---------------------------------------------------------------------
    void Grid3DPageStrategy::updateDebugDisplay(Page* p, SceneNode* sn)
    {
        uint8 dbglvl = mManager->getDebugDisplayLevel();
        if (dbglvl)
        {
            // we could try to avoid updating the geometry every time here, but this 
            // wouldn't easily deal with paging parameter changes. There shouldn't 
            // be that many pages anyway, and this is debug after all, so update every time
            int32 x, y, z;
            Grid3DPageStrategyData* stratData = static_cast<Grid3DPageStrategyData*>(
                p->getParentSection()->getStrategyData());
            stratData->calculateCell(p->getID(), &x, &y, &z);

            Grid3DPageStrategyData* data = static_cast<Grid3DPageStrategyData*>(p->getParentSection()->getStrategyData());

            // Determine our centre point, we'll anchor here
            Vector3 midPoint;
            data->getMidPointGridSpace(x, y, z, midPoint);
            sn->setPosition(midPoint);

            //--- Get coordinates, relative to midPoint :
            Vector3 corners[8];
            Vector3 hSize = 0.500f * stratData->getCellSize();
            for (int i = 0; i < 8; ++i)
            {
                corners[i].x = i&1 ? hSize.x : -hSize.x;
                corners[i].z = i&2 ? hSize.y : -hSize.y;
                corners[i].y = i&4 ? hSize.z : -hSize.z;
            }

            //--- Get a material
            String matName = "Ogre/G3D/Debug";
            MaterialPtr mat = MaterialManager::getSingleton().getByName(matName);
            if (mat.isNull())
            {
                mat = MaterialManager::getSingleton().create(matName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
                Pass* pass = mat->getTechnique(0)->getPass(0);
                pass->setLightingEnabled(false);
                pass->setVertexColourTracking(TVC_AMBIENT);
                pass->setDepthWriteEnabled(false);
                mat->load();
            }

            ManualObject* mo = 0;
            bool update = sn->numAttachedObjects() > 0;
            if( update )
            {
                mo = static_cast<ManualObject*>(sn->getAttachedObject(0));
                mo->beginUpdate(0);
            }
            else
            {
                mo = p->getParentSection()->getSceneManager()->createManualObject();
                mo->begin(matName, RenderOperation::OT_LINE_STRIP);
            }

            ColourValue vcol = ColourValue::Green;
            mo->position(corners[0]); mo->colour(vcol); // First Square...
            mo->position(corners[1]); mo->colour(vcol);
            mo->position(corners[3]); mo->colour(vcol);
            mo->position(corners[2]); mo->colour(vcol);
            mo->position(corners[0]); mo->colour(vcol);
            mo->position(corners[4]); mo->colour(vcol); // 0-4 link + second square and 
            mo->position(corners[5]); mo->colour(vcol);
            mo->position(corners[7]); mo->colour(vcol);
            mo->position(corners[6]); mo->colour(vcol);
            mo->position(corners[4]); mo->colour(vcol);
            mo->position(corners[5]); mo->colour(vcol); // 5-1 link
            mo->position(corners[1]); mo->colour(vcol);
            mo->position(corners[3]); mo->colour(vcol); // 3-7 link
            mo->position(corners[7]); mo->colour(vcol);
            mo->position(corners[6]); mo->colour(vcol); // 6-2 link
            mo->position(corners[2]); mo->colour(vcol);
            mo->end();

            if(!update)
                sn->attachObject(mo);
        }
    }
开发者ID:Gerviba,项目名称:MuOnline,代码行数:80,代码来源:OgreGrid3DPageStrategy.cpp


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