Esempio n. 1
0
    void Update()
    {
        timer += Time.deltaTime;
        //Debug.Log("Timer: " + timer);
        if (timer < 3)
        {
            if (exercise == "Squat")
            {
                Squat_Instruction.SetActive(true);
            }
            else if (exercise == "SideHiKick")
            {
                SideHighKick_Instruction.SetActive(true);
            }
            else if (exercise == "Lunge")
            {
                Lunge_Left_Instruction.SetActive(true);
            }
        }
        else if (timer < 4)
        {
            Squat_Instruction.SetActive(false);
            SideHighKick_Instruction.SetActive(false);
            Lunge_Left_Instruction.SetActive(false);

            count3.SetActive(true);
            count2.SetActive(false);
            count1.SetActive(false);
            ex_start.SetActive(true);
        }
        else if (timer < 5)
        {
            count3.SetActive(false);
            count2.SetActive(true);
        }
        else if (timer < 6)
        {
            count2.SetActive(false);
            count1.SetActive(true);
            ex_start.SetActive(true);
        }
        else
        {
            count1.SetActive(false);
            ex_start.SetActive(false);

            //lsy
            if (trainer_check_outside)
            {
                Trainer_Run();
            }
            //lsy end

            float[]  data1 = new float[bodyCount * jointCount * 3];
            int[]    state = new int[bodyCount * jointCount];
            int[]    id    = new int[bodyCount];
            GCHandle gch   = GCHandle.Alloc(data1, GCHandleType.Pinned);
            GCHandle gch2  = GCHandle.Alloc(state, GCHandleType.Pinned);
            GCHandle gch3  = GCHandle.Alloc(id, GCHandleType.Pinned);

            if (BodySourceManager == null)
            {
                return;
            }

            _BodyManager = BodySourceManager.GetComponent <BodySourceManager>();
            if (_BodyManager == null)
            {
                return;
            }

            Kinect.Body[] data = _BodyManager.GetData();
            if (data == null)
            {
                return;
            }

            List <ulong> trackedIds = new List <ulong>();
            foreach (var body in data)
            {
                if (body == null)
                {
                    continue;
                }

                if (body.IsTracked)
                {
                    trackedIds.Add(body.TrackingId);
                }
            }

            List <ulong> knownIds = new List <ulong>(_Bodies.Keys);

            // First delete untracked bodies
            foreach (ulong trackingId in knownIds)
            {
                if (!trackedIds.Contains(trackingId))
                {
                    Destroy(_Bodies[trackingId]);
                    _Bodies.Remove(trackingId);
                }
            }

            foreach (var body in data)
            {
                if (body == null)
                {
                    continue;
                }

                if (body.IsTracked)
                {
                    if (!_Bodies.ContainsKey(body.TrackingId))
                    {
                        _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId);
                    }
                    RefreshBodyObject(body, _Bodies[body.TrackingId]);
                }
            }
        }
    }
Esempio n. 2
0
    void Start()
    {
        timer = 0;
        Trainner_count.text = "";
        Trainee_count.text  = "";
        total = "20";
        tot   = 20;

        skeleton_Trainnner = new CharacterSkeleton(Trainnner);
        skeleton_Trainnne  = new CharacterSkeleton(Trainnne);

        //lsy
        trainer_state = new int[bodyCount * jointCount];
        trainer_data1 = new float[bodyCount * jointCount * 3];
        //lsy end

        exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.

        // Debug.Log(exercise);    //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기

        if (exercise == "Squat")
        {
            lines = File.ReadAllLines(@"Trainer_txt/squart.txt");
            // Debug.Log("읽음");
        }
        else if (exercise == "SideHiKick")
        {
            lines       = File.ReadAllLines(@"Trainer_txt/leg_right.txt");
            lines_right = File.ReadAllLines(@"Trainer_txt/leg_left.txt");
            //Debug.Log("읽음");
        }
        else if (exercise == "Lunge")
        {
            lines       = File.ReadAllLines(@"Trainer_txt/runzi_right.txt");
            lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt");
            // Debug.Log("읽음");
        }
        else
        {
            lines = File.ReadAllLines(@"Trainer_txt/squart.txt");
            //Debug.Log("읽음");
        }

        workout_count = 0;
        workout_flag  = 0;
        workout_flag2 = 0;
        workout       = false;

        sidehk_flag  = 0;
        lunge_flag_l = 0;
        lunge_flag_r = 0;
        flag         = 0;
        flag_timer   = 0;

        if (exercise == "Squat")
        {
            Squat_Instruction.SetActive(true);
        }
        else if (exercise == "SideHiKick")
        {
            SideHighKick_Instruction.SetActive(true);
        }
        else if (exercise == "Lunge")
        {
            Lunge_Left_Instruction.SetActive(true);
        }

        //HipBalance1.SetActive(false);
        //PullHipBack2.SetActive(false);
        //LegUp3.SetActive(false);
        //SpineStraight4.SetActive(false);
        //Great5.SetActive(false);
        //KneeDown6.SetActive(false);
    }