protected virtual void Update()
        {
            // D�but blabla de base de Leap
            if (_workerThreadProfiling)
            {
                LeapProfiling.Update();
            }

            if (!checkConnectionIntegrity())
            {
                return;
            }

#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isCompiling)
            {
                UnityEditor.EditorApplication.isPlaying = false;
                Debug.LogWarning("Unity hot reloading not currently supported. Stopping Editor Playback.");
                return;
            }
#endif

            _fixedOffset.Update(Time.time - Time.fixedTime, Time.deltaTime);

            if (_frameOptimization == FrameOptimizationMode.ReusePhysicsForUpdate)
            {
                DispatchUpdateFrameEvent(_transformedFixedFrame);
                return;
            }

            if (_useInterpolation)
            {
#if !UNITY_ANDROID || UNITY_EDITOR
                _smoothedTrackingLatency.value = Mathf.Min(_smoothedTrackingLatency.value, 30000f);
                _smoothedTrackingLatency.Update((float)(_leapController.Now() - _leapController.FrameTimestamp()), Time.deltaTime);
#endif
                long timestamp = CalculateInterpolationTime() + (ExtrapolationAmount * 1000);
                _unityToLeapOffset = timestamp - (long)(Time.time * S_TO_NS);

                _leapController.GetInterpolatedFrameFromTime(_untransformedUpdateFrame, timestamp, CalculateInterpolationTime() - (BounceAmount * 1000));
            }
            else
            {
                _leapController.Frame(_untransformedUpdateFrame);
            }

            if (_untransformedUpdateFrame != null)
            {
                transformFrame(_untransformedUpdateFrame, _transformedUpdateFrame);

                DispatchUpdateFrameEvent(_transformedUpdateFrame);
            }

            // Fin du blabla de base de Leap. D�but de mon blabla :)
            bool spacePressed = Input.GetKeyDown(KeyCode.Space);
            gatherData(spacePressed, CurrentFrame);

            // Fonction de marc, retournant les json d'une frame  GetFrameData(CurrentFrame);
        }
Example #2
0
        protected virtual void Update()
        {
            if (_workerThreadProfiling)
            {
                LeapProfiling.Update();
            }

            if (!checkConnectionIntegrity())
            {
                return;
            }

#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isCompiling)
            {
                UnityEditor.EditorApplication.isPlaying = false;
                Debug.LogWarning("Unity hot reloading not currently supported. Stopping Editor Playback.");
                return;
            }
#endif

            _fixedOffset.Update(Time.time - Time.fixedTime, Time.deltaTime);

            if (_frameOptimization == FrameOptimizationMode.ReusePhysicsForUpdate)
            {
                DispatchUpdateFrameEvent(_transformedFixedFrame);
                return;
            }

            if (useInterpolation)
            {
#if !UNITY_ANDROID || UNITY_EDITOR
                _smoothedTrackingLatency.value = Mathf.Min(_smoothedTrackingLatency.value, 30000f);
                _smoothedTrackingLatency.Update((float)(_leapController.Now() - _leapController.FrameTimestamp()), Time.deltaTime);
#endif
                long timestamp = CalculateInterpolationTime() + (extrapolationAmount * 1000);
                _unityToLeapOffset = timestamp - (long)(Time.time * S_TO_NS);

                _leapController.GetInterpolatedFrameFromTime(untransformedUpdateFrame,
                                                             timestamp, CalculateInterpolationTime() - (bounceAmount * 1000));
            }
            else
            {
                _leapController.Frame(untransformedUpdateFrame);
            }

            if (untransformedUpdateFrame != null)
            {
                transformFrame(untransformedUpdateFrame, _transformedUpdateFrame);

                DispatchUpdateFrameEvent(_transformedUpdateFrame);
            }
        }
Example #3
0
        protected virtual void Update()
        {
            if (_workerThreadProfiling)
            {
                Debug.Log("hello");
                LeapProfiling.Update();
            }

            if (!checkConnectionIntegrity())
            {
                return;
            }

#if UNITY_EDITOR
            if (UnityEditor.EditorApplication.isCompiling)
            {
                UnityEditor.EditorApplication.isPlaying = false;
                Debug.LogWarning("Unity hot reloading not currently supported. Stopping Editor Playback.");
                return;
            }
#endif

            _fixedOffset.Update(Time.time - Time.fixedTime, Time.deltaTime);

            if (_frameOptimization == FrameOptimizationMode.ReusePhysicsForUpdate)
            {
                DispatchUpdateFrameEvent(_transformedFixedFrame);
                return;
            }

            if (_useInterpolation)
            {
#if !UNITY_ANDROID || UNITY_EDITOR
                _smoothedTrackingLatency.value = Mathf.Min(_smoothedTrackingLatency.value, 30000f);
                _smoothedTrackingLatency.Update((float)(_leapController.Now() - _leapController.FrameTimestamp()), Time.deltaTime);
#endif
                if (capturing)
                {
                    // Timestamp stuff -- actually really important to simulating Frame data.
                    long interpolationTime = CalculateInterpolationTime(); // My own for recording values
                    long timestamp         = CalculateInterpolationTime() + (ExtrapolationAmount * 1000);
                    _unityToLeapOffset = timestamp - (long)(Time.time * S_TO_NS);

                    // Capturing Frames and other necessary values for playback
                    CaptureObjectValues(_untransformedUpdateFrame, _unityToLeapOffset, timestamp, interpolationTime);

                    // Most important part for getting hands to show up
                    _leapController.GetInterpolatedFrameFromTime(_untransformedUpdateFrame, timestamp, CalculateInterpolationTime() - (BounceAmount * 1000));
                }

                else
                {
                    // Recover the serialiazed data
                    recoverObjectData();

                    // Set stuff to make it look the same as above
                    long interpolationtime = recoveredInterpolationTimes[whichFrame];
                    long timestamp         = recoveredTimeStamps[whichFrame];
                    _unityToLeapOffset = recoveredTimeStamps[whichFrame];

                    _untransformedUpdateFrame = recoveredFrames[whichFrame]; // This is important because I think other methods _untransformedUpdateFrame somewhere else
                    _leapController.GetInterpolatedFrameFromTime(_untransformedUpdateFrame, timestamp, interpolationtime - (BounceAmount * 1000));
                }
            }
            else
            {
                _leapController.Frame(_untransformedUpdateFrame);
            }

            if (_untransformedUpdateFrame != null)
            {
                transformFrame(_untransformedUpdateFrame, _transformedUpdateFrame);

                DispatchUpdateFrameEvent(_transformedUpdateFrame);
            }
        }