Exemplo n.º 1
0
 void Start()
 {
     if (null == this.BodySourceManager)
     {
         BodySourceManager[] objs = FindObjectsOfType(typeof(BodySourceManager)) as BodySourceManager[];
         if (objs.Length > 0)
         {
             this.BodySourceManager = objs[0];
         }
     }
 }
Exemplo n.º 2
0
 public void Start()
 {
     // common for someone to forget to set this so,
     // if body source manager wasn't set try to find it
     if (null == this.BodySourceManager)
     {
         BodySourceManager[] objs = FindObjectsOfType(typeof(BodySourceManager)) as BodySourceManager[];
         if (objs.Length > 0)
         {
             this.BodySourceManager = objs[0];
         }
     }
 }
Exemplo n.º 3
0
 void Start()
 {
     if (null == this.BodySourceManager)
     {
         BodySourceManager[] objs = FindObjectsOfType(typeof(BodySourceManager)) as BodySourceManager[];
         if (objs.Length > 0)
         {
             this.BodySourceManager = objs[0];
         }
     }
     _Sensor    = Windows.Kinect.KinectSensor.GetDefault();
     cam        = GameObject.Find("Main Camera").GetComponent <Camera>();
     resFactorY = (float)Screen.height / 1080;
     resFactorX = (float)Screen.width / 1920;
 }
Exemplo n.º 4
0
        void Update()
        {
            if (BodySourceManager == null)
            {
                return;
            }

            _BodyManager = BodySourceManager.GetComponent <BodySourceManager>();
            if (_BodyManager == null)
            {
                return;
            }

            Kinect.Body[] data = _BodyManager.Bodies;
            if (data == null)
            {
                return;
            }

            List <ulong> trackedIds = new List <ulong>();

            foreach (var body in data)
            {
                if (body == null)
                {
                    continue;
                }

                if (body.IsTracked)
                {
                    trackedIds.Add(body.TrackingId);
                }
            }

            List <ulong> knownIds = new List <ulong>(_Bodies.Keys);

            // First delete untracked bodies
            foreach (ulong trackingId in knownIds)
            {
                if (!trackedIds.Contains(trackingId))
                {
                    Destroy(_Bodies[trackingId]);
                    _Bodies.Remove(trackingId);
                }
            }

            foreach (var body in data)
            {
                if (body == null)
                {
                    continue;
                }

                if (body.IsTracked)
                {
                    if (!_Bodies.ContainsKey(body.TrackingId))
                    {
                        _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId);
                    }

                    RefreshBodyObject(body, _Bodies[body.TrackingId]);
                }
            }
        }