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


C++ GetElapsedTime函数代码示例

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


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

示例1: ManageObjectsAfterEvents

void RuntimeScene::ManageObjectsAfterEvents()
{
    //Delete objects that were removed.
    RuntimeObjList allObjects = objectsInstances.GetAllObjects();
    for (unsigned int id = 0;id<allObjects.size();++id)
    {
    	if ( allObjects[id]->GetName().empty() )
        {
            for (unsigned int i = 0;i<extensionsToBeNotifiedOnObjectDeletion.size();++i)
                extensionsToBeNotifiedOnObjectDeletion[i]->ObjectDeletedFromScene(*this, allObjects[id].get());

            objectsInstances.RemoveObject(allObjects[id]); //Remove from objects instances, not from the temporary list!
        }
    }

    //Update objects positions, forces and automatisms
    allObjects = objectsInstances.GetAllObjects();
    for (unsigned int id = 0;id<allObjects.size();++id)
    {
        allObjects[id]->SetX( allObjects[id]->GetX() + ( allObjects[id]->TotalForceX() * static_cast<double>(GetElapsedTime())/1000000.0 ));
        allObjects[id]->SetY( allObjects[id]->GetY() + ( allObjects[id]->TotalForceY() * static_cast<double>(GetElapsedTime())/1000000.0 ));
        allObjects[id]->UpdateTime( static_cast<double>(GetElapsedTime())/1000000.0 );
        allObjects[id]->UpdateForce( static_cast<double>(GetElapsedTime())/1000000.0 );
        allObjects[id]->DoAutomatismsPostEvents(*this);
    }
}
开发者ID:AntonioModer,项目名称:GD,代码行数:26,代码来源:RuntimeScene.cpp

示例2: while

// 指定距離移動
void ExtraStageLookUp::MoveDist(
		char	cLRsw,			// ライントレース位置 'L':左、'R':右、'N':トレースなし
		int		nDist,			// 移動距離 mm単位
		float	fTailAngle,
		int		nForward
		)
{
	//-----ログ出力-----
	char*	cLogBuff	= m_pUIGet->GetBlueT()->pcLogBuff;
	//------------------

	DV	dv;

	int32_t		nLmotorCountS = m_pDeviceInterface->m_pCLeftMotor->getCount();
	int32_t		nRmotorCountS = m_pDeviceInterface->m_pCRightMotor->getCount();
	int32_t		nMotorCountS  = ( nLmotorCountS + nRmotorCountS ) / 2;
	while(1){
		int32_t		nLmotorCountN = m_pDeviceInterface->m_pCLeftMotor->getCount();
		int32_t		nRmotorCountN = m_pDeviceInterface->m_pCRightMotor->getCount();
		int32_t		nMotorCountN  = ( nLmotorCountN + nRmotorCountN ) / 2;

		int32_t		nRunCount	= nMotorCountN - nMotorCountS;
		double		dRunDist	= GetRunDistance(nRunCount);	//オフセット付き角位置から距離mmに変換

		if( dRunDist >= (double)nDist ){
			//-----ログ出力-----
			sprintf(cLogBuff,"MoveDist  %lu, nDist=%d, nRunCount=%ld, dRunDist=%f\n", GetElapsedTime(),
					nDist, nRunCount, dRunDist);
			m_pUIGet->WriteLog(cLogBuff);
			//------------------
			break;
		}

		// ライントレース制御
		dv	= CalcuTraceMoterPower( cLRsw, nForward );

		// モータードライブ
		m_pMotorDrive->TailMotorDrive(fTailAngle);
		m_pMotorDrive->LRMotorDrive( dv.Lmotor_pwm, dv.Rmotor_pwm );

		//ログ出力
		sprintf(cLogBuff,"ExtraRun MoveDist %lu, cLRsw=[%c], nDist=%d,  fTailAngle=%f, nForward=%d, color=%d, Lmotor_pwm=%d, Rmotor_pwm=%d\n",
				GetElapsedTime(),
				cLRsw,
				nDist,
				fTailAngle,
				nForward,
				dv.color,
				dv.Lmotor_pwm, dv.Rmotor_pwm
		);

		m_pDeviceInterface->m_pCClock->sleep(4); // 4msec周期起動

		if( IsKeyBreak(fTailAngle) )	break;
	}
}
开发者ID:MaedaSumire,项目名称:2016eitnreotb,代码行数:57,代码来源:ExtraStageLookUp.cpp

示例3: sprintf

// ゲートに行く
void ExtraStageLookUp::GoGate(
			char	cLRsw,			// ライントレース位置 'L':左、'R':右、'N':トレースなし
			float	fTailAngle
		)
{
	//-----ログ出力-----
	char*	cLogBuff	= m_pUIGet->GetBlueT()->pcLogBuff;
	//------------------
	DV	dv;
	int		nForward	= 10;	// 走行速度

//	int16_t	nDistanceMin = 5;	// ソナーセンサー距離cm
	int16_t	nDistanceMin = 7;	// ソナーセンサー距離cm

	int16_t nDistance	= m_pDeviceInterface->m_pCSonarSensor->getDistance();

	for(int i=0 ; ; i++ ){
		if( i % 10 == 9 ){
			// 40ミリ秒毎にソナー検出
			nDistance	=  m_pDeviceInterface->m_pCSonarSensor->getDistance();
		}

		if( nDistance <= nDistanceMin ){
			// ゲート前に到着
			//ログ出力
			sprintf(cLogBuff,"ExtraRun GoGate %lu, nDistance=%d\n", GetElapsedTime(), nDistance);
			m_pUIGet->WriteLog(cLogBuff);
			break;
		}

		// ライントレース制御
		dv	= CalcuTraceMoterPower( cLRsw, nForward );

		// モータードライブ
		m_pMotorDrive->TailMotorDrive(fTailAngle);
		m_pMotorDrive->LRMotorDrive(dv.Lmotor_pwm, dv.Rmotor_pwm);

		//ログ出力
		sprintf(cLogBuff,"ExtraRun GoGate %lu, cLRsw=[%c], nDistance=%d,  fTailAngle=%f, nForward=%d, color=%d, Lmotor_pwm=%d, Rmotor_pwm=%d\n",
				GetElapsedTime(),
				cLRsw,
				nDistance,
				fTailAngle,
				nForward,
				dv.color,
				dv.Lmotor_pwm, dv.Rmotor_pwm
		);
		m_pUIGet->WriteLog(cLogBuff);

		m_pDeviceInterface->m_pCClock->sleep(4); // 4msec周期起動
		if( IsKeyBreak(fTailAngle) )	break;

	}

}
开发者ID:MaedaSumire,项目名称:2016eitnreotb,代码行数:56,代码来源:ExtraStageLookUp.cpp

示例4: Vector2

void Body::UpdateBody(void)
{
	if(IsUnmovable())
	{
		m_linearVelocity = Vector2(0.0f,0.0f);
		m_angularVelocity = 0.0f;
		return;
	}

	float elapsedTime = GetElapsedTime();

	// Apply damping
	m_linearVelocity -= m_linearVelocity * m_linearDamping * elapsedTime;
	m_angularVelocity -= m_angularVelocity * m_angularDamping * elapsedTime;

	// Apply damping forces
	//m_force -= m_linearVelocity * m_linearDamping * elapsedTime;
	//m_torque -= m_angularVelocity * m_angularDamping * elapsedTime;

	// Euler (First Order Taylor Expansion)
	// Integrate position
	//m_position += m_linearVelocity * elapsedTime;
	//m_orientation += m_angularVelocity * elapsedTime;

	// Integrate velocity
	//m_linearVelocity += m_force * (m_inverseMass * elapsedTime);
	//m_angularVelocity += m_torque * (m_inverseInertia * elapsedTime);

	// Second Order Taylor Expansion
	// Integrate position
	m_position += m_linearVelocity * GetElapsedTime() + 0.5f * m_force * m_inverseMass * elapsedTime * elapsedTime;
	m_orientation += m_angularVelocity * GetElapsedTime() + 0.5f * m_torque * m_inverseInertia * elapsedTime * elapsedTime;

	// Remove accumulated rotation
	while(m_orientation > M_PI*2)
		m_orientation -= M_PI*2;

	// Integrate velocity
	m_linearVelocity += m_force * m_inverseMass * elapsedTime;
	m_angularVelocity += m_torque * m_inverseInertia * elapsedTime;

	// Clear forces
	m_force.SetEmpty();
	m_torque = 0.0f;

	// Integrator stability test
	//Sleep(rand() % 40);
}
开发者ID:m1h4,项目名称:Xetrix,代码行数:48,代码来源:Game.cpp

示例5: GetElapsedTime

void StarSystem::Update( float priority )
{
    Unit *unit;
    bool  firstframe = true;
    //No time compression here
    float normal_simulation_atom = SIMULATION_ATOM;
    time += GetElapsedTime();
    _Universe->pushActiveStarSystem( this );
    if ( time/SIMULATION_ATOM >= (1./PHY_NUM) ) {
        while ( time/SIMULATION_ATOM >= (1.) ) {
            //Chew up all SIMULATION_ATOMs that have elapsed since last update
            ExecuteDirector();
            TerrainCollide();
            Unit::ProcessDeleteQueue();
            current_stage = MISSION_SIMULATION;
            collidetable->Update();
            for (un_iter iter = drawList.createIterator(); (unit = *iter); ++iter)
                unit->SetNebula( NULL );
            UpdateMissiles();                    //do explosions
            UpdateUnitPhysics( firstframe );

            firstframe = false;
        }
        time -= SIMULATION_ATOM;
    }
    SIMULATION_ATOM = normal_simulation_atom;
    _Universe->popActiveStarSystem();
}
开发者ID:Ezeer,项目名称:VegaStrike_win32FR,代码行数:28,代码来源:star_system_generic.cpp

示例6: GetElapsedTime

void Emitter::UpdateParticles(void)
{
	static const float linearDamping = 0.2f;

	for(unsigned long i = 0; i < _countof(m_particles); ++i)
	{
		if(m_particles[i].m_velocity.GetLength() < 0.0001f)
			continue;

		// Linear Taylor Expansion
		m_particles[i].m_position += m_particles[i].m_velocity * GetElapsedTime();

		// Simple velocity damping
		m_particles[i].m_velocity -= m_particles[i].m_velocity * linearDamping * GetElapsedTime();
	}
}
开发者ID:m1h4,项目名称:Xetrix,代码行数:16,代码来源:Game.cpp

示例7: GetElapsedTime

void CNetGame::Process()
{
	float fElapsedTime = GetElapsedTime();

	UpdateNetwork();

	if(this->gameState == 1) 
	{	
		if(this->playerPool) this->playerPool->Process(fElapsedTime);
		if(this->vehiclePool) this->vehiclePool->Process(fElapsedTime);
		if(this->objectPool) this->objectPool->Process(fElapsedTime);
		if(this->gamemodeManager) this->gamemodeManager->Frame(fElapsedTime);
		if(this->scriptTimerManager) this->scriptTimerManager->Process((uint32_t)(fElapsedTime * 1000.0f));
		if(this->scriptHttpManager) this->scriptHttpManager->Process();

		if ( __ElementFactory ) __ElementFactory->Process ( fElapsedTime );
	} 
	else if(this->gameState == 2) 
	{
		fRestartWaitTime += fElapsedTime;
		if(fRestartWaitTime > 12.0f)
		{
			ReInitWhenRestarting();
		}
	}

	if (__Console->GetBoolVar("announce"))
		MasterServerAnnounce(fElapsedTime);

	__Plugins->DoProcessTick();

	#ifndef WIN32
		this->elapsedTime += (double)fElapsedTime;
	#endif
}
开发者ID:trisz404,项目名称:OpenSAMP-WIP,代码行数:35,代码来源:CNetGame.cpp

示例8: GetElapsedTime

	void MenuElement::DrawTooltip( void ) {
	#if 0
		//FIXME: re-implement after redesigning menu elements
		if ( common.hidden ) {
			return;
		}

		const real64_t currentTime = GetElapsedTime();
		if ( tooltip.mouseHovering ) {
			tooltip.lastMouseTime = currentTime;
		}
		const real64_t fadeTime = 333.0;
		if ( /*!updatingValue &&*/ tooltip.lastMouseTime > currentTime - fadeTime ) {
			const real32_t alpha = static_cast<real32_t>(
				1.0 - ((currentTime - tooltip.lastMouseTime) / fadeTime)
			);
			static const vector4 colour = { 1.0f, 1.0f, 1.0f, alpha };
			const vector2 pos = {
				(tooltip.lastMousePos[0] + 0.03333f) * Renderer::rdState.window.width,
				tooltip.lastMousePos[1] * Renderer::rdState.window.height
			};
			tooltip.font->Draw(
				pos,
				tooltip.text,
				tooltip.pointSize,
				&colour
			);
		}
	#endif
	}
开发者ID:Razish,项目名称:xsngine,代码行数:30,代码来源:MenuElement.cpp

示例9: GetFrame

int GetFrame() {
	

	// Acquire frame
	
	printf("Acquiring from webcam frame number %d\n",frame_counter);
	gettimeofday(&step_start_time,NULL);
	
	if ( AcquisitionLoopV4L2(fg_v4l2,fr) != 0) {
		printf("Unexpexted error when acquiring frame v4l2 device \n");	
		return -1;
	}
	
	gettimeofday(&step_end_time,NULL);
    	GetElapsedTime("Frame acquisition", &step_start_time, &step_end_time, &acquisition_time );
	
	// If required, save one out of n_save_frame frames in a .ppm file
	
	if ( SAVE_FRAMES ) {
	
		if ( (frame_counter%n_save_frame) == 0){
			
			snprintf( frame_fname, sizeof(frame_fname), "frame_%d.ppm",frame_counter );
			SaveFrame(fr, frame_fname);	
			printf("Frame %d saved to file \n",frame_counter);
		
		}
	}	
		
	return 0;
}
开发者ID:clacarbone,项目名称:RosSaettaVision,代码行数:31,代码来源:v4l2_capture.c

示例10: SteamGameServer

/**
 * Give the async task time to do its work
 * Can only be called on the async task manager thread
 */
void FOnlineAsyncTaskSteamLogoffServer::Tick() 
{
	if (!bInit)
	{
		// @TODO ONLINE Listen Servers need to unset rich presence
		//SteamFriends()->SetRichPresence("connect", ""); for master server sessions
		SteamGameServer()->EnableHeartbeats(false);
		SteamGameServer()->LogOff();
		bInit = true;
	}

	// Wait for the disconnect
	FOnlineSessionSteamPtr SessionInt = StaticCastSharedPtr<FOnlineSessionSteam>(Subsystem->GetSessionInterface());
	if (!SessionInt->bSteamworksGameServerConnected && !SessionInt->GameServerSteamId.IsValid())
	{
		bIsComplete = true;
		bWasSuccessful = true;
	}
	else
	{
		// Fallback timeout in case we don't hear from Steam
		if (GetElapsedTime() >= ASYNC_TASK_TIMEOUT)
		{
			SessionInt->bSteamworksGameServerConnected = false;
			SessionInt->GameServerSteamId = NULL;
			bIsComplete = true;
			bWasSuccessful = false;
		}
	}
}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:34,代码来源:OnlineSessionAsyncServerSteam.cpp

示例11: IdleFunc

// IdleFunc()
// Idle function for between frames
void IdleFunc(void) 
{

   float deltaTime;

   // Mark time
   MarkTimeThisTick();
   deltaTime = GetElapsedTime() * GAME_SPEED;

   // Call the display routine next time through the main loop  

   glutPostRedisplay();

   HUDClearScreen();
   HUDPrintToScreen( "There is nothing to see but these text strings!!!\n\n" );
   HUDPrintToScreen( "This app shows a bare minimum AI engine implemented.\n" );
   HUDPrintToScreen( "Below you'll see the states of forty different game\n" );
   HUDPrintToScreen( "objects as they wander around in space. See if you\n" );
   HUDPrintToScreen( "can find a pattern. Then check the code to see if\n" );
   HUDPrintToScreen( "you're right. Hint: Great AI makes the player believe\n" );
   HUDPrintToScreen( "that the game is smarter than it really is.\n\n\n" );

   //Send any messages that have been waiting
   SendDelayedMessages();

   // Update all game objects in the AI engine
   GODBUpdate();

   GODBOutputStateInfoToHUD();

}
开发者ID:wrx-sam,项目名称:myai_engine,代码行数:33,代码来源:main.cpp

示例12: while

void System::gameLoop(){
    SDL_Event Event;
	bool running = true;
    while(running) {
        while(SDL_PollEvent(&Event)) {
			switch( Event.type ){
			case SDL_KEYDOWN:
			case SDL_KEYUP:
				mInputHandler->KeyDown( Event.key.keysym.sym , Event.key.state == SDL_PRESSED );
				break;
			case SDL_MOUSEMOTION:
				mInputHandler->MouseMoved( Event.motion.x, Event.motion.y );
				break;
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				mInputHandler->MouseDown( Event.button.button, Event.button.state == SDL_PRESSED, Event.button.x, Event.button.y );
				break;
			case SDL_QUIT:
				running = false;
				break;
			default:
				break;
			}
        }
		mObjectMgr->Update(GetElapsedTime());
		mRenderer->drawScene();
    }
	return;
}
开发者ID:usewits,项目名称:TwinGame,代码行数:29,代码来源:System.cpp

示例13: GETCURRENTTIME

RetCode StmtHandler::Execute(ExecutedResult* exec_result) {
  GETCURRENTTIME(start_time);
  RetCode ret = rSuccess;
  sql_parser_ = new Parser(sql_stmt_);
  AstNode* raw_ast = sql_parser_->GetRawAST();
  if (NULL == raw_ast) {
    exec_result->error_info_ = "Parser Error";
    exec_result->status_ = false;
    exec_result->result_ = NULL;
    return rParserError;
  }
  raw_ast->Print();
  ret = GenerateStmtExec(raw_ast);
  if (rSuccess != ret) {
    return ret;
  }
  ret = stmt_exec_->Execute(exec_result);
  if (rSuccess != ret) {
    return ret;
  }
  double exec_time_ms = GetElapsedTime(start_time);
  if (NULL != exec_result->result_)
    exec_result->result_->query_time_ = exec_time_ms / 1000.0;
  cout << "execute time: " << exec_time_ms / 1000.0 << " sec" << endl;
  return rSuccess;
}
开发者ID:JolyZhang,项目名称:CLAIMS,代码行数:26,代码来源:stmt_handler.cpp

示例14: UpdateGraphics

bool PointStarVlist::BeginDrawState (const QVector &center, const Vector & velocity, const Vector & torque, bool roll, bool yawpitch, int whichTexture) {
    UpdateGraphics();
    static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false"));
    GFXColorMaterial(AMBIENT|DIFFUSE);
    bool ret=false;
    if (StarStreaks) {
        Matrix rollMatrix;
        static float velstreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_scale","5"));
        static float minstreak= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_min","1"));
        static float fov_smoothing=XMLSupport::parse_float(vs_config->getVariable("graphics","warp.fovlink.smoothing",".4"));
        float fov_smoot = pow(double(fov_smoothing),GetElapsedTime());
        Vector vel (-velocity*velstreakscale);
        float speed = vel.Magnitude();

        if ((smoothstreak>=minstreak||vel.MagnitudeSquared()>=minstreak*minstreak)&&(speed>1.0e-7)) {
            ret=true;
            vel*=1./speed;
            speed = fov_smoot*speed + (1-fov_smoot)*smoothstreak;

            if (speed<minstreak) speed=minstreak;
            static float streakcap  = XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_max","100"));
            if (speed>streakcap) {
                speed=streakcap;
            }
            vel=vel*speed;
            smoothstreak=speed;
            GFXColorVertex * v = vlist->BeginMutate(0)->colors;
            int numvertices = vlist->GetNumVertices();

            static float torquestreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","torque_star_streak_scale","1"));
            for (int j=0; j<numvertices-1; j+=2) {
                int i=j;
//				if (SlowStarStreaks)
//					i=((rand()%numvertices)/2)*2;
                Vector vpoint (v[i+1].x,v[i+1].y,v[i+1].z);
                Vector recenter =(vpoint-center.Cast());
                if (roll) {
                    RotateAxisAngle(rollMatrix,torque,torque.Magnitude()*torquestreakscale*.003);
                    vpoint = Transform(rollMatrix,recenter)+center.Cast();
                }
                v[i].x=vpoint.i-vel.i;
                v[i].y=vpoint.j-vel.j;
                v[i].z=vpoint.k-vel.k;
//				static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05"));
//				if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices)
//					break;
            }
            vlist->EndMutate();
        }
    }
    if (ret) {
        vlist->LoadDrawState();
        vlist->BeginDrawState();
    } else {
        nonstretchvlist->LoadDrawState();
        nonstretchvlist->BeginDrawState();
    }
    return ret;
}
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:59,代码来源:star.cpp

示例15: GetElapsedTime

//Stop Timining
void CStopWatch::Stop()
{
	if(m_bIsRunning)
	{
		m_dElapsedTime += GetElapsedTime();
		m_bIsRunning = false;
	}
}
开发者ID:BGCX261,项目名称:zombie-maul-svn-to-git,代码行数:9,代码来源:CStopWatch.cpp


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