Exemple #1
0
        public Plie(Canvas canvas, Skeleton skeleton)
        {
            this.skeleton = skeleton;
            this.canvas = canvas;
            this.position = new Position(canvas, skeleton);

            Point3D leftKnee = new Point3D(skeleton.Joints[JointType.KneeLeft].Position.X,
                skeleton.Joints[JointType.KneeLeft].Position.Y,
                skeleton.Joints[JointType.KneeLeft].Position.Z);
            Point3D rightKnee = new Point3D(skeleton.Joints[JointType.KneeRight].Position.X,
                skeleton.Joints[JointType.KneeRight].Position.Y,
                skeleton.Joints[JointType.KneeRight].Position.Z);

            // Set initial "previous frame" to current frame position
            this.leftKneePreviousFrame = leftKnee;
            this.rightKneePreviousFrame = rightKnee;

            this.leftKneeTopRange = new Range(leftKnee.y, Range.kneeIntermediateRange);
            this.rightKneeTopRange = new Range(rightKnee.y, Range.kneeIntermediateRange);

            this.leftFootXRange = new Range(skeleton.Joints[JointType.FootLeft].Position.X, Range.footEasyRange);
            this.leftFootYRange = new Range(skeleton.Joints[JointType.FootLeft].Position.Y, Range.footEasyRange);
            this.leftFootZRange = new Range(skeleton.Joints[JointType.FootLeft].Position.Z, Range.footEasyRange);
            this.rightFootXRange = new Range(skeleton.Joints[JointType.FootRight].Position.X, Range.footEasyRange);
            this.rightFootYRange = new Range(skeleton.Joints[JointType.FootRight].Position.Y, Range.footEasyRange);
            this.rightFootZRange = new Range(skeleton.Joints[JointType.FootRight].Position.Z, Range.footEasyRange);
        }
Exemple #2
0
        public Boolean firstPosition()
        {
            if (skeleton == null)
            {
                return false;
            }

            checkAlignment();

            Joint rightAnkle = this.skeleton.Joints[JointType.AnkleRight];
            Joint leftAnkle = this.skeleton.Joints[JointType.AnkleLeft];
            Joint rightHip = this.skeleton.Joints[JointType.HipRight];
            Joint leftHip = this.skeleton.Joints[JointType.HipLeft];

            // Make sure feet are equally positioned on the floor (one foot isn't in front of the other)
            Range rightAnkleYComparison = new Range(rightAnkle.Position.Y, Range.ankleEasyRange);
            Range rightAnkleZComparison = new Range(rightAnkle.Position.Z, Range.ankleEasyRange);
            // Make sure feet are not wider than the hips
            Range rightHipXComparison = new Range(rightHip.Position.X, Range.hipEasyRange);
            Range leftHipXComparison = new Range(leftHip.Position.X, Range.hipEasyRange);

            return (rightAnkleYComparison.inRange(leftAnkle.Position.Y) &&
                    rightAnkleZComparison.inRange(leftAnkle.Position.Z) &&
                    rightAnkle.Position.X <= rightHipXComparison.maximum &&
                    leftAnkle.Position.X >= leftHipXComparison.minimum &&
                    rightFootStable() &&
                    leftFootStable() &&
                    rightFootTurnout() &&
                    leftFootTurnout()
            );
        }
Exemple #3
0
        public Position(Canvas canvas, Skeleton skeleton)
        {
            this.skeleton = skeleton;
            this.canvas = canvas;

            this.leftFootXRange = new Range(skeleton.Joints[JointType.FootLeft].Position.X, Range.footEasyRange);
            this.leftFootYRange = new Range(skeleton.Joints[JointType.FootLeft].Position.Y, Range.footEasyRange);
            this.leftFootZRange = new Range(skeleton.Joints[JointType.FootLeft].Position.Z, Range.footEasyRange);
            this.rightFootXRange = new Range(skeleton.Joints[JointType.FootRight].Position.X, Range.footEasyRange);
            this.rightFootYRange = new Range(skeleton.Joints[JointType.FootRight].Position.Y, Range.footEasyRange);
            this.rightFootZRange = new Range(skeleton.Joints[JointType.FootRight].Position.Z, Range.footEasyRange);
            this.correction = new TextBlock();
            correction.Background = Brushes.Orange;
            correction.FontSize = 40;
            Canvas.SetTop(correction, 200);
        }
Exemple #4
0
        // This returns whether or not the user is still in the correct movement
        // sequence to complete a plie.
        // If the user deviates from the movements involved to complete a plie,
        // the method will return false.
        public Boolean trackPlie()
        {
            if (skeleton == null)
            {
                return false;
            }

            // Alignment checks
            this.position.checkAlignment();

            // Grab joints observed in a plie
            Joint leftKnee = skeleton.Joints[JointType.KneeLeft];
            Joint rightKnee = skeleton.Joints[JointType.KneeRight];
            Joint leftFoot = skeleton.Joints[JointType.FootLeft];
            Joint rightFoot = skeleton.Joints[JointType.FootRight];
            Joint leftAnkle = skeleton.Joints[JointType.AnkleLeft];
            Joint rightAnkle = skeleton.Joints[JointType.AnkleRight];

            Range leftKneeRange = new Range(this.leftKneePreviousFrame.y, Range.kneeEasyRange);
            Range rightKneeRange = new Range(this.rightKneePreviousFrame.y, Range.kneeEasyRange);

            // Folllow process of movement for a plie
            // Make sure feet are turned out and haven't moved
            if (this.position.leftFootTurnout() &&
                this.position.rightFootTurnout() &&
                this.position.leftFootStable() &&
                this.position.rightFootStable()
            )
            {
                // On our way down
                if (!this.plieBottomReached)
                {
                    {
                        if (!(leftKnee.Position.Y <= leftKneeRange.maximum ||
                            rightKnee.Position.Y <= rightKneeRange.maximum)
                        )
                        {
                            this.plieMovingUpFrames++;

                            if (this.plieMovingUpFrames >= 5)
                            {
                                this.plieBottomReached = true;
                            }
                        }

                        this.leftKneePreviousFrame = new Point3D(leftKnee.Position.X, leftKnee.Position.Y, leftKnee.Position.Z);
                        this.rightKneePreviousFrame = new Point3D(rightKnee.Position.X, rightKnee.Position.Y, rightKnee.Position.Z);
                        return true;
                    }
                }
                // On our way up
                else
                {
                    if (leftKnee.Position.Y >= leftKneeRange.minimum ||
                        rightKnee.Position.Y >= rightKneeRange.minimum
                    )
                    {
                        if (leftKnee.Position.Y >= this.leftKneeTopRange.minimum &&
                            rightKnee.Position.Y >= this.rightKneeTopRange.minimum)
                        {
                            this.gestureComplete = true;
                        }
                        this.leftKneePreviousFrame = new Point3D(leftKnee.Position.X, leftKnee.Position.Y, leftKnee.Position.Z);
                        this.rightKneePreviousFrame = new Point3D(rightKnee.Position.X, rightKnee.Position.Y, rightKnee.Position.Z);
                        return true;
                    }
                }
            }
            return false;
        }
Exemple #5
0
        public void hipAlignmentYAxis()
        {
            Joint leftHip = (skeleton.Joints[JointType.HipLeft]);
            Joint rightHip = (skeleton.Joints[JointType.HipRight]);
            Range range = new Range(leftHip.Position.Y, Range.hipIntermediateRange);

            Point p1 = new Point(rightHip.Position.X * (windowWidth / 2) + (windowWidth / 2), rightHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(leftHip.Position.X * (windowWidth / 2) + (windowWidth / 2), leftHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (rightHip.Position.Y < range.minimum)
            {
                p3 = new Point(leftHip.Position.X * (windowWidth / 2) + (windowWidth / 2), leftHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = upDownColor, StrokeThickness = correctionLineThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (rightHip.Position.Y > range.maximum)
            {
                p3 = new Point(rightHip.Position.X * (windowWidth / 2) + (windowWidth / 2), rightHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p1.X, Y1 = p1.Y, X2 = p3.X, Y2 = p3.Y, Stroke = upDownColor, StrokeThickness = correctionLineThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }
Exemple #6
0
        public void spineAlignmentYAxis()
        {
            Joint centerHip = skeleton.Joints[JointType.HipCenter];
            Joint centerShoulder = skeleton.Joints[JointType.ShoulderCenter];
            Range hipsRange = new Range(centerShoulder.Position.Z, Range.hipsToShouldersIntermediateRange);

            Point p1 = new Point(centerHip.Position.X * (windowWidth / 2) + (windowWidth / 2), centerHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (centerHip.Position.Z > hipsRange.maximum)
            {
                p3 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio - correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (centerHip.Position.Z < hipsRange.minimum)
            {
                p3 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }
Exemple #7
0
        public void shoulderAlignmentZAxis()
        {
            Joint leftShoulder = skeleton.Joints[JointType.ShoulderLeft];
            Joint rightShoulder = skeleton.Joints[JointType.ShoulderRight];
            Range range = new Range(leftShoulder.Position.Z, Range.shoulderIntermediateRange);

            Point p1 = new Point(leftShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), leftShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(rightShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), rightShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (rightShoulder.Position.Z > range.maximum)
            {
                p3 = new Point(leftShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), leftShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio - correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p1.X, Y1 = p1.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (rightShoulder.Position.Z < range.minimum)
            {
                p3 = new Point(rightShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), rightShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }