/// <summary> /// Play animation track related to the current calibration stage /// </summary> /// <param name="calibrationStage"></param> public override void PlayAnimation(CalibrationStage calibrationStage) { switch (calibrationStage) { case CalibrationStage.Mapping: // removed cycle so animation is not going to wait for the user //_animator.SetTrigger("Cycle"); break; case CalibrationStage.Remapping: _animator.Play("ThreeDots"); break; case CalibrationStage.HoldStill: _animator.SetTrigger("HoldStill"); break; case CalibrationStage.WaitingForSensors: // TODO animation for waiting for sensors stage break; case CalibrationStage.Completed: _animator.SetTrigger("GreenCheck"); break; case CalibrationStage.Fail: // TODO animation for fail stage break; default: throw new Exception("Calibration stage not implemented: " + calibrationStage); } }
private IEnumerator FailState() { StopCoroutine(_mainCoroutine); _currentCalibrationStage = CalibrationStage.Fail; _localizer.onSlamInitializationFailed.Invoke(); yield return(StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage))); metaContext.Get <MetaLocalization>().ResetLocalization(); }
private IEnumerator TrackCalibrationSteps(SlamInitializationType initializationType) { // waiting for the sensors while (!_sensorsReady) { yield return(null); } // shows a message in case the user doesn't move in the beggining _currentCalibrationStage = CalibrationStage.WaitingForTracking; StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage)); if (initializationType == SlamInitializationType.NewMap) { _currentCalibrationStage = CalibrationStage.Mapping; // start timeout countdown StartCoroutine(TimeOutCalibrationFail(SlamFailTimeOut)); } else { _headOrientation.gameObject.SetActive(false); _currentCalibrationStage = CalibrationStage.Remapping; } // show start message StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage)); int currentStep = 0; while (true) { float coverage = _coverageAngle; if (_calibrationSteps[currentStep] == CalibrationStep.RotateFurtherLeft || _calibrationSteps[currentStep] == CalibrationStep.RotateFurtherRight) { coverage *= _furtherAngleIncrease; } float angle; // TODO change logic to consider _initialYOrientation after compositor implements different origin if (_centerEye.rotation.eulerAngles.y > 180) { angle = Mathf.Clamp(_centerEye.rotation.eulerAngles.y - 360, -coverage, coverage); } else { angle = Mathf.Clamp(_centerEye.rotation.eulerAngles.y, -coverage, coverage); } _headOrientation.Rotation = (coverage - angle) / (coverage * 2); // if calibration happens at any point if (DetectCalibratedStage()) { _currentCalibrationStage = CalibrationStage.Completed; yield return(StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage))); } // if hold still stage is detected at any point else if (DetectHoldStillStage() && _currentCalibrationStage != CalibrationStage.HoldStill) { _currentCalibrationStage = CalibrationStage.HoldStill; _headOrientation.gameObject.SetActive(false); StartCoroutine(TimeOutCalibrationFail(SlamHoldStillMaxTime)); StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage)); } // if goal for the current step is achieved else if (ApproximatelyWithThreshold(_calibrationStepAngle[_calibrationSteps[currentStep]], ConvertToPositiveAngle(_centerEye.rotation.eulerAngles.y))) { if (currentStep + 1 < _calibrationSteps.Length) { currentStep++; StartCoroutine(_slamUI.ChangeUIStage(_currentCalibrationStage)); } // steps finished else { // if not initialized then fail StartCoroutine(FailState()); } } yield return(null); } }
/// <summary> /// Play animation track related to the current calibration stage /// </summary> /// <param name="calibrationStage"></param> public abstract void PlayAnimation(CalibrationStage calibrationStage);
/// <summary> /// Change the current UI stage based on the calibration process /// </summary> /// <param name="calibrationStage"></param> /// <returns></returns> public override IEnumerator ChangeUIStage(CalibrationStage calibrationStage) { MetaCompositor compositor = null; switch (calibrationStage) { case CalibrationStage.WaitingForSensors: compositor = FindObjectOfType <MetaCompositor>(); if (compositor && compositor.OcclusionEnabledAtStart) { compositor.EnableHandOcclusion = false; } _slamUIMessages.CurrentMessage = SLAMUIMessageType.WaitingForSensors; _slamAnimation.PlayAnimation(calibrationStage); break; case CalibrationStage.Mapping: // if is already running the animation if (_slamUIMessages.CurrentMessage == SLAMUIMessageType.TurnAround) { _slamAnimation.PlayAnimation(calibrationStage); } // if it is the first time else { _slamUIMessages.CurrentMessage = SLAMUIMessageType.TurnAround; _slamAnimation.StartAnimation(); } break; case CalibrationStage.Completed: _slamUIMessages.CurrentMessage = SLAMUIMessageType.MappingSuccess; _slamAnimation.PlayAnimation(CalibrationStage.Completed); yield return(new WaitForSeconds(_delayBetweenMessages)); // fades out _slamUIMessages.CurrentMessage = SLAMUIMessageType.None; _slamAnimation.StopAnimation(); compositor = FindObjectOfType <MetaCompositor>(); if (compositor && compositor.OcclusionEnabledAtStart) { compositor.EnableHandOcclusion = true; } yield return(new WaitForSeconds(_delayBetweenMessages)); Destroy(gameObject); break; case CalibrationStage.HoldStill: _slamUIMessages.CurrentMessage = SLAMUIMessageType.HoldStill; _slamAnimation.PlayAnimation(calibrationStage); break; case CalibrationStage.Fail: _slamUIMessages.CurrentMessage = SLAMUIMessageType.MappingFail; yield return(new WaitForSeconds(_delayBetweenMessages)); break; case CalibrationStage.WaitingForTracking: _slamUIMessages.CurrentMessage = SLAMUIMessageType.WaitingForTracking; break; case CalibrationStage.Remapping: _slamUIMessages.CurrentMessage = SLAMUIMessageType.Relocalization; _slamAnimation.PlayAnimation(calibrationStage); break; default: throw new Exception("Calibration stage not implemented: " + calibrationStage); } }
/// <summary> /// Change the current UI stage based on the calibration process /// </summary> /// <param name="calibrationStage"></param> /// <returns></returns> public abstract IEnumerator ChangeUIStage(CalibrationStage calibrationStage);