Esempio n. 1
0
    void	cFMTimeLineAnimationRule::Update(float e_fElpaseTime)
    {
		if( !m_bInitCalled )
			return;
		if( m_iCurrentPlayCount == this->m_iPlayCount)
		{
			m_fCurrentProgress = 1.f;
		    return;
		}
	    m_fPastTime += e_fElpaseTime;
		float	l_fEndTime = this->GetEndTime();
		if( m_fPastTime >= l_fEndTime )
		{
			//seems use m_iCurrentPlayCount += m_fPastTime/l_fEndTime; is better but I do care.
			m_iCurrentPlayCount++;
			if( m_iCurrentPlayCount  != m_iPlayCount )
			{
				int l_iCurrentPlayTime = m_iCurrentPlayCount+1;
				m_fPastTime = GetFloatModulus(m_fPastTime,m_fTotalPlayTime);
				e_fElpaseTime = m_fPastTime;
				this->Init();
				m_iCurrentPlayCount = l_iCurrentPlayTime;
			}
			else
			{
				if( m_bStayAtLastFrame )
				{
					float l_fRestTime = m_fPastTime - e_fElpaseTime;
					l_fRestTime = l_fEndTime - m_fPastTime;
					InternalUpdate(l_fRestTime);
					//m_fPastTime += e_fElpaseTime;
					//if(m_fCurrentProgress != 1.f)
					//{
					//	this->Init();
					//	InternalUpdate(m_fPastTime-m_fStartTime);
					//	InternalUpdate(l_fEndTime);
					//}
				}
				m_fCurrentProgress = 1.f;
			}
		}
		if( !this->IsAnimationDone() )
		{
			if( !m_bStart )
			{
				if(m_fPastTime>m_fStartTime)
				{
					m_bStart = true;
					InternalUpdate(m_fPastTime-m_fStartTime);
				}
			}
			else
			{
				InternalUpdate(e_fElpaseTime);
			}
			m_fCurrentProgress = this->m_fPastTime/this->m_fTotalPlayTime;
		}
    }
Esempio n. 2
0
void Point ( int iID, float fX, float fY, float fZ )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	/* LEEFIX - 041002 - LOOK not tied to rotation of object
	// point an object in a direction
	m_pPos->vecLook.x = fX - m_pPos->vecPosition.x;
	m_pPos->vecLook.y = fY - m_pPos->vecPosition.y;
	m_pPos->vecLook.z = fZ - m_pPos->vecPosition.z;
	D3DXVec3Normalize(&m_pPos->vecLook,&m_pPos->vecLook);
	// set the new look direction
	m_pPos->vecLook = D3DXVECTOR3 ( fX, fY, fZ );
	*/

	// rotation from xyz diff
	GetAngleFromPoint ( m_pPos->vecPosition.x, m_pPos->vecPosition.y, m_pPos->vecPosition.z,
						fX, fY, fZ, &m_pPos->vecRotate.x, &m_pPos->vecRotate.y, &m_pPos->vecRotate.z);

	// apply the changes
	InternalUpdate ( iID );
}
Esempio n. 3
0
void Game::Run(void) {

	InternalInitialize();
	Initialize();

	running = true;

	while (running) {
		currentTicks = SDL_GetTicks();

		this->input->Update();

		if(this->input->GetKey(SDL_SCANCODE_ESCAPE)) {
			running = false;
		}

		InternalUpdate(currentTicks - lastTicks);
		Update(currentTicks - lastTicks);

		InternalRender();
//		Render();
        renderer->Present();

		lastTicks = currentTicks;
		fpsCount++;
	}

	Shutdown();
}
Esempio n. 4
0
	int			Atom::Run()
	{
		MSG		msg = {0};

		m_msPerFrame = 1.0f / g_settings.frameRate;
		m_timer.Reset();

		ATOM_LOG("[info]: framerate: %d, ms per frame: %.4f\n", g_settings.frameRate, m_msPerFrame);

		while (msg.message != WM_QUIT)
		{
			if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else
			{
				m_timer.Tick();
				m_deltaTime += m_timer.GetElapsedTime();
				if (m_deltaTime >= m_msPerFrame)
				{
					InternalUpdate(m_deltaTime);
					Update(m_deltaTime);
					Draw();
					m_deltaTime = 0.0f;
				}
			}
		}
		return (int)msg.wParam;
	}
Esempio n. 5
0
void Scale ( int iID, float fX, float fY, float fZ )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	// scale an object by the specified scale values

	// set the new values
	m_pPos->vecScale = D3DXVECTOR3 ( fX/100.0f, fY/100.0f, fZ/100.0f );

	// update for clipping
	GetCullDataFromModel ( iID );

	// apply the changes
	InternalUpdate ( iID );
}
Esempio n. 6
0
void Move ( int iID, float fStep )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	// moves an object forward in it's current direction

	// update internal data
	if ( !UpdatePtr ( iID ) )
		return;
	
	// update the position vector
//	m_pPos->vecPosition -= ( fStep * m_pPos->vecLook );
//	m_pPos->vecPosition -= ( 0.1f * m_pPos->vecLook );

	// mike : Always move INTO the Z
	m_pPos->vecPosition += ( fStep * m_pPos->vecLook );
	m_pPos->bHasBeenMovedForResponse=true;

	// apply changes
	InternalUpdate ( iID );
}
void
InputDevice::Update(InputDeltaState* delta)
{
	*previousState_ = *state_;
#if defined(GAINPUT_DEV)
	if (synced_)
	{
		return;
	}
#endif
	InternalUpdate(delta);
}
Esempio n. 8
0
STFResult PhysicalUnit::InternalCompleteConfigure(void)
	{
	configureCounter--;

	if (configureCounter == 0)
		{
		STFRES_REASSERT(InternalUpdate());
		changeSet = 0;
		}

	STFRES_RAISE_OK;
	}
Esempio n. 9
0
void Position ( int iID, float fX, float fY, float fZ )
{
	// set the position of an object

	// update internal data
	if ( !UpdatePtr ( iID ) )
		return;

	// set the new position
	m_pPos->vecPosition = D3DXVECTOR3 ( fX, fY, fZ );
	m_pPos->bHasBeenMovedForResponse=true;

	// apply the changes
	InternalUpdate ( iID );
}
Esempio n. 10
0
    void Sound::Update() {
        // Fade the Gain update to avoid "ticking" sounds when there is a gain discontinuity
        float targetGain = positionalGain * soundGain * SliderToAmplitude(effectsVolume.Get());

        //TODO make it framerate independant and fade out in about 1/8 seconds ?
        if (currentGain > targetGain) {
            currentGain = std::max(currentGain - 0.02f, targetGain);
            //currentGain = std::max(currentGain * 1.05f, targetGain);
        } else if (currentGain < targetGain) {
            currentGain = std::min(currentGain + 0.02f, targetGain);
            //currentGain = std::min(currentGain / 1.05f - 0.01f, targetGain);
        }

        source->SetGain(currentGain);

        InternalUpdate();
    }
Esempio n. 11
0
void RollRight ( int iID, float fAngle )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	m_pPos->vecYawPitchRoll.z += fAngle;
	m_pPos->bFreeFlightRotation = true;

	InternalUpdate ( iID );
}
Esempio n. 12
0
void MoveDown ( int iID, float fStep )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	m_pPos->vecPosition -= ( fStep * m_pPos->vecUp );
	m_pPos->bHasBeenMovedForResponse=true;

	InternalUpdate ( iID );
}
Esempio n. 13
0
	CErrno NetThread::Update( void )
	{
		if (!m_bInitFirst)
		{
			m_bInitFirst = TRUE;
			Init(m_objInitConf);
		}

		if (m_pNetReactor && m_pNetReactor->GetReactorType() == REACTOR_TYPE_EPOLLEX)
		{
#ifdef _LINUX
			co_eventloop(co_get_epoll_ct(), InternalUpdate, this);
#endif
		}
		else
		{
			InternalUpdate(this);
		}

		return CErrno::Success();
	}
Esempio n. 14
0
void ZRotate ( int iID, float fZ )
{
	// update internal data
	if ( iID < 1 || iID > MAXIMUMVALUE )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNUMBERILLEGAL);
		return;
	}
	if ( !UpdatePtr ( iID ) )
	{
		RunTimeError(RUNTIMEERROR_B3DMODELNOTEXISTS);
		return;
	}

	// rotate an object around it's z axis

	// store the new rotation values
	m_pPos->vecRotate = D3DXVECTOR3 ( m_pPos->vecRotate.x, m_pPos->vecRotate.y, fZ );
	m_pPos->bFreeFlightRotation = false;

	// apply the changes
	InternalUpdate ( iID );
}
Esempio n. 15
0
void Value::Update()
{
    if (HasChanged()) {
        InternalUpdate();
    }
}
Esempio n. 16
0
void BaseGameApp::OnUpdate(float delta)
{
	InternalUpdate();
}
Esempio n. 17
0
void BaseGameApp::Loop()
{
	LOG_INFO(LOGCAT_GAMEAPP, "OnLoadGame event.\n");
	m_content->OnLoadGame();
	OnLoadGame();

	LOG_INFO(LOGCAT_GAMEAPP, "Main loop started.\n");

	uint numUpdatesThisFrame;
	uint numLoops = 0;
	uint timeElapsed = 0;

	uint updateTime = 0;
	uint renderTime = 0;

	m_nextUpdateAt = GetTicks();
	uint currentTime = GetTicks();

	while (!m_stop)
	{
		if (m_isPaused)
		{
			// make sure we *always* do our own internal processing all the time
			// that this loop is being executed. this makes sure OS events are
			// being processed.
			// NOTE: the underlying framework may or may not keep this loop running
			// when the app has been paused however.
			InternalUpdate();
		}
		else
		{
			uint newTime = GetTicks();
			uint frameTime = newTime - currentTime;
			currentTime = newTime;
			timeElapsed += frameTime;

			// Every second, recalculate the FPS
			if (timeElapsed >= 1000)
			{
				m_fps = numLoops;
				m_frameTime = 1000.0f / m_fps;

				m_rendersPerSecond = m_numRenders;
				m_updatesPerSecond = m_numUpdates;
				m_renderTime = renderTime;
				m_updateTime = updateTime;

				m_numUpdates = 0;
				m_numRenders = 0;
				renderTime = 0;
				updateTime = 0;

				numLoops = 0;
				timeElapsed = 0;
			}

			// we're "running slowly" if we're more than one update behind
			if (currentTime > m_nextUpdateAt + m_ticksPerUpdate)
				m_isRunningSlowly = true;
			else
				m_isRunningSlowly = false;

			numUpdatesThisFrame = 0;
			while (GetTicks() >= m_nextUpdateAt && numUpdatesThisFrame < m_maxFrameSkip)
			{
				if (numUpdatesThisFrame > 0)
					m_isRunningSlowly = true;

				uint before = GetTicks();
				OnUpdate(m_fixedUpdateInterval);
				updateTime += GetTicks() - before;

				++numUpdatesThisFrame;
				m_nextUpdateAt += m_ticksPerUpdate;

				++m_numUpdates;

				// just updated, so we need to render the new game state
				m_isDirty = true;
			}

			if (m_isDirty && m_window->IsActive() && m_window->HasGLContext())
			{
				uint before = GetTicks();
				OnRender();
				m_window->Flip();
				renderTime += GetTicks() - before;

				++m_numRenders;

				// don't render again until we have something new to show
				m_isDirty = false;
			}

			++numLoops;
		}
	}

	LOG_INFO(LOGCAT_GAMEAPP, "Main loop exiting.\n");
}