Example #1
0
 /// <summary>
 /// Constructor of the shoot object
 /// </summary>
 /// <param name="sensor"></param>
 /// <param name="skel"></param>
 /// <param name="forearm"></param>
 public Shoot(KinectSensor sensor, Skeleton skel, float forearm)
 {
     SkeletonPoint hand = skel.Joints[JointType.HandRight].Position;
     SkeletonPoint elbow = skel.Joints[JointType.ElbowRight].Position;
     calculator = new Calculator();
     gestures = new Gesture[2];
     gestures[0] = new Gesture(hand, JointType.HandRight, sensor, 1, 0.08f);
     gestures[1] = new Gesture(calculator.sum(elbow, 0.05 * Math.Sign(hand.X - elbow.X), 0.9 * forearm, 0.9 * forearm), JointType.HandRight, sensor, 0.1f, 0.3f);
     this.sensor = sensor;
     this.forearm = forearm;
 }
Example #2
0
        /// <summary>
        /// Measure the user to give a more personalizated positions
        /// </summary>
        /// <param name="skel">Skeleton tracked to determine user measures</param>
        /// <param name="actual_frame">Number of the actual frame to determine the waiting time</param>
        private void measureUser(Skeleton skel, int actual_frame)
        {
            this.statusBarText.Text = "Ponte en esta posiciĆ³n. \n Vamos a medirte.";
            this.measure_imagen.Visibility = Visibility.Visible;
            // Show the guide image
            this.measure_imagen.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("../../images/img.png")));

            SkeletonPoint right_shoulder = skel.Joints[JointType.ShoulderRight].Position;
            SkeletonPoint right_elbow = skel.Joints[JointType.ElbowRight].Position;
            SkeletonPoint right_wrist = skel.Joints[JointType.WristRight].Position;

            arm = calculator.distance(right_shoulder, right_elbow);
            forearm = calculator.distance(right_wrist, right_elbow);

            SkeletonPoint[] measuring_points = new SkeletonPoint[4];
            measuring_points[0] = calculator.sum(skel.Joints[JointType.ShoulderRight].Position, arm + 0.05, -0.05, 0);
            measuring_points[1] = calculator.sum(skel.Joints[JointType.ShoulderRight].Position, (arm + forearm) + 0.05, -0.05, 0);
            measuring_points[2] = calculator.sum(skel.Joints[JointType.ShoulderLeft].Position, -arm - 0.05, -0.05, 0);
            measuring_points[3] = calculator.sum(skel.Joints[JointType.ShoulderLeft].Position, -(arm + forearm) - 0.05, -0.05, 0);

            if (first_frame_measure == -1) {
                //Defines the measuring gesture
                JointType[] measuring_joints = new JointType[4];
                measuring_joints[0] = JointType.ElbowRight;
                measuring_joints[1] = JointType.HandRight;
                measuring_joints[2] = JointType.ElbowLeft;
                measuring_joints[3] = JointType.HandLeft;
                measuring = new Gesture(measuring_points, measuring_joints, my_KinectSensor, 1);

                // Begin the count
                first_frame_measure = actual_frame;
            }
            measuring.adjustLocations(measuring_points);
            measuring.adjustColor(skel, actual_frame);

            if (measuring.isCompleted() && !measured) {
                measured = true;
                first_frame_measure = -1;   // To ensure that the next time that an user need to be measured, he is
                this.measure_imagen.Visibility = Visibility.Hidden;
                initializeElements(skel, actual_frame);
                state = States.TUTORIAL;
                exit_tutorial.activate(actual_frame);
            }
        }
Example #3
0
        /// <summary>
        /// Determine gestures and guides positions
        /// </summary>
        /// <param name="skel">Skeleton tracked to determine guides positions</param>
        private void initializeElements(Skeleton skel, int actual_frame)
        {
            SkeletonPoint[] pause_points = new SkeletonPoint[2];
            pause_points[0] = calculator.sum(skel.Joints[JointType.ShoulderRight].Position, arm, forearm, -0.1);
            pause_points[1] = calculator.sum(skel.Joints[JointType.ShoulderLeft].Position, -arm, -forearm, -0.1);
            JointType[] pause_joints = new JointType[2];
            pause_joints[0] = JointType.HandRight;
            pause_joints[1] = JointType.HandLeft;
            pause = new Gesture(pause_points, pause_joints, my_KinectSensor, 2);

            pause.setDistanceColor(1, Brushes.LightGray);
            pause.setDistanceColor(2, Brushes.Transparent);

            SkeletonPoint hand = skel.Joints[JointType.HandRight].Position;
            SkeletonPoint elbow = skel.Joints[JointType.ElbowRight].Position;

            shoot = new Shoot(my_KinectSensor , skel, forearm);

            dalton1 = new InteractiveObject(ref imageDalton1, "JoeDalton.png", 160, 60);
            dalton2 = new InteractiveObject(ref imageDalton2, "JoeDalton2.png", 300, 120);
            lives_object = new InteractiveObject(ref life_image, "3.png", 0);
            fajita = new InteractiveObject(ref fajita_image, "fajita.png", 160, 500);

            exit_button = new InteractiveObject(ref exit_image, "salir.png", 0);
            back_to_game_button = new InteractiveObject(ref to_play_image, "volver_juego.png", 0);
            exit_tutorial = new InteractiveObject(ref exit_tutorial_image, "salir_tutorial.png", 0);
            point_mode_button = new InteractiveObject(ref points_image, "modo_puntuacion.png", 0);
            survive_mode_button = new InteractiveObject(ref survive_image, "modo_superviviente.png", 0);

            spock_hand.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("../../images/spock.png")));
            tutorial_image.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath("../../images/gesto_1.png")));

            first_tutorial_image_first_frame = actual_frame;
            second_tutorial_image_first_frame = actual_frame + 250;
            third_tutorial_image_first_frame = actual_frame + 500;
        }