Example #1
0
	//----------------------------------------------------------------------
	void Shake( SActivationInfo* pActInfo, bool bUpdateOnly )
	{
		IView* pView = GetView( pActInfo );
		if (!pView)
			return;

		int currentFrameId = gEnv->pRenderer->GetFrameID();

		if (!bUpdateOnly && (m_lastShakeFrameID == currentFrameId))
			return;

		SInputParams inputParams;
		ReadCurrentInputParams( pActInfo, inputParams );

		IView::SShakeParams params;

		params.bGroundOnly     = inputParams.groundOnly;
		params.isSmooth        = inputParams.isSmooth;
		params.shakeAngle      = inputParams.angle;
		params.shakeShift      = inputParams.shift;
		params.sustainDuration = inputParams.sustainDuration;
		params.bPermanent      = (params.sustainDuration == -1);
		float freq = inputParams.frequency;
		if (iszero(freq) == false)
			freq = 1.0f / freq;
		params.frequency       = freq;
		params.randomness      = inputParams.randomness;
		params.bFlipVec        = true;        // GetPortBool(pActInfo, EIP_Flip);
		params.bUpdateOnly     = bUpdateOnly; // it's an update if and only if Frequency has been changed
		params.fadeInDuration  = inputParams.fadeInDuration;
		params.fadeOutDuration = inputParams.fadeOutDuration;
		params.shakeID         = FLOWGRAPH_SHAKE_ID;

		float    distance    = inputParams.distance;
		IEntity* pEntityNode = pActInfo->pEntity;
		if (pEntityNode)
		{
			distance = pView->GetCurrentParams()->position.GetDistance( pEntityNode->GetWorldPos());
		}

		const float rangeMin = inputParams.rangeMin;
		const float rangeMax = inputParams.rangeMax;
		float       amount   = min(1.f, max(0.f, (rangeMax - distance) / (rangeMax - rangeMin)));

		params.shakeAngle *= amount;
		params.shakeShift *= amount;

		pView->SetViewShakeEx( params );

		m_lastShakeFrameID = currentFrameId;
	}
Example #2
0
void CCameraView::Reset()
{
	//initialize the camera view
	IViewSystem *pViewSystem = g_pGame->GetIGameFramework()->GetIViewSystem();
	IView *pView = pViewSystem->GetActiveView();
	CRY_ASSERT(pView);
	m_lastViewParams = *(pView->GetCurrentParams());

	//the player can still change camera angles etc.
	CPlayer *pHero = CPlayer::GetHero();
	CRY_ASSERT(pHero);


	m_pCamHelper = pHero->GetCameraInputHelper();
	CRY_ASSERT(m_pCamHelper);

	m_bModeTransition = false;
	m_fTransitionTimeout = 0.0f;

	m_curPolar.SetPitch(1.f);
}