示例#1
0
        public static void right_part(float angle)
        {
            rip_ok = 1;

            if (angle <= 180 && angle >= 120 && right_select != 0)
            {
                Console.Out.WriteLine(" section " + 1 + " angle " + angle);
                EigenRequest.startLoop("0");
                right_select = 0;
                rip_ok       = 0;
            }
            else if (angle < 120 && angle >= 60 && right_select != 1)
            {
                Console.Out.WriteLine(" section " + 2 + " angle " + angle);
                EigenRequest.startLoop("1");
                right_select = 1;
                rip_ok       = 0;
            }
            else if (angle < 60 && angle >= 0 && right_select != 2)
            {
                Console.Out.WriteLine(" section " + 3 + " angle " + angle);
                EigenRequest.startLoop("2");
                right_select = 2;
                rip_ok       = 0;
            }

            rip_ok = 0;
        }
示例#2
0
        public static void rip(Body body, JointType ElbowLeft, JointType WristLeft, JointType WristRight, JointType ShoulderLeft)
        {
            if (rip_ok == 0)
            {
                if ((body.Joints[ElbowLeft].Position.Y < body.Joints[WristLeft].Position.Y) && (body.Joints[ElbowLeft].Position.Y < body.Joints[ShoulderLeft].Position.Y))
                {
                    //  float valuerip = (body.Joints[WristRight].Position.Z) / Math.Abs(body.Joints[WristLeft].Position.Y - body.Joints[ElbowLeft].Position.Y);
                    //// Console.Out.WriteLine("rip " + Math.Abs(pre_z - body.Joints[WristRight].Position.Z)*1000);

                    //  float normalisation_factor=(body.Joints[JointType.Neck].Position.Y -body.Joints[JointType.SpineMid].Position.Y);

                    //  Console.Out.WriteLine("rip required" + Math.Abs(pre_z - body.Joints[WristRight].Position.Z)*1000 / normalisation_factor);

                    //  if (Math.Abs(pre_z-body.Joints[WristRight].Position.Z)*1000>8)
                    //  { //EigenRequest.playMusic("3");
                    //      //Console.Out.WriteLine("rip required" + Math.Abs(pre_z - body.Joints[WristRight].Position.Z)/normalisation_factor);
                    //  }
                    //  pre_z = body.Joints[WristRight].Position.Z;

                    if (sw.ElapsedMilliseconds >= 1500)
                    {
                        EigenRequest.playMusic("4"); // RIP

                        sw.Stop();
                        sw.Reset();
                        sw.Start();
                    }
                }
            }
        }
示例#3
0
 /// <summary>
 /// Execute start up tasks
 /// </summary>
 /// <param name="sender">object sending the event</param>
 /// <param name="e">event arguments</param>
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     if (this.bodyFrameReader != null)
     {
         this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
     }
     EigenRequest.playMusic("9");
     EigenRequest.changeVolume("9", "0.3"); // Background sound
 }
示例#4
0
        /// <summary>
        /// Handles the body frame data arriving from the sensor
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void Reader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            bool dataReceived = false;

            using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (this.bodies == null)
                    {
                        this.bodies = new Body[bodyFrame.BodyCount];
                    }

                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects wi  ll be re-used.
                    bodyFrame.GetAndRefreshBodyData(this.bodies);
                    dataReceived = true;
                }
            }



            if (dataReceived)
            {
                using (DrawingContext dc = this.drawingGroup.Open())
                {
                    // Draw a transparent background to set the render size
                    dc.DrawRectangle(backgroundBrush, null, new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));
                    this.DrawMainCircle(dc);

                    int penIndex = 0;
                    foreach (Body body in this.bodies)
                    {
                        Pen drawPen = this.bodyColors[penIndex++];

                        if (body.IsTracked)
                        {
                            //=================================================================================================================//
                            //angle between three point
                            //     float angle=   AngleBetweenJoints(body, JointType.ElbowRight, JointType.HandRight, JointType.ShoulderRight);

                            //============================================================================================//
                            //select section from right side

                            Boolean select    = false;
                            Joint   head      = body.Joints[JointType.Head];
                            Joint   Wristleft = body.Joints[JointType.WristLeft];

                            float right_section = AngleBetweenJoints(body, JointType.ShoulderRight, JointType.ElbowRight, JointType.HipRight);

                            int count = 1;
                            if (head.Position.Y < Wristleft.Position.Y)
                            {
                                if (count == 1)
                                {
                                    select = true; count = 2;
                                }
                                else if (count == 2)
                                {
                                    select = false; count = 1;
                                }
                            }

                            if (select && count == 2)
                            {
                                if ((body.Joints[JointType.ShoulderLeft].Position.Y < body.Joints[JointType.ElbowLeft].Position.Y) &&
                                    (body.Joints[JointType.ElbowLeft].Position.Y < body.Joints[JointType.WristLeft].Position.Y))

                                {
                                    right_part(right_section); rip_ok = 0;
                                }
                            }

                            //=======================================================================================//
                            //find distance from z axis
                            // if (body.Joints[JointType.WristLeft].Position.Y>body.Joints[JointType.ElbowLeft].Position.Y)
                            {
                                float depth_hand   = depth_from_Hand(body, JointType.HandLeft, JointType.HandRight);
                                float depth_hand_Y = depth_from_Hand_Y(body, JointType.HandLeft, JointType.HandRight);

                                Console.Out.WriteLine(right_select.ToString());
                                this.globalVolume = depth_hand;
                                this.globalTempo  = depth_hand_Y;
                                EigenRequest.changeVolume(right_select.ToString(), depth_hand.ToString());

                                float bmp = depth_hand_Y * 360;
                                if (bmp <= 0)
                                {
                                    bmp = 1;
                                }
                                EigenRequest.changeBPM(right_select.ToString(),
                                                       (System.Convert.ToUInt32(bmp)
                                                       ).ToString());
                                Console.Out.WriteLine((System.Convert.ToUInt32(depth_hand_Y * 360)
                                                       ).ToString());
                            }

                            // detect jump
                            Boolean jumpright = jump_right_leg(body, JointType.FootRight, JointType.FootLeft);
                            Boolean jumpleft  = jump_left_leg(body, JointType.FootRight, JointType.FootLeft);
                            //  Console.Out.WriteLine(jump);
                            if (jumpright)
                            {
                                //Console.Out.WriteLine("jumpright");
                                EigenRequest.playMusic("6");

                                //Console.Out.WriteLine("jump");
                                //EigenRequest.playMusic("6");
                            }
                            if (jumpleft)
                            {
                                //Console.Out.WriteLine("jumpleft");
                                EigenRequest.playMusic("7");
                            }
                            //play rip
                            rip(body, JointType.ElbowLeft, JointType.WristLeft, JointType.WristRight, JointType.ShoulderLeft);
                            {
                                // Console.Out.WriteLine(angle);
                                // Console.Out.WriteLine(right_section);


                                this.DrawClippedEdges(body, dc);

                                IReadOnlyDictionary <JointType, Joint> joints = body.Joints;

                                // convert the joint points to depth (display) space
                                Dictionary <JointType, Point> jointPoints = new Dictionary <JointType, Point>();

                                foreach (JointType jointType in joints.Keys)
                                {
                                    // sometimes the depth(Z) of an inferred joint may show as negative
                                    // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
                                    CameraSpacePoint position = joints[jointType].Position;
                                    if (position.Z < 0)
                                    {
                                        position.Z = InferredZPositionClamp;
                                    }

                                    DepthSpacePoint depthSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(position);
                                    jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y);
                                }

                                this.DrawBody(joints, jointPoints, dc, drawPen);

                                //this.DrawHand(body.HandLeftState, jointPoints[JointType.HandLeft], dc);
                                //this.DrawHand(body.HandRightState, jointPoints[JointType.HandRight], dc);
                                this.DrawBars(dc, globalTempo, globalVolume);
                                this.DrawRandombars(dc);
                            }
                        }

                        // prevent drawing outside of our render area
                        this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));
                    }
                }
            }
        }