virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo) { switch (event) { case eFE_Activate: { if(IsPortActive(pActInfo, EIP_RecenterPose)) { bool triggered = false; IHMDManager* pHmDManager = gEnv->pSystem->GetHMDManager(); IHMDDevice* pDev = pHmDManager ? pHmDManager->GetHMDDevice() : NULL; if (pDev && pHmDManager->IsStereoSetupOk()) { const HMDTrackingState& sensorState = pDev->GetTrackingState(); if (sensorState.CheckStatusFlags(HS_IsUsable)) { pDev->RecenterPose(); triggered = true; } } ActivateOutput(pActInfo, triggered ? EOP_Triggered : EOP_Failed, true); ActivateOutput(pActInfo, EOP_Done, true); } } break; } }
virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo) { switch (event) { case eFE_Initialize: { if (pActInfo->pGraph != nullptr) { const bool enabled = GetPortBool( pActInfo, EIP_Enabled ); pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, enabled ); } } break; case eFE_Activate: { if (IsPortActive(pActInfo, EIP_Enabled)) { const bool enabled = GetPortBool( pActInfo, EIP_Enabled ); pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, enabled ); } } break; case eFE_Update: { // Camera info IRenderer * pRenderer = gEnv->pRenderer; if (pRenderer) { const CCamera &rCam = pRenderer->GetCamera(); const Ang3 angles = RAD2DEG(rCam.GetAngles()); ActivateOutput(pActInfo, EOP_CamPos, rCam.GetPosition()); ActivateOutput(pActInfo, EOP_CamRot, Vec3(angles)); } ActivateOutput(pActInfo, EOP_CamDataValid, pRenderer != nullptr); // HMD info IHMDManager * pHmdManager = gEnv->pSystem->GetHMDManager(); bool bHmdOk = false; if (pHmdManager != nullptr) { const HMDTrackingState& sensorState = pHmdManager->GetHMDDevice()->GetWorldTrackingState(); if (sensorState.CheckStatusFlags(HS_IsUsable)) { bHmdOk = true; Ang3 hmdAngles(sensorState.pose.orientation); ActivateOutput(pActInfo, EOP_HmdRot, Vec3(RAD2DEG(hmdAngles))); ActivateOutput(pActInfo, EOP_HmdPos, sensorState.pose.position); } } ActivateOutput(pActInfo, EOP_HmdDataValid, bHmdOk); // Player Info CPlayer* pLocalPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor()); if (pLocalPlayer) { Vec3 entityRotationInDegrees(RAD2DEG(Ang3(pLocalPlayer->GetViewQuat()))); ActivateOutput(pActInfo, EOP_PlayerViewRot, entityRotationInDegrees); ActivateOutput(pActInfo, EOP_PlayerPos, pLocalPlayer->GetEntity()->GetWorldPos()); } ActivateOutput(pActInfo, EOP_PlayerDataValid, pLocalPlayer != nullptr); } break; } }