고다경

트레이너 속도 조절

...@@ -2141,7 +2141,7 @@ MonoBehaviour: ...@@ -2141,7 +2141,7 @@ MonoBehaviour:
2141 SideHighKick_Instruction: {fileID: 1616699126} 2141 SideHighKick_Instruction: {fileID: 1616699126}
2142 Lunge_Left_Instruction: {fileID: 1914474766} 2142 Lunge_Left_Instruction: {fileID: 1914474766}
2143 Lunge_Right_Instruction: {fileID: 1540314533} 2143 Lunge_Right_Instruction: {fileID: 1540314533}
2144 - Right_Start: {fileID: 0} 2144 + Right_Start: {fileID: 779933557}
2145 --- !u!4 &1461362268 2145 --- !u!4 &1461362268
2146 Transform: 2146 Transform:
2147 m_ObjectHideFlags: 0 2147 m_ObjectHideFlags: 0
......
...@@ -44,7 +44,7 @@ public class Move : MonoBehaviour ...@@ -44,7 +44,7 @@ public class Move : MonoBehaviour
44 public bool trainer_check_outside = true; 44 public bool trainer_check_outside = true;
45 public float trainer_timer = 0; 45 public float trainer_timer = 0;
46 public bool trainer_other_side = false; 46 public bool trainer_other_side = false;
47 - public int trainer_speed = 5; 47 + public int trainer_speed = 0;
48 //lsy end 48 //lsy end
49 49
50 public Text AngleLeftKnee; 50 public Text AngleLeftKnee;
...@@ -149,7 +149,7 @@ public class Move : MonoBehaviour ...@@ -149,7 +149,7 @@ public class Move : MonoBehaviour
149 { 149 {
150 Lunge_Right_Instruction.SetActive(false); 150 Lunge_Right_Instruction.SetActive(false);
151 151
152 - trainer_speed = 8; 152 + trainer_speed = 7;
153 trainer_count = 0; 153 trainer_count = 0;
154 lines = lines_right; 154 lines = lines_right;
155 trainer_other_side = true; 155 trainer_other_side = true;
...@@ -242,7 +242,7 @@ public class Move : MonoBehaviour ...@@ -242,7 +242,7 @@ public class Move : MonoBehaviour
242 //lsy end 242 //lsy end
243 243
244 exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴. 244 exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
245 - exercise = "Squat"; 245 + exercise = "Lunge";
246 Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기 246 Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
247 247
248 if (exercise == "Squat") 248 if (exercise == "Squat")
...@@ -258,7 +258,6 @@ public class Move : MonoBehaviour ...@@ -258,7 +258,6 @@ public class Move : MonoBehaviour
258 } 258 }
259 else if (exercise == "Lunge") 259 else if (exercise == "Lunge")
260 { 260 {
261 - trainer_speed = 5;
262 lines = File.ReadAllLines(@"Trainer_txt/runzi_right.txt"); 261 lines = File.ReadAllLines(@"Trainer_txt/runzi_right.txt");
263 lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt"); 262 lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt");
264 Debug.Log("읽음"); 263 Debug.Log("읽음");
...@@ -364,47 +363,21 @@ public class Move : MonoBehaviour ...@@ -364,47 +363,21 @@ public class Move : MonoBehaviour
364 count1.SetActive(false); 363 count1.SetActive(false);
365 ex_start.SetActive(true); 364 ex_start.SetActive(true);
366 365
367 - HipBalance1.SetActive(false);
368 - PullHipBack2.SetActive(false);
369 - LegUp3.SetActive(false);
370 - SpineStraight4.SetActive(false);
371 - Great5.SetActive(false);
372 - KneeDown6.SetActive(false);
373 -
374 } 366 }
375 else if (timer < 5) { 367 else if (timer < 5) {
376 count3.SetActive(false); 368 count3.SetActive(false);
377 count2.SetActive(true); 369 count2.SetActive(true);
378 - count1.SetActive(false);
379 - ex_start.SetActive(true);
380 -
381 - HipBalance1.SetActive(false);
382 - PullHipBack2.SetActive(false);
383 - LegUp3.SetActive(false);
384 - SpineStraight4.SetActive(false);
385 - Great5.SetActive(false);
386 - KneeDown6.SetActive(false);
387 370
388 } 371 }
389 else if (timer < 6) 372 else if (timer < 6)
390 { 373 {
391 - count3.SetActive(false);
392 count2.SetActive(false); 374 count2.SetActive(false);
393 count1.SetActive(true); 375 count1.SetActive(true);
394 ex_start.SetActive(true); 376 ex_start.SetActive(true);
395 377
396 - HipBalance1.SetActive(false);
397 - PullHipBack2.SetActive(false);
398 - LegUp3.SetActive(false);
399 - SpineStraight4.SetActive(false);
400 - Great5.SetActive(false);
401 - KneeDown6.SetActive(false);
402 -
403 } 378 }
404 else 379 else
405 { 380 {
406 - count3.SetActive(false);
407 - count2.SetActive(false);
408 count1.SetActive(false); 381 count1.SetActive(false);
409 ex_start.SetActive(false); 382 ex_start.SetActive(false);
410 383
...@@ -417,19 +390,6 @@ public class Move : MonoBehaviour ...@@ -417,19 +390,6 @@ public class Move : MonoBehaviour
417 } 390 }
418 //lsy end 391 //lsy end
419 392
420 -
421 - IfSpineIsStraight.text = "허리를 곧게: Tracking";
422 - HipBalance.text = "양쪽 힙 균형: Calculating";
423 - AngleLeftKnee.text = "";
424 - AngleRightKnee.text = "";
425 - KneeToeLeft.text = "";
426 - KneeToeRight.text = "";
427 - LeftLegUp.text = "왼쪽 다리 들어올린 각도: Tracking";
428 - RightLegUp.text = "오른쪽 다리 들어올린 각도: Tracking";
429 -
430 - PullHipBack.text = "";
431 - Great.text = "";
432 -
433 float[] data1 = new float[bodyCount * jointCount * 3]; 393 float[] data1 = new float[bodyCount * jointCount * 3];
434 int[] state = new int[bodyCount * jointCount]; 394 int[] state = new int[bodyCount * jointCount];
435 int[] id = new int[bodyCount]; 395 int[] id = new int[bodyCount];
...@@ -539,257 +499,257 @@ public class Move : MonoBehaviour ...@@ -539,257 +499,257 @@ public class Move : MonoBehaviour
539 Kinect.Joint sourceJoint = body.Joints[jt]; 499 Kinect.Joint sourceJoint = body.Joints[jt];
540 Kinect.Joint? targetJoint = null; 500 Kinect.Joint? targetJoint = null;
541 501
542 - /////////////////////////// 502 +
543 - Angles MyAngles = new Angles();
544 - byte[] ReadAngles = MyAngles.GetVector(body);
545 503
546 - if (exercise == "Squat") 504 + if (_BoneMap.ContainsKey(jt))
547 { 505 {
548 - if (ReadAngles[1] - ReadAngles[2] <= 5) 506 + targetJoint = body.Joints[_BoneMap[jt]];
549 - { 507 + }
550 - hipbal = ""; 508 + Transform jointObj = bodyObject.transform.Find(jt.ToString());
551 - //hipbal = "양쪽 균형이 잡혀있습니다."; 509 + jointObj.localPosition = GetVector3FromJoint(sourceJoint);
552 - HipBalance1.SetActive(false);
553 - }
554 - else
555 - {
556 - hipbal = "양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!";
557 - HipBalance1.SetActive(true);
558 - }
559 510
560 - if (ReadAngles[5] > 95 || ReadAngles[6] > 95) 511 + //Debug.Log(i);
561 - {
562 - pullhipback = "엉덩이를 뒤로 더 빼세요!";
563 - PullHipBack2.SetActive(true);
564 - }
565 - else
566 - {
567 - PullHipBack2.SetActive(false);
568 - }
569 512
570 - if (ReadAngles[3] < 95 && ReadAngles[4] < 95) 513 + i++;
571 - { 514 + data1[i] = sourceJoint.Position.X;
572 - great = "GREAT!"; 515 + i++;
573 - //Debug.Log(ReadAngles[3]); 516 + data1[i] = sourceJoint.Position.Y;
574 - Great5.SetActive(true); 517 + i++;
575 - } 518 + data1[i] = sourceJoint.Position.Z;
576 - else 519 + if ((sourceJoint.Position.X + sourceJoint.Position.Y + sourceJoint.Position.Z) != 0)
577 - { 520 + {
578 - great = ""; 521 + state[i - 2] = 1;
579 - Great5.SetActive(false); 522 + }
580 - } 523 + skeleton_Trainnne.dasomset(data1, state, 0, true, true, body.Joints[jt], jointObj);
581 524
582 - ////////////운동 횟수 카운트////////////////////// 525 + /*
583 - if (ReadAngles[3] < 95 && ReadAngles[4] < 95 && workout 526 + LineRenderer lr = jointObj.GetComponent<LineRenderer>();
584 - && workout_flag >= 95 && workout_flag2 >= 95) 527 + if (targetJoint.HasValue)
585 - { 528 + {
586 - Trainee_Count(); 529 + //Debug.Log(jointObj.localPosition);
587 - } 530 + //Debug.Log(GetVector3FromJoint(targetJoint.Value));
588 - else 531 + lr.SetPosition(0, jointObj.localPosition);
589 - { 532 + lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
590 - workout_flag = ReadAngles[3]; 533 + lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
591 - workout_flag2 = ReadAngles[4]; 534 + }
592 - workout = true; 535 + else
593 - } 536 + {
537 + lr.enabled = false;
538 + }
539 + */
540 + }
541 +
542 + ///////////////////////////
543 + Angles MyAngles = new Angles();
544 + byte[] ReadAngles = MyAngles.GetVector(body);
594 545
546 + if (exercise == "Squat")
547 + {
548 + if (ReadAngles[1] - ReadAngles[2] <= 5)
549 + {
550 + HipBalance1.SetActive(false);
595 } 551 }
596 - else if (exercise == "SideHiKick") 552 + else
597 { 553 {
598 - if ((ReadAngles[7] < 45) && (ReadAngles[7] > 10) 554 + //"양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!";
599 - && (sidehk_flag < ReadAngles[7])) 555 + HipBalance1.SetActive(true);
600 - { 556 + }
601 - LegUp3.SetActive(true); //다리를 더 높이 들어올리세요
602 - Great5.SetActive(false);
603 557
604 - } 558 + if (ReadAngles[5] > 95 || ReadAngles[6] > 95)
605 - else 559 + {
606 - { 560 + //"엉덩이를 뒤로 더 빼세요!";
607 - LegUp3.SetActive(false); 561 + PullHipBack2.SetActive(true);
608 - Great5.SetActive(false); 562 + }
563 + else
564 + {
565 + PullHipBack2.SetActive(false);
566 + }
567 +
568 + if (ReadAngles[3] < 95 && ReadAngles[4] < 95)
569 + {
570 + Great5.SetActive(true);
571 + }
572 + else
573 + {
574 + great = "";
575 + Great5.SetActive(false);
576 + }
577 +
578 + ////////////운동 횟수 카운트//////////////////////
579 + if (ReadAngles[3] < 95 && ReadAngles[4] < 95 && workout
580 + && workout_flag >= 95 && workout_flag2 >= 95)
581 + {
582 + Trainee_Count();
583 + }
584 + else
585 + {
586 + workout_flag = ReadAngles[3];
587 + workout_flag2 = ReadAngles[4];
588 + workout = true;
589 + }
590 +
591 + }
592 + else if (exercise == "SideHiKick")
593 + {
594 + if ((ReadAngles[7] < 45) && (ReadAngles[7] > 10)
595 + && (sidehk_flag < ReadAngles[7]))
596 + {
597 + LegUp3.SetActive(true); //다리를 더 높이 들어올리세요
598 + Great5.SetActive(false);
599 +
600 + }
601 + else
602 + {
603 + LegUp3.SetActive(false);
604 + Great5.SetActive(false);
605 +
606 + //이전각도
607 + sidehk_flag = ReadAngles[7];
608 + }
609 +
610 + if (ReadAngles[7] >= 45)
611 + {
612 + Great5.SetActive(true); //Great
613 + }
614 + else
615 + {
616 + Great5.SetActive(false);
617 + }
618 +
619 + ////////운동 횟수 카운트////////////////////
620 + if (ReadAngles[7] > 45 && workout && workout_flag <= 45)
621 + {
622 + Trainee_Count();
623 + }
624 + else
625 + {
626 + workout_flag = ReadAngles[7];
627 + workout = true;
628 + }
609 629
610 - //이전각도
611 - sidehk_flag = ReadAngles[7];
612 - }
613 630
614 - if (ReadAngles[7] >= 45) 631 +
632 + }
633 + else if (exercise == "Lunge")
634 + {
635 + if (workout_count < 10)
636 + {
637 + if (flag == 0)
615 { 638 {
616 - Great5.SetActive(true); //Great 639 + if (lunge_flag_l < 120 && ReadAngles[3] >= 91 && lunge_flag_l > ReadAngles[3])
640 + {
641 + great = "";
642 + //Great5.SetActive(false);
643 + KneeDown6.SetActive(true); //무릎을 더 굽혀주세요.
644 + flag = 1;
645 +
646 + }
647 + else if (ReadAngles[3] < 91)
648 + {
649 + great = "GREAT!";
650 + Great5.SetActive(true);
651 + //KneeDown6.SetActive(false);
652 +
653 + flag = 1;
654 + }
617 } 655 }
618 else 656 else
619 { 657 {
620 - Great5.SetActive(false); 658 +
659 + flag_timer += Time.deltaTime;
660 + //Debug.Log(flag_timer);
661 + if (flag_timer > 5)
662 + {
663 + flag = 0;
664 + flag_timer = 0;
665 + Debug.Log("5초넘음");
666 +
667 + Great5.SetActive(false);
668 + KneeDown6.SetActive(false);
669 + }
621 } 670 }
622 671
623 - ////////운동 횟수 카운트//////////////////// 672 +
624 - if (ReadAngles[7] > 45 && workout && workout_flag <= 45) 673 + //////////////운동 횟수 카운트//////////////////
674 + //왼쪽
675 + if (ReadAngles[3] < 95 && workout && workout_flag >= 95)
625 { 676 {
626 Trainee_Count(); 677 Trainee_Count();
627 } 678 }
628 else 679 else
629 { 680 {
630 - workout_flag = ReadAngles[7]; 681 + workout_flag = ReadAngles[3];
631 workout = true; 682 workout = true;
632 } 683 }
633 -
634 -
635 -
636 } 684 }
637 - else if (exercise == "Lunge") 685 + else
638 { 686 {
639 - if (workout_count < 10) 687 + if (flag == 0)
640 { 688 {
641 - if (flag == 0) 689 + if (lunge_flag_r < 120 && ReadAngles[4] >= 91 && lunge_flag_r > ReadAngles[4])
642 { 690 {
643 - if (lunge_flag_l < 120 && ReadAngles[3] >= 91 && lunge_flag_l > ReadAngles[3]) 691 + great = "";
644 - { 692 + //Great5.SetActive(false);
645 - great = ""; 693 + KneeDown6.SetActive(true); //무릎을 더 굽혀주세요.
646 - //Great5.SetActive(false); 694 + flag = 1;
647 - KneeDown6.SetActive(true); //무릎을 더 굽혀주세요.
648 - flag = 1;
649 -
650 - }
651 - else if (ReadAngles[3] < 91)
652 - {
653 - great = "GREAT!";
654 - Great5.SetActive(true);
655 - //KneeDown6.SetActive(false);
656 -
657 - flag = 1;
658 - }
659 - }
660 - else {
661 -
662 - flag_timer += Time.deltaTime;
663 - //Debug.Log(flag_timer);
664 - if (flag_timer > 50) {
665 - flag = 0;
666 - flag_timer = 0;
667 - Debug.Log("5초넘음");
668 -
669 - Great5.SetActive(false);
670 - KneeDown6.SetActive(false);
671 - }
672 - }
673 -
674 695
675 - //////////////운동 횟수 카운트//////////////////
676 - //왼쪽
677 - if (ReadAngles[3] < 95 && workout && workout_flag >= 95)
678 - {
679 - Trainee_Count();
680 } 696 }
681 - else 697 + else if (ReadAngles[4] < 91)
682 - {
683 - workout_flag = ReadAngles[3];
684 - workout = true;
685 - }
686 - }
687 - else {
688 - if (flag == 0)
689 - {
690 - if (lunge_flag_r < 120 && ReadAngles[4] >= 91 && lunge_flag_r > ReadAngles[4])
691 - {
692 - great = "";
693 - //Great5.SetActive(false);
694 - KneeDown6.SetActive(true); //무릎을 더 굽혀주세요.
695 - flag = 1;
696 -
697 - }
698 - else if (ReadAngles[4] < 91)
699 - {
700 - great = "GREAT!";
701 - Great5.SetActive(true);
702 - //KneeDown6.SetActive(false);
703 -
704 - flag = 1;
705 - }
706 - }
707 - else
708 { 698 {
699 + great = "GREAT!";
700 + Great5.SetActive(true);
701 + //KneeDown6.SetActive(false);
709 702
710 - flag_timer += Time.deltaTime; 703 + flag = 1;
711 - //Debug.Log(flag_timer);
712 - if (flag_timer > 50)
713 - {
714 - flag = 0;
715 - flag_timer = 0;
716 - Debug.Log("5초넘음");
717 -
718 - Great5.SetActive(false);
719 - KneeDown6.SetActive(false);
720 - }
721 } 704 }
705 + }
706 + else
707 + {
722 708
723 - //////////////운동 횟수 카운트////////////////// 709 + flag_timer += Time.deltaTime;
724 - //오른쪽 710 + //Debug.Log(flag_timer);
725 - if (workout_count >= 10 && ReadAngles[4] < 95 && workout && workout_flag >= 95) 711 + if (flag_timer > 5)
726 { 712 {
727 - Trainee_Count(); 713 + flag = 0;
728 - } 714 + flag_timer = 0;
729 - else 715 + Debug.Log("5초넘음");
730 - { 716 +
731 - workout_flag = ReadAngles[4]; 717 + Great5.SetActive(false);
732 - workout = true; 718 + KneeDown6.SetActive(false);
733 } 719 }
734 } 720 }
735 721
736 - 722 + //////////////운동 횟수 카운트//////////////////
737 - lunge_flag_l = ReadAngles[3]; 723 + //오른쪽
738 - lunge_flag_r = ReadAngles[4]; 724 + if (workout_count >= 10 && ReadAngles[4] < 95 && workout && workout_flag >= 95)
739 - } 725 + {
740 - 726 + Trainee_Count();
741 - //공통된 사항 727 + }
742 - if (ReadAngles[0] < 170 || ReadAngles[0] > 190) 728 + else
743 - { 729 + {
744 - spinestraight = "허리를 곧게 펴세요!"; 730 + workout_flag = ReadAngles[4];
745 - SpineStraight4.SetActive(true); 731 + workout = true;
746 - } 732 + }
747 - else
748 - {
749 - spinestraight = "";
750 - SpineStraight4.SetActive(false);
751 - }
752 -
753 -
754 - ///////////////////////////
755 -
756 - if (_BoneMap.ContainsKey(jt))
757 - {
758 - targetJoint = body.Joints[_BoneMap[jt]];
759 } 733 }
760 - Transform jointObj = bodyObject.transform.Find(jt.ToString());
761 - jointObj.localPosition = GetVector3FromJoint(sourceJoint);
762 734
763 - //Debug.Log(i);
764 735
765 - i++; 736 + lunge_flag_l = ReadAngles[3];
766 - data1[i] = sourceJoint.Position.X; 737 + lunge_flag_r = ReadAngles[4];
767 - i++; 738 + }
768 - data1[i] = sourceJoint.Position.Y;
769 - i++;
770 - data1[i] = sourceJoint.Position.Z;
771 - if ((sourceJoint.Position.X + sourceJoint.Position.Y + sourceJoint.Position.Z) != 0)
772 - {
773 - state[i - 2] = 1;
774 - }
775 - skeleton_Trainnne.dasomset(data1, state, 0, true, true, body.Joints[jt], jointObj);
776 739
777 - /* 740 + //공통된 사항
778 - LineRenderer lr = jointObj.GetComponent<LineRenderer>(); 741 + if (ReadAngles[0] < 170 || ReadAngles[0] > 190)
779 - if (targetJoint.HasValue) 742 + {
780 - { 743 + spinestraight = "허리를 곧게 펴세요!";
781 - //Debug.Log(jointObj.localPosition); 744 + SpineStraight4.SetActive(true);
782 - //Debug.Log(GetVector3FromJoint(targetJoint.Value)); 745 + }
783 - lr.SetPosition(0, jointObj.localPosition); 746 + else
784 - lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value)); 747 + {
785 - lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState)); 748 + spinestraight = "";
786 - } 749 + SpineStraight4.SetActive(false);
787 - else
788 - {
789 - lr.enabled = false;
790 - }
791 - */
792 } 750 }
751 +
752 + ///////////////////////////
793 } 753 }
794 754
795 private static Color GetColorForState(Kinect.TrackingState state) 755 private static Color GetColorForState(Kinect.TrackingState state)
......