private void Reader_MultiSourceFrameArrived(object sender, Kinect.MultiSourceFrameArrivedEventArgs e)
    {
        var reference = e.FrameReference.AcquireFrame();

        //Body
        using (var frame = reference.BodyFrameReference.AcquireFrame())
        {
            if (frame != null)
            {
                bodies = new Kinect.Body[frame.BodyFrameSource.BodyCount]; //BodyCount is always 6. I guess they have it on 6 because it is the maximum of the players that they can track per frame.
                frame.GetAndRefreshBodyData(bodies);
                var p = 0;                                                 //p counts the bodies so it counts the players

                foreach (var body in bodies)
                {
                    foundId = false;
                    if (body != null)
                    {
                        if (body.IsTracked)
                        {
                            players[p] = true;

                            if (playersIdBreak.Count == 0)
                            {
                                playersIdBreak.Add(body.TrackingId);
                            }

                            foreach (ulong id in playersIdBreak)
                            {
                                if (body.TrackingId == id)
                                {
                                    foundId = true;
                                }
                            }

                            if (foundId == false)
                            {
                                playersIdBreak.Add(body.TrackingId);
                            }
                        }
                        else
                        {
                            players[p] = false;
                        }
                    }
                    p++;
                }
            }
        }
    }
Example #2
0
    void Reader_MultiSourceFrameArrived(object sender, Kinect2.MultiSourceFrameArrivedEventArgs e)
    {
        var reference = e.FrameReference.AcquireFrame();

        using (var frame = reference.BodyFrameReference.AcquireFrame())
        {
            if (frame != null)
            {
                _Bodies = new Kinect2.Body[frame.BodyFrameSource.BodyCount];

                frame.GetAndRefreshBodyData(_Bodies);
                foreach (Kinect2.Body body in _Bodies)
                {
                    if (body.IsTracked)
                    {
                        /*
                         * if (sAutoMotionCaptureDevicesSelecter != null)
                         * {
                         *  sAutoMotionCaptureDevicesSelecter.bMoveTransform = true;
                         * }
                         */
                        fFBXRecStart -= Time.deltaTime;

                        /*
                         * if (fFBXRecStart <= 0.0) {
                         *  if (sFBXExporterForUnity != null)
                         *  {
                         *      sFBXExporterForUnity.bOutAnimation = true;
                         *  }
                         * }
                         */
                        _Body = body;

                        /*for (int ii = 0; ii < (int)Kinect2.JointType.ThumbRight - 4; ii++)
                         * {
                         *  if (((uint)Mask & (uint)(1 << ii)) > 0 && (_nullMask & (uint)(1 << ii)) <= 0)
                         *  {
                         *      RotateJoint(body, ii);
                         *  }
                         * }*/
                    }
                }
                frame.Dispose();
            }
        }
    }
    void Reader_MultiSourceFrameArrived(object sender, Kinect2.MultiSourceFrameArrivedEventArgs e)
    {
        var reference = e.FrameReference.AcquireFrame();

        using (var frame = reference.BodyFrameReference.AcquireFrame()) {
            if (frame != null)
            {
                _Bodies = new Kinect2.Body[frame.BodyFrameSource.BodyCount];

                frame.GetAndRefreshBodyData(_Bodies);
                foreach (Kinect2.Body body in _Bodies)
                {
                    if (body.IsTracked)
                    {
                        fFBXRecStart -= Time.deltaTime;
                        if (fFBXRecStart <= 0.0)
                        {
                            if (sFBXExporter4Unity != null)
                            {
                                sFBXExporter4Unity.bOutAnimation = true;
                            }
                        }
                        _Body = body;
                        for (int ii = 0; ii < (int)Kinect2.JointType.ThumbRight - 4; ii++)
                        {
                            if (((uint)Mask & (uint)(1 << ii)) > 0 && (_nullMask & (uint)(1 << ii)) <= 0)
                            {
                                RotateJoint(body, ii);
                            }
                        }
                    }
                }
                frame.Dispose();
            }
        }
    }
 // Token: 0x06002DA2 RID: 11682 RVA: 0x000E0B01 File Offset: 0x000DEF01
 internal MultiSourceFrameArrivedEventArgs(IntPtr pNative)
 {
     this._pNative = pNative;
     MultiSourceFrameArrivedEventArgs.Windows_Kinect_MultiSourceFrameArrivedEventArgs_AddRefObject(ref this._pNative);
 }