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); }
// This method gets called every time the Kinect returns a new frame private void Render() { if (skeleton != null) { EllipseCanvas.Children.Clear(); // Allow user to resize window EllipseCanvas.Height = Canvas.ActualHeight; EllipseCanvas.Width = Canvas.ActualWidth; if (this.pliesGesture == null) { this.pliesGesture = new Gesture(EllipseCanvas, skeleton, (Rectangle)Canvas.FindName("pliesButton"), (TextBlock)Canvas.FindName("pliesTitle"), this.pliesMode); } if (this.firstPositionGesture == null) { this.firstPositionGesture = new Gesture(EllipseCanvas, skeleton, (Rectangle)Canvas.FindName("firstPositionButton"), (TextBlock)Canvas.FindName("firstPositionTitle"), this.firstPositionMode); } this.pliesMode = handleGesture(this.pliesGesture, "pliesButton", this.pliesMode); this.firstPositionMode = handleGesture(this.firstPositionGesture, "firstPositionButton", this.firstPositionMode); DrawSkeleton(skeleton, FRONT_VIEW); DrawSkeleton(skeleton, SIDE_VIEW); if (pliesMode) { // Show title TextBlock title = (TextBlock)Canvas.FindName("pliesTitle"); title.Visibility = Visibility.Visible; if (this.plie == null) { this.plie = new Plie(EllipseCanvas, skeleton); } // If the user successfully completes a plie or breaks out of the plie movement sequence, // set our Plie object to null so we know to start over with a new Plie object when render gets // called again. if (this.plie.gestureComplete && this.plie.position.showSuccessBanner("plieCompletedImage") || !this.plie.gestureComplete && !this.plie.trackPlie()) { this.plie = null; } } if (firstPositionMode) { // Show title TextBlock title = (TextBlock)Canvas.FindName("firstPositionTitle"); title.Visibility = Visibility.Visible; if (this.position == null) { this.position = new Position(EllipseCanvas, skeleton); } // If the user successfully completes a first position or breaks out of the first position // movement sequence, set our Position to null so we know to start over with a new Postition // when render gets called again. if (this.position.gestureComplete && this.position.showSuccessBanner("firstPositionCompletedImage") || !this.position.firstPosition()) { this.position = null; } } } else { System.Console.WriteLine("skeleton is null"); } }