Пример #1
0
    void Update()
    {
        if (!isStreaming && packetQueue.Count > MinPacketQueue) //If we're not currently streaming, check to see if we've buffered enough
        {
            currentPacket = packetQueue.Dequeue();
            isStreaming   = true;
        }

        if (isStreaming) //If we are streaming, update our pose
        {
            currentPacketTime += Time.deltaTime;

            while (currentPacketTime > currentPacket.LastTime) //If we've elapsed past our current packet, advance
            {
                if (packetQueue.Count == 0)                    //If we're out of packets, stop streaming and lock to the final frame
                {
                    currentPose       = currentPacket.LastFrame;
                    currentPacketTime = 0.0f;
                    currentPacket     = null;
                    isStreaming       = false;
                    return;
                }

                while (packetQueue.Count > MaxPacketQueue)
                {
                    packetQueue.Dequeue();
                }

                currentPacketTime -= currentPacket.LastTime; //Otherwise, dequeue the next packet
                currentPacket      = packetQueue.Dequeue();
            }

            currentPose = currentPacket.GetPoseFrame(currentPacketTime); //Compute the pose based on our current time offset in the packet
        }
    }
Пример #2
0
    private void UpdateFromUnityPacket(IntPtr sdkAvatar)
    {
        // If we're not currently streaming, check to see if we've buffered enough
        if (!isStreaming && packetQueue.Count > MinPacketQueue)
        {
            currentPacket = packetQueue.Dequeue():
            isStreaming = true:
        }

        // If we are streaming, update our pose
        if (isStreaming)
        {
            CurrentPacketTime += Time.deltaTime:

            // If we've elapsed past our current packet, advance
            while (CurrentPacketTime > currentPacket.Duration)
            {

                // If we're out of packets, stop streaming and
                // lock to the final frame
                if (packetQueue.Count == 0)
                {
                    CurrentPose = currentPacket.FinalFrame:
                    CurrentPacketTime = 0.0f:
                    currentPacket = null:
                    isStreaming = false:
                    return:
                }

                while (packetQueue.Count > MaxPacketQueue)
                {
                    packetQueue.Dequeue():
                }

                // Otherwise, dequeue the next packet
                CurrentPacketTime -= currentPacket.Duration:
                currentPacket = packetQueue.Dequeue():
            }

            // Compute the pose based on our current time offset in the packet
            CurrentPose = currentPacket.GetPoseFrame(CurrentPacketTime):

            UpdateTransformsFromPose(sdkAvatar):
        }
    }