Exemple #1
0
 void OnPreRender()
 {
     if (imagesEnabled)
     {
         LeapWebSocketController controller = _provider.GetLeapController();
         long start = controller.Now();
         while (!_requestedImage.IsComplete)
         {
             if (controller.Now() - start > ImageTimeout)
             {
                 break;
             }
         }
         if (_requestedImage.IsComplete)
         {
             if (_eyeTextureData.CheckStale(_requestedImage, _requestedImage))
             {
                 _eyeTextureData.Reconstruct(_requestedImage, _requestedImage);
             }
             _eyeTextureData.UpdateTextures(_requestedImage, _requestedImage);
         }
         else if (!checkingImageState)
         {
             StartCoroutine(checkImageMode());
         }
     }
 }
Exemple #2
0
        void OnDestroy()
        {
            StopAllCoroutines();
            LeapWebSocketController controller = _provider.GetLeapController();

            if (controller != null)
            {
                _provider.GetLeapController().DistortionChange -= onDistortionChange;
            }
        }
Exemple #3
0
        private IEnumerator waitForController()
        {
            LeapWebSocketController controller = null;

            do
            {
                controller = _provider.GetLeapController();
                yield return(null);
            } while (controller == null);
            onController(controller);
        }
Exemple #4
0
 /** Calling this method stop the connection for the existing instance of a Controller,
  * clears old policy flags and resets to null */
 protected void destroyController()
 {
     if (webController != null)
     {
         if (webController.IsConnected)
         {
             webController.ClearPolicy(Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
         }
         webController.StopConnection();
         webController = null;
     }
 }
Exemple #5
0
 private void onController(LeapWebSocketController controller)
 {
     controller.DistortionChange += onDistortionChange;
     //controller.Connect += delegate {
     //  _provider.GetLeapController().Config.Get("images_mode", (Int32 enabled) => {
     //    this.imagesEnabled = enabled == 0 ? false : true;
     //  });
     //};
     if (!checkingImageState)
     {
         StartCoroutine(checkImageMode());
     }
 }
Exemple #6
0
 void Update()
 {
     if (imagesEnabled)
     {
         Frame imageFrame = _provider.CurrentFrame;
         LeapWebSocketController controller = _provider.GetLeapController();
         // _requestedImage = controller.RequestImages(imageFrame.Id, Image.ImageType.DEFAULT);
     }
     else if (!checkingImageState)
     {
         StartCoroutine(checkImageMode());
     }
 }
Exemple #7
0
        void OnDisable()
        {
            StopAllCoroutines();
            LeapWebSocketController controller = _provider.GetLeapController();

            if (controller != null)
            {
                _provider.GetLeapController().DistortionChange -= onDistortionChange;
            }

            LeapVRCameraControl.OnLeftPreRender  -= ApplyCameraProjectionValues;
            LeapVRCameraControl.OnRightPreRender -= ApplyCameraProjectionValues;
        }
Exemple #8
0
        void OnEnable()
        {
            LeapWebSocketController controller = _provider.GetLeapController();

            if (controller != null)
            {
                onController(controller);
            }
            else
            {
                StartCoroutine(waitForController());
            }

            LeapVRCameraControl.OnLeftPreRender  += ApplyCameraProjectionValues;
            LeapVRCameraControl.OnRightPreRender += ApplyCameraProjectionValues;
        }
Exemple #9
0
        /** Create an instance of a Controller, initialize its policy flags
         * and subscribe to connection event */
        protected void createController()
        {
            if (webController != null)
            {
                destroyController();
            }
            webController = FindObjectOfType <LeapWebSocketController>();

            if (webController.IsConnected)
            {
                initializeFlags();
            }
            else
            {
                webController.Device += onHandControllerConnect;
            }
        }
 protected void Start()
 {
     if (provider.IsConnected())
     {
         deviceInfo = provider.GetDeviceInfo();
         LeapVRCameraControl.OnValidCameraParams += onValidCameraParams;
         if (deviceInfo.type == LeapDeviceType.Invalid)
         {
             Debug.LogWarning("Invalid Leap Device -> enabled = false");
             enabled = false;
             return;
         }
     }
     else
     {
         StartCoroutine(waitForConnection());
         LeapWebSocketController controller = provider.GetLeapController();
         //controller.Device += OnDevice;
     }
 }