public void SkeletonUpdate(SkeletonUpdateArgs e)
        {
            // Check to see if we have gone from 2 players to 1 player on this Kinect
            bool missingPlayer = e.Skeletons.Count < players[e.KinectId].Values.Count && e.Skeletons.Count == 1;

            // If we have a missing player, remove him and free his PlayerId for the next drop-in
            if (missingPlayer)
            {
                // TODO: refactor this to work a little better
                Player[] playerArray = players[e.KinectId].Values.ToArray<Player>();

                for (int i = 0; i < playerArray.Length; i++)
                {
                    if (playerArray[i].Skeleton.TrackingId != e.Skeletons[0].TrackingId)
                    {
                        RemovePlayer(playerArray[i]);
                    }
                }
            }

            // Iterate through the skeletons
            foreach (Skeleton skeleton in e.Skeletons)
            {
                // Try to update the skeleton associated with the new skeleton's tracking id
                try
                {
                    Player p = players[e.KinectId][skeleton.TrackingId];
                    p.Skeleton = skeleton;
                }
                catch (KeyNotFoundException e1)
                {
                    // If no skeleton is found and there is room, add a new player
                    if (players.Count < (pipeThreads.Count * 2))
                    {
                        //AddPlayer(new Player(playerIndex, e.KinectId, skeleton));
                        AddPlayer(skeleton, e.KinectId);
                    }
                }
            }

            // Call to gesture module
            if (players[e.KinectId].Values.Count > 0)
            {
                GestureModuleArgs args = new GestureModuleArgs(players[e.KinectId].Values.ToList<Player>());
                gestureModules[e.KinectId].BeginInvoke(args, null, null);
            }
        }
Example #2
0
 private void UpdateSkeletons(List<Skeleton> skeletons)
 {
     SkeletonUpdateArgs args = new SkeletonUpdateArgs(kinectId, skeletons);
     update.Invoke(args);
 }
 public void NoSkeletons(SkeletonUpdateArgs e)
 {
     RemovePlayerList(e.KinectId);
 }
Example #4
0
 private void EmptyFrame()
 {
     SkeletonUpdateArgs args = new SkeletonUpdateArgs(kinectId, null);
     empty.Invoke(args);
 }