예제 #1
0
void CCinematicInput::UpdateAdditiveCameraInput( IScriptSystem* pScriptSystem, float frameTime )
{
	CCinematicInput::SUpdateContext updateCtx;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", updateCtx.m_lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", updateCtx.m_lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", updateCtx.m_lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", updateCtx.m_lookRightLimit);
	float recenterCamera = 0.0f;
	pScriptSystem->GetGlobalValue("Cinematic_CameraDoNotCenter", recenterCamera);

	updateCtx.m_lookUpLimit = DEG2RAD(updateCtx.m_lookUpLimit);
	updateCtx.m_lookDownLimit = DEG2RAD(updateCtx.m_lookDownLimit);
	updateCtx.m_lookLeftLimit = DEG2RAD(updateCtx.m_lookLeftLimit);
	updateCtx.m_lookRightLimit = DEG2RAD(updateCtx.m_lookRightLimit);
	updateCtx.m_recenter = (recenterCamera < 0.01f);

	updateCtx.m_frameTime = frameTime;

	CActor* pClientActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetClientActor());
	if (pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer* pClientPlayer = static_cast<CPlayer*>(pClientActor);

		IPlayerInput* pIPlayerInput = pClientPlayer->GetPlayerInput();
		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput * pPlayerInput = static_cast<CPlayerInput*>(pIPlayerInput);

			Ang3 frameAccumulatedAngles(0.0f, 0.0f, 0.0f);

#if CINEMATIC_INPUT_PC_MOUSE
			const bool isAimingWithMouse = pPlayerInput->IsAimingWithMouse();

			RefreshInputMethod(isAimingWithMouse);

			if (isAimingWithMouse)
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithMouse(updateCtx, pPlayerInput->GetRawMouseInput());
			}
			else
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
			}
#else
			frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
#endif

			IView* pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();
			if (pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(frameAccumulatedAngles);
			}
		}
	}
}
예제 #2
0
void CCinematicInput::UpdateAdditiveCameraInput(IScriptSystem *pScriptSystem, float frameTime)
{
	float lookUpLimit = 0.0f, lookDownLimit = 0.0f;
	float lookLeftLimit = 0.0f, lookRightLimit = 0.0f;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", lookRightLimit);

	lookUpLimit = DEG2RAD(lookUpLimit);
	lookDownLimit = DEG2RAD(lookDownLimit);
	lookLeftLimit = DEG2RAD(lookLeftLimit);
	lookRightLimit = DEG2RAD(lookRightLimit);

	CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());

	if(pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer *pClientPlayer = static_cast<CPlayer *>(pClientActor);

		IPlayerInput *pIPlayerInput = pClientPlayer->GetPlayerInput();

		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput *pPlayerInput = static_cast<CPlayerInput *>(pIPlayerInput);

			Ang3 rawMouseInput = pPlayerInput->GetRawMouseInput() * 0.25f;
			rawMouseInput.z = - rawMouseInput.z;
			rawMouseInput.x *= (g_pGameCVars->cl_invertMouse == 0) ? 1.0f : -1.0f;

			Ang3 rawControllerInput = pPlayerInput->GetRawControllerInput() + rawMouseInput;
			//Yaw angle (Z axis)
			rawControllerInput.z = -clamp((float)__fsel(rawControllerInput.z, rawControllerInput.z * lookRightLimit, rawControllerInput.z * lookLeftLimit), -lookLeftLimit, lookRightLimit);
			//Pitch angle (X axis)
			rawControllerInput.x *= (g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f;
			rawControllerInput.x = clamp((float)__fsel(rawControllerInput.x, rawControllerInput.x * lookUpLimit, rawControllerInput.x * lookDownLimit), -lookDownLimit, lookUpLimit);
			//No roll allowed
			rawControllerInput.y = 0.0f;

			Interpolate(m_currentRawInputAngles, rawControllerInput, 2.5f, frameTime);

			IView *pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();

			if(pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(m_currentRawInputAngles);
			}
		}
	}
}