Пример #1
0
        // Use this for initialization
        void Start()
        {
            //Application.targetFrameRate = 60;
            if (isLocalPlayer)
            {
                switch (frameEncodingType)
                {
                case FrameEncodingEnum.VectorHand:
                    playerState = new VectorFrameEncoding();
                    break;

                case FrameEncodingEnum.CurlHand:
                    playerState = new CurlFrameEncoding();
                    break;

                default:
                    playerState = new VectorFrameEncoding();
                    break;
                }
                //LeapDataProvider = HandController.gameObject.AddComponent<LeapServiceProvider>();
                leapDataProvider = handController.gameObject.AddComponent <LeapXRServiceProvider>();
                //ENABLE THESE AGAIN ONCE THE SERVICE HAS THESE EXPOSED SOMEHOW
                //LeapDataProvider._temporalWarping = HandController.parent.GetComponent<LeapVRTemporalWarping>();
                //LeapDataProvider._temporalWarping.provider = LeapDataProvider;
                //LeapDataProvider._isHeadMounted = true;
                //LeapDataProvider.UpdateHandInPrecull = true;
            }
            else
            {
                networkDataProvider = handController.gameObject.AddComponent <LeapStreamingProvider>();
                //Destroy(handController.parent.GetComponent<LeapXRTemporalWarping>());
                switch (frameEncodingType)
                {
                case FrameEncodingEnum.VectorHand:
                    playerState = new VectorFrameEncoding();
                    networkDataProvider.lerpState    = new VectorFrameEncoding();
                    networkDataProvider.prevState    = new VectorFrameEncoding();
                    networkDataProvider.currentState = new VectorFrameEncoding();
                    break;

                case FrameEncodingEnum.CurlHand:
                    playerState = new CurlFrameEncoding();
                    networkDataProvider.lerpState    = new CurlFrameEncoding();
                    networkDataProvider.prevState    = new CurlFrameEncoding();
                    networkDataProvider.currentState = new CurlFrameEncoding();
                    break;

                default:
                    playerState = new VectorFrameEncoding();
                    networkDataProvider.lerpState    = new VectorFrameEncoding();
                    networkDataProvider.prevState    = new VectorFrameEncoding();
                    networkDataProvider.currentState = new VectorFrameEncoding();
                    break;
                }
            }
            //handController.gameObject.AddComponent<LeapHandController>();
            playerState.fillEncoding(null);
        }
Пример #2
0
 void RpcsetState(byte[] data)
 {
     if (isLocalPlayer && !NetworkServer.active)
     {
         handData = data;
         playerState.fillEncoding(handData);
         if (NetworkDataProvider)
         {
             NetworkDataProvider.AddFrameState(playerState); //Enqueue new tracking data on an interval for everyone else
         }
     }
     return;
 }
Пример #3
0
        // Use this for initialization
        void Start()
        {
            //Application.targetFrameRate = 60;
            NetworkDataProvider = Resources.FindObjectsOfTypeAll <LeapStreamingProvider>()[0];
            LeapDataProvider    = Resources.FindObjectsOfTypeAll <LeapServiceProvider>()[0];

            switch (FrameEncodingType)
            {
            case FrameEncodingEnum.VectorHand:
                playerState = new VectorFrameEncoding();
                NetworkDataProvider.lerpState    = new VectorFrameEncoding();
                NetworkDataProvider.prevState    = new VectorFrameEncoding();
                NetworkDataProvider.currentState = new VectorFrameEncoding();
                break;

            case FrameEncodingEnum.CurlHand:
                playerState = new CurlFrameEncoding();
                NetworkDataProvider.lerpState    = new CurlFrameEncoding();
                NetworkDataProvider.prevState    = new CurlFrameEncoding();
                NetworkDataProvider.currentState = new CurlFrameEncoding();
                break;

            default:
                playerState = new VectorFrameEncoding();
                NetworkDataProvider.lerpState    = new VectorFrameEncoding();
                NetworkDataProvider.prevState    = new VectorFrameEncoding();
                NetworkDataProvider.currentState = new VectorFrameEncoding();
                break;
            }

            playerState.fillEncoding(handData);
        }
Пример #4
0
        public override void Update()
        {
            //Constantly adjust the interpolation play speed,
            //so there is always one sample in the buffer
            float playSpeed = stateBuffer.Count * 0.5f;

            //Increment the interpolation timeline
            interpolationTime += Time.unscaledDeltaTime * playSpeed;
            interpolationTime  = Mathf.Clamp(interpolationTime, 0f, sampleInterval * 3f);

            //Read from the state buffer until the interpolation timeline is caught up with real time
            while ((stateBuffer.Count > 0) && (interpolationTime > sampleInterval))
            {
                prevState.fillEncoding(currentState.data);
                currentState.fillEncoding(stateBuffer.Dequeue());
                interpolationTime -= sampleInterval;
            }

            //Interpolate the real samples according to the interpolation timeline
            lerpState.lerp(prevState, currentState, interpolationTime / sampleInterval);

            //if (RealtimeGraph.Instance != null) { RealtimeGraph.Instance.AddSample("InterpolationAlpha", RealtimeGraph.GraphUnits.Miliseconds, (prevState.RPos == currentState.RPos) ? 10f : 0f); }

            //Decode the interpolated state and send it off
            fillCurrentFrame(lerpState);
            DispatchUpdateFrameEvent(CurrentFrame);
        }
Пример #5
0
        public override void Update()
        {
            if (prevRecording != recording)
            {
                if (recording)
                {
                    StartRecording();
                    playing = false;
                }
                else
                {
                    Record();
                    StopRecording();
                }
                prevRecording = recording;
            }

            if (prevPlaying != playing)
            {
                if (playing)
                {
                    StartPlaying(fileName);
                    recording = false;
                }
                else
                {
                    StopPlaying();
                }
                prevPlaying = playing;
            }

            if (!playing)
            {
                playerState.fillEncoding(LeapDataProvider.CurrentFrame, transform);
                AddFrameState(playerState);
            }
            else
            {
                Play();
            }

            if (recording)
            {
                Record();
            }

            fillCurrentFrame(currentState);
            DispatchUpdateFrameEvent(CurrentFrame);
        }
Пример #6
0
        void Play()
        {
            //If we have reached the end of our playBackBuffer or the file...
            if (currentBufferTime >= (float)((playBackBuffer.Length / frameSize) - 1) / fps || currentFileTime >= (float)(((fileLength - headerLength) / frameSize) - 1) / fps)
            {
                readNextChunk();
            }
            int startFrame; float alpha;

            bufferTimeToFramesandAlpha(currentBufferTime, out startFrame, out alpha);

            Array.Copy(playBackBuffer, startFrame * frameSize, beginInterpolate.data, 0, frameSize);
            beginInterpolate.fillEncoding(beginInterpolate.data);
            Array.Copy(playBackBuffer, (startFrame + 1) * frameSize, endInterpolate.data, 0, frameSize);
            endInterpolate.fillEncoding(endInterpolate.data);

            playerState.lerp(beginInterpolate, endInterpolate, alpha);

            currentBufferTime += Time.deltaTime / 100f;
            currentFileTime   += Time.deltaTime / 100f;
            AddFrameState(playerState);
        }