コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            _recordedTransform.position = dce.position;
            _recordedTransform.rotation = dce.rotation;

            RGBDStreamEventArgs evArgs = PollEventQueue();

            if (evArgs != null && RGBDStreamEvent != null)
            {
                RGBDStreamEvent(this, evArgs);
            }

            if (_state == RGBD_STATE.IDLE && last_idle + 2.0f < Time.time)
            {
                RequestConfig();
                last_idle = Time.time;
            }

            RGBDBodyFrame f = DequeueBodyFrame();

            while (f != null)
            {
                if (!_trackedBodies.ContainsKey(f.trackingID) || _trackedBodies[f.trackingID] == null)
                {
                    GameObject newBody = Instantiate(bodyPrefab, sfs.cameraTransform);
                    newBody.transform.localPosition = Vector3.zero;
                    newBody.transform.localRotation = Quaternion.identity;
                    _trackedBodies.Add(f.trackingID, newBody.GetComponent <RGBDBody>());
                }

                _trackedBodies[f.trackingID].ApplyFrame(f);
                f = DequeueBodyFrame();
            }
        }
コード例 #2
0
        private RGBDStreamEventArgs PollEventQueue()
        {
            RGBDStreamEventArgs res = null;

            lock (_eventQueueLock) {
                if (_eventQueue.Count > 0)
                {
                    res = _eventQueue.Dequeue();
                }
            }
            return(res);
        }
コード例 #3
0
 private void QueueEvent(RGBDStreamEventArgs ev)
 {
     lock (_bodyFramesLock) {
         _eventQueue.Enqueue(ev);
     }
 }