示例#1
0
	virtual void ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
		{
			CreateView();
			return;
		}
		break;
		case eFE_Activate:
		{
			if (IsPortActive(pActInfo, EIP_Enable))
			{
				if (m_pView == NULL)
					CreateView();

				if (m_pView == NULL)
					return;

				if (pActInfo->pEntity == NULL)
					return;

				SViewParams params;

				params.justActivated  = true;
				params.fov            = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				params.blend          = GetPortBool(pActInfo, EIP_Blend);
				params.blendFOVOffset = DEG2RAD(GetPortFloat(pActInfo, EIP_BlendFOVOffset));
				params.blendFOVSpeed  = GetPortFloat(pActInfo, EIP_BlendFOVSpeed);
				params.blendPosOffset = GetPortVec3(pActInfo, EIP_BlendPosOffset);
				params.blendPosSpeed  = GetPortFloat(pActInfo, EIP_BlendPosSpeed);
				params.blendRotSpeed  = GetPortFloat(pActInfo, EIP_BlendRotSpeed);
				params.blendRotOffset = Quat::CreateRotationXYZ(static_cast<Ang3>(GetPortVec3(pActInfo, EIP_BlendRotOffset)));

				m_pView->SetCurrentParams(params);
				m_pView->LinkTo(pActInfo->pEntity);

				m_pViewSystem->SetActiveView(m_pView);
			}
			else if (IsPortActive(pActInfo, EIP_Disable))
			{
				if (m_pLocalPlayerView)
					m_pViewSystem->SetActiveView(m_pLocalPlayerView);
			}
			else if (IsPortActive(pActInfo, EIP_FOV))
			{
				SViewParams params;
				params.fov = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				m_pView->SetCurrentParams(params);
			}
		}
		break;
		}
	}
示例#2
0
	void CreateView()
	{
		if (gEnv->pGame == NULL)
			return;

		IGameFramework* pGF = gEnv->pGame->GetIGameFramework();

		if (pGF == NULL)
			return;

		m_pViewSystem = pGF->GetIViewSystem();

		if (m_pViewSystem == NULL)
			return;
		//if the game has a clientactor, cache the view
		if (pGF->GetClientActor())
		{
			m_pLocalPlayerView = m_pViewSystem->GetViewByEntityId(pGF->GetClientActor()->GetEntityId());
		}



		if (m_pLocalPlayerView && (m_pViewSystem->GetActiveView() != m_pLocalPlayerView))
			m_pViewSystem->SetActiveView(m_pLocalPlayerView);

		if (m_pView == NULL)
			m_pView = m_pViewSystem->CreateView();
	}