Exemple #1
0
        //fills the skeleton info with infromation from the last skeleton frame
        private void _populateSkelInfo(int iter, GameState state)
        {
            SkeletonInfo tmp = new SkeletonInfo();

            tmp.TrackingID = _skeletonList[iter].TrackingId;
            tmp.Tracked    = _skeletonList[iter].TrackingState;

            var rightHand = _skeletonList[iter].Joints[JointType.HandRight];

            tmp.DisplayPosition = _coordMapper.MapSkeletonPointToColorPoint(_skeletonList[iter].Joints[JointType.ShoulderCenter].Position, ColorImageFormat.RgbResolution640x480Fps30);
            tmp.LeftHand        = _coordMapper.MapSkeletonPointToColorPoint(_skeletonList[iter].Joints[JointType.HandLeft].Position, ColorImageFormat.RgbResolution640x480Fps30);
            tmp.RightHand       = _coordMapper.MapSkeletonPointToColorPoint(rightHand.Position, ColorImageFormat.RgbResolution640x480Fps30);
            tmp.RightShoulder   = _coordMapper.MapSkeletonPointToColorPoint(_skeletonList[iter].Joints[JointType.ShoulderRight].Position, ColorImageFormat.RgbResolution640x480Fps30);

            if ((state ^ GameState.SinglePlayer) == GameState.Running ||
                (state ^ GameState.MultiPlayer) == GameState.Running)
            {
                _cursor.ToggleDisplay(false);
                var rightVec = new Vector2();
                var leftVec  = new Vector2();

                _calculateVectors(ref rightVec, ref leftVec, tmp);

                _selectNextColor(rightVec, leftVec, ref tmp);
                _getIndividualRot(rightVec, leftVec, ref tmp);
            }
            else if (iter < 1)
            {
                _cursor.ToggleDisplay(true);

                var world    = new Vector2(640, 480);
                var width    = world.X * .4f;
                var height   = world.Y * .4f;
                var bounding = new Rectangle(tmp.RightShoulder.X - (int)(width / 2),
                                             tmp.RightShoulder.Y - (int)(height / 2),
                                             (int)width, (int)height);

                var location = new ColorImagePoint();
                if (bounding.Contains(tmp.RightHand.X, tmp.RightHand.Y))
                {
                    location.X = tmp.RightHand.X - bounding.X;
                    location.Y = tmp.RightHand.Y - bounding.Y;
                    location   = location.BoundingToWorldSpace(new Vector2(width, height), world);
                }
                _cursor.Pos = new Vector2(location.X, location.Y);
                _cursor.Update(state);
            }

            AssignSkeletonInfo(tmp, iter);
        }