Exemplo n.º 1
0
    /**
     * Helper function for calibration setup.
     * This will perform the following procedures
     *
     *    1) Initialize eye tracking calibration
     *    2) Ensure Vive Tracker for Headset and Vive Controllers are connected
     *    3) Prompt to calibrate FOVE headset to Vive space (Press H)
     *    4) Load initial scene (Scene_000) if everything is completed
     */
    private void RunCalibrationSetup()
    {
        if (eyeTrackerCalibrationStarted == false)
        {
            FoveInterface.EnsureEyeTrackingCalibration();
            eyeTrackerCalibrationStarted = true;
        }

        if (RenderSettings.skybox != defaultSkyboxMaterial)
        {
            RenderSettings.skybox = defaultSkyboxMaterial;
        }

        bool eyeTrackerCalibrated        = (!FoveInterface.IsEyeTrackingCalibrating() && FoveInterface.IsEyeTrackingCalibrated());
        bool headsetCalibrated           = headsetLocalizationInstance.IsHeadsetCalibrated();
        bool viveTrackerHeadsetConnected = headsetLocalizationInstance.IsHeadsetPositionTracked();
        bool controllersConnected        = headsetLocalizationInstance.IsControllersConnected();

        string uiPromptMessage = "";

        if (viveTrackerHeadsetConnected == false)
        {
            uiPromptMessage += "Please turn on Vive Tracker for headset.\n";
        }
        if (controllersConnected == false)
        {
            uiPromptMessage += "Please connect both Vive controllers.\n";
        }
        if (eyeTrackerCalibrated == false)
        {
            uiPromptMessage += "Please calibrate eye tracking.\n";
        }
        if (headsetCalibrated == false)
        {
            uiPromptMessage += "Please calibrate headset and vive to world space [H]\n";
        }
        uiPrompt.SetUiPromptMessage(uiPromptMessage);
        uiPrompt.TurnOnUiPrompt();

        if (eyeTrackerCalibrated && headsetCalibrated)
        {
            systemCalibrated = true;
            uiPrompt.TurnOffUiPrompt();

            // Initialize a new scene
            headsetLocalizationInstance.ReCenterUser();
            eyeTrackerInstance.CreateNewScene(GenerateSceneName(currentSceneNumber));
            SceneManager.LoadSceneAsync(GenerateSceneName(currentSceneNumber), LoadSceneMode.Additive);
            ChangeSkybox(currentSceneNumber);
            currentSceneState = SCENE_CHANGE_STATE.Changing;
        }
    }