Пример #1
0
 private void ShowSelectedScene()
 {
     SetDefaultSceneSettings();
     DestroyCurrentScene();
     currentScene = Instantiate(scenes[currentSceneIdx] as UnityEngine.Object, Vector3.zero, Quaternion.identity) as GameObject;
     currentScene.SetActive(true);
     logger.DebugLog("Enabling scene " + currentScene.name);
 }
 /**
  * Sets the current virtual distance to accomodate to in meters.
  *
  * Updates are throttled temporally by {minTimeBetweenUpdatesSecs}
  * and physically by {minDistanceBetweenUpdatesPercentDiopters}.
  *
  * The {perceptualSmoothingAlpha} param can be set between 0 and 1 and enables
  * driving the display to the target virtual distance over multiple updates
  * spaced out by {minTimeBetweenUpdatesSecs} according to the following formula:
  *	 currentVirtualDistanceDiopters = alpha * targetVirtualDistanceDiopters + (1 - alpha) * currentVirtualDistanceDiopters
  * This continues until convergence and can prevent sudden large movements of the display.
  * To disable perceptual smoothing, set perceptualSmoothingAlpha=-1.
  */
 public void AccommodateVirtualDistance(float virtualDistanceMeters, float perceptualSmoothingAlpha = -1)
 {
     if (virtualDistanceMeters != currentDistanceMeters)
     {
         logger.DebugLog("Setting virtual distance=" + virtualDistanceMeters + " meters, perceptual smoothing alpha=" + perceptualSmoothingAlpha + "");
     }
     currentDistanceMeters      = virtualDistanceMeters;
     currentPerceptualSmoothing = perceptualSmoothingAlpha;
 }
Пример #3
0
    public void CalibrateCurrent()
    {
        logger.DebugLog("Starting calibration for distance (meters): " + calibrationDistancesMeters [currentCalibrationIdx]);
        displayAccomodationManager.AccommodateVirtualDistance(calibrationDistancesMeters [currentCalibrationIdx]);

                #if UNITY_EDITOR
        OnCalibrationResult(0);
                #else
        SMI.SMIEyeTrackingMobile.Instance.smi_StartFivePointCalibration();
                #endif
    }
Пример #4
0
    private void OnApplicationFocusChange(bool isPaused)
    {
        if (!Connected)
        {
            return;
        }

        if (isPaused)
        {
            logger.DebugLog("Application paused. Disengaging motor.");
            bluetoothPeripheralManager.SendInt16LE(MotorControlSignals.DisengageStepper);
            bluetoothPeripheralManager.SendInt16LE(MotorControlSignals.DisengageStepper);
        }
        else
        {
            logger.DebugLog("Application resumed. Re-engaging motor.");
            bluetoothPeripheralManager.SendInt16LE(MotorControlSignals.EngageStepper);
        }
    }
 public void SetEyeCalibration(float virtualDistanceMeters)
 {
     if (calibrations.Count != 0)
     {
         Calibration closestCalibration = GetClosestCalibration(virtualDistanceMeters);
         if (currentCalibration == null || currentCalibration.name != closestCalibration.name)
         {
             currentCalibration = closestCalibration;
             logger.DebugLog("Loading eye calibration: scene distance=" + virtualDistanceMeters + ", calibration distance=" + closestCalibration.distance);
                             #if !UNITY_EDITOR
             SMI.SMIEyeTrackingMobile.Instance.smi_LoadCalibration(closestCalibration.name);
                             #endif
         }
     }
 }
    public void ConnectTo(BluetoothPeripheralParams newPeripheralParams)
    {
        if (_peripheralParams.HasValue && newPeripheralParams.Equals(_peripheralParams.Value))
        {
            logger.Warning("Already connected to this peripheral: " + newPeripheralParams);
            return;
        }

                #if UNITY_EDITOR
        _state     = States.None;
        _connected = true;
        if (OnConnect != null)
        {
            OnConnect();
        }
        return;
                #endif

        ResetState(() => {
            _peripheralParams = newPeripheralParams;
            BluetoothLEHardwareInterface.Initialize(true, false, () => {
                logger.DebugLog("Initialized bluetooth hardware interface.");
                SetState(States.Scan, 0.1f);
            }, (error) => {
                logger.Error("Error initializing bluetooth hardware interface: " + error);
            });
        });
    }