コード例 #1
0
 public Message(string arg, int val, Jointure[] array)
 {
     str = arg;
     id = val;
     arr = array;
 }
コード例 #2
0
        private void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            SkeletonFrame skeletonFrame = e.SkeletonFrame;

            uint skel = 0;
            Message[] skeletons = new Message[2];

            int iSkeleton = 0;

            // skeleton.Children.Clear();

            foreach (SkeletonData data in skeletonFrame.Skeletons)
            {

                if (SkeletonTrackingState.Tracked == data.TrackingState)
                {

                    Jointure HipCenter = new Jointure("hipcenter", data.Joints[JointID.HipCenter]);
                    Jointure Spine = new Jointure("spine", data.Joints[JointID.Spine]);
                    Jointure ShoulderCenter = new Jointure("shouldercenter", data.Joints[JointID.ShoulderCenter]);
                    Jointure Head = new Jointure("head", data.Joints[JointID.Head]);
                    Jointure ShoulderLeft = new Jointure("shoulderleft", data.Joints[JointID.ShoulderLeft]);
                    Jointure ElbowLeft = new Jointure("elbowleft", data.Joints[JointID.ElbowLeft]);
                    Jointure WristLeft = new Jointure("wristleft", data.Joints[JointID.WristLeft]);
                    Jointure HandLeft = new Jointure("handleft", data.Joints[JointID.HandLeft]);
                    Jointure ShoulderRight = new Jointure("shoulderight", data.Joints[JointID.ShoulderRight]);
                    Jointure ElbowRight = new Jointure("elbowright", data.Joints[JointID.ElbowRight]);
                    Jointure WristRight = new Jointure("wristright", data.Joints[JointID.WristRight]);
                    Jointure HandRight = new Jointure("handright", data.Joints[JointID.HandRight]);
                    Jointure HipLeft = new Jointure("hipleft", data.Joints[JointID.HipLeft]);
                    Jointure KneeLeft = new Jointure("kneeleft", data.Joints[JointID.KneeLeft]);
                    Jointure AnkleLeft = new Jointure("ankleleft", data.Joints[JointID.AnkleLeft]);
                    Jointure FootLeft = new Jointure("footleft", data.Joints[JointID.FootLeft]);
                    Jointure HipRight = new Jointure("hipright", data.Joints[JointID.HipRight]);
                    Jointure KneeRight = new Jointure("kneeright", data.Joints[JointID.KneeRight]);
                    Jointure AnkleRight = new Jointure("ankleright", data.Joints[JointID.AnkleRight]);
                    Jointure FootRight = new Jointure("footright", data.Joints[JointID.FootRight]);

                    Jointure[] array = new Jointure[20];
                    array[0] = HipCenter;
                    array[1] = Spine;
                    array[2] = Head;
                    array[3] = ShoulderLeft;
                    array[4] = ElbowLeft;
                    array[5] = WristLeft;
                    array[6] = HandLeft;
                    array[7] = ShoulderCenter;
                    array[8] = ShoulderRight;
                    array[9] = ElbowRight;
                    array[10] = WristRight;
                    array[11] = HandRight;
                    array[12] = HipLeft;
                    array[13] = KneeLeft;
                    array[14] = AnkleLeft;
                    array[15] = FootLeft;
                    array[16] = HipRight;
                    array[17] = KneeRight;
                    array[18] = AnkleRight;
                    array[19] = FootRight;

                    string message = "";
                    // Message info = new Message(message, 0);

                    for (int i = 0; i < array.Length; i++)
                    {
                        message += "joint/";
                        message += array[i].name.ToString();
                        message += "/";
                        message += array[i].x.ToString();
                        message += "/";
                        message += array[i].y.ToString();
                        message += "/";
                        message += array[i].z.ToString();
                    }

                    Message info = new Message(message, data.TrackingID, array);
                    // info.Initialize(message, data.TrackingID);

                    skeletons[skel] = info;
                    skel++;

                } // if SkeletonTrackingState.Tracked == data.TrackingState

                iSkeleton++;

            } // for each skeleton

            uint loop = 0;
            Int32[] temp = new Int32[2];

            foreach (Message i in skeletons)
            {
                if (i == null)
                {
                    temp[loop] = 0;
                }
                else
                {
                    temp[loop] = i.GetID();
                }

                loop++;
            }

            uint index;

            #region if : dispatchSkeleton
            if (temp[0] == 0)
            {
                index = 1;
                dispatchSkeleton(skeletons[index]);
                return;
            }

            if (temp[1] == 0)
            {
                index = 0;
                dispatchSkeleton(skeletons[index]);
                return;
            }

            if (temp[0] < temp[1])
            {
                index = 0;
                dispatchSkeleton(skeletons[index]);
                return;
            }

            if (temp[1] < temp[0])
            {
                index = 1;
                dispatchSkeleton(skeletons[index]);
                return;
            }
            #endregion
        }