Esempio n. 1
0
        private void Start()
        {
            arkitFacialValues = new ARKitFacialValues();

            recorder = new ARKitFacialRecorder();

            var oscParser = new Parser();

            var server = new UdpServerProxy(port, (bytes, endPoint) =>
            {
                oscParser.FeedData(bytes, bytes.Length);

                while (0 < oscParser.MessageCount)
                {
                    var msg = oscParser.PopMessage();
                    OnReceivedOsc(msg);
                }
            });

            Observable
            .EveryUpdate()
            .Subscribe(_ =>
            {
                recorder.RecordUpdate(arkitFacialValues);

                arkitFacialControl.ApplyExternal(arkitFacialValues);

                if (text)
                {
                    text.text = arkitFacialValues.ToString();
                }
            }).AddTo(this);
        }
Esempio n. 2
0
        private void Start()
        {
            arkitFacialValues = new ARKitFacialValues();

            recorder = new ARKitFacialRecorder();

            Parser oscParser = new Parser();

            var server = new UdpServerProxy <Queue <Message> >(port, (bytes, endPoint) =>
            {
                oscParser.FeedData(bytes, bytes.Length);

                messageQueue.Clear();

                while (0 < oscParser.MessageCount)
                {
                    var msg = oscParser.PopMessage();

                    messageQueue.Enqueue(msg);
                }

                return(messageQueue);
            });

            server.OnValueChanged()
            .SubscribeOn(Scheduler.ThreadPool)
            .Subscribe()
            .AddTo(this);

            Observable
            .EveryUpdate()
            .Where(_ => messageQueue.Count > 0)
            .Subscribe(_ =>
            {
                for (int i = 0; i < messageQueue.Count; i++)
                {
                    OnReceivedOsc(messageQueue.Dequeue());
                }
            }).AddTo(this);

            Observable
            .EveryUpdate()
            .Subscribe(_ =>
            {
                recorder.RecordUpdate(arkitFacialValues);

                arkitFacialControl.ApplyExternal(arkitFacialValues);

                if (text)
                {
                    text.text = arkitFacialValues.ToString();
                }
            }).AddTo(this);
        }
        public void SetTime(double time)
        {
            if (!asset)
            {
                return;
            }

            var bytes       = asset.bytes;
            int totalFrames = bytes.Length / bufferLength;

            ARKitFacialValues value = null;

            for (int i = 0; i < totalFrames; i++)
            {
                var buffer = new byte[bufferLength];

                Buffer.BlockCopy(bytes, i * bufferLength, buffer, 0, buffer.Length);

                value = ZeroFormatterSerializer.Deserialize <ARKitFacialValues>(buffer);

                double sec = (double)value.elapsedTicks / Stopwatch.Frequency;

                if (sec >= time)
                {
                    break;
                }
            }

            if (value != null)
            {
                facialControl.ApplyExternal(value);
            }
            else
            {
            }
        }