고다경

humanoid scene 게임시작 타이머 설정, 운동 각도에 따른 뷰 구현

......@@ -209,7 +209,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &64300835
RectTransform:
m_ObjectHideFlags: 0
......@@ -379,7 +379,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &109009051
RectTransform:
m_ObjectHideFlags: 0
......@@ -450,7 +450,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &132265373
RectTransform:
m_ObjectHideFlags: 0
......@@ -701,7 +701,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &310358199
RectTransform:
m_ObjectHideFlags: 0
......@@ -709,16 +709,16 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 310358198}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0.3420201, w: 0.9396927}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1679758666}
m_RootOrder: 18
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 40}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 330, y: 150}
m_AnchoredPosition: {x: 290, y: 100}
m_SizeDelta: {x: 250, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &310358200
......@@ -772,7 +772,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &395084096
RectTransform:
m_ObjectHideFlags: 0
......@@ -843,7 +843,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &469119555
RectTransform:
m_ObjectHideFlags: 0
......@@ -988,7 +988,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &618891444
RectTransform:
m_ObjectHideFlags: 0
......@@ -1066,7 +1066,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &687225090
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -1144,7 +1144,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &883974734
RectTransform:
m_ObjectHideFlags: 0
......@@ -1293,7 +1293,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1089006721
RectTransform:
m_ObjectHideFlags: 0
......@@ -1310,7 +1310,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 330, y: 150}
m_AnchoredPosition: {x: 330, y: 200}
m_SizeDelta: {x: 250, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1089006722
......@@ -1526,7 +1526,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1313906996
RectTransform:
m_ObjectHideFlags: 0
......@@ -1750,6 +1750,15 @@ MonoBehaviour:
HipBalance: {fileID: 64300837}
PullHipBack: {fileID: 469119556}
Great: {fileID: 1784424919}
count3: {fileID: 1983785836}
count2: {fileID: 132265372}
count1: {fileID: 1606945878}
HipBalance1: {fileID: 395084095}
PullHipBack2: {fileID: 109009050}
LegUp3: {fileID: 1484596775}
SpineStraight4: {fileID: 1089006720}
Great5: {fileID: 310358198}
ex_start: {fileID: 0}
--- !u!4 &1461362268
Transform:
m_ObjectHideFlags: 0
......@@ -1781,7 +1790,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1484596776
RectTransform:
m_ObjectHideFlags: 0
......@@ -1852,7 +1861,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1493856867
RectTransform:
m_ObjectHideFlags: 0
......@@ -1930,7 +1939,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1543390837
RectTransform:
m_ObjectHideFlags: 0
......@@ -2008,7 +2017,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1606945879
RectTransform:
m_ObjectHideFlags: 0
......@@ -2353,7 +2362,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1723072948
RectTransform:
m_ObjectHideFlags: 0
......@@ -2608,7 +2617,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &1983785837
RectTransform:
m_ObjectHideFlags: 0
......@@ -2679,7 +2688,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &2059169296
RectTransform:
m_ObjectHideFlags: 0
......
......@@ -55,6 +55,14 @@ public class Move : MonoBehaviour
string spinestraight, pullhipback, great;
string exercise;
int squat_flag, squat_count;
private float timer;
public GameObject count3;
public GameObject count2;
public GameObject count1;
public GameObject HipBalance1, PullHipBack2, LegUp3, SpineStraight4, Great5;
public GameObject ex_start;
//lsy
void Trainer_Run()
......@@ -101,6 +109,8 @@ public class Move : MonoBehaviour
void Start()
{
timer = 0;
skeleton_Trainnner = new CharacterSkeleton(Trainnner);
skeleton_Trainnne = new CharacterSkeleton(Trainnne);
......@@ -113,6 +123,15 @@ public class Move : MonoBehaviour
exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
squat_count = 0;
squat_flag = 0;
HipBalance1.SetActive(false);
PullHipBack2.SetActive(false);
LegUp3.SetActive(false);
SpineStraight4.SetActive(false);
Great5.SetActive(false);
}
private Dictionary<Kinect.JointType, Kinect.JointType> _BoneMap = new Dictionary<Kinect.JointType, Kinect.JointType>()
......@@ -149,6 +168,54 @@ public class Move : MonoBehaviour
void Update()
{
timer += Time.deltaTime;
Debug.Log("Timer: " + timer);
if (timer < 1)
{
count3.SetActive(true);
count2.SetActive(false);
count1.SetActive(false);
ex_start.SetActive(true);
HipBalance1.SetActive(false);
PullHipBack2.SetActive(false);
LegUp3.SetActive(false);
SpineStraight4.SetActive(false);
Great5.SetActive(false);
}
else if (timer >= 1 && timer < 2) {
count3.SetActive(false);
count2.SetActive(true);
count1.SetActive(false);
ex_start.SetActive(true);
HipBalance1.SetActive(false);
PullHipBack2.SetActive(false);
LegUp3.SetActive(false);
SpineStraight4.SetActive(false);
Great5.SetActive(false);
}
else if (timer >= 2 && timer < 3)
{
count3.SetActive(false);
count2.SetActive(false);
count1.SetActive(true);
ex_start.SetActive(true);
HipBalance1.SetActive(false);
PullHipBack2.SetActive(false);
LegUp3.SetActive(false);
SpineStraight4.SetActive(false);
Great5.SetActive(false);
}
else
{
count3.SetActive(false);
count2.SetActive(false);
count1.SetActive(false);
ex_start.SetActive(false);
//lsy
Trainer_Run();
//lsy end
......@@ -237,6 +304,8 @@ public class Move : MonoBehaviour
}
}
}
private GameObject CreateBodyObject(ulong id)
{
......@@ -277,74 +346,102 @@ public class Move : MonoBehaviour
///////////////////////////
Angles MyAngles = new Angles();
byte[] ReadAngles = MyAngles.GetVector(body);
// ReadAngles[0].ToString();
//Debug.Log("HipLeft " + ReadAngles[1].ToString());
//Debug.Log("HipRight " + ReadAngles[2].ToString());
//Debug.Log("KneeLeft " + ReadAngles[3].ToString());
//Debug.Log("KneeRight " + ReadAngles[4].ToString());
if (exercise == "Squat")
{
if (ReadAngles[1] - ReadAngles[2] <= 5)
{
hipbal = "";
//hipbal = "양쪽 균형이 잡혀있습니다.";
HipBalance1.SetActive(false);
}
else
{
hipbal = "양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!";
HipBalance1.SetActive(true);
}
if (ReadAngles[5] > 90)
if (ReadAngles[5] > 95 || ReadAngles[6] > 95)
{
//leftkneewarning = "왼쪽 무릎이 발끝을 넘어갔습니다.";
pullhipback = "엉덩이를 뒤로 더 빼세요!";
PullHipBack2.SetActive(true);
}
else
{
leftkneewarning = "";
PullHipBack2.SetActive(false);
}
if (ReadAngles[6] > 90)
if (ReadAngles[3] < 95 && ReadAngles[4] < 95)
{
//rightkneewarning = "오른쪽 무릎이 발끝을 넘어갔습니다.";
pullhipback = "엉덩이를 뒤로 더 빼세요!";
great = "GREAT!";
Debug.Log(ReadAngles[3]);
Great5.SetActive(true);
}
else
{
rightkneewarning = "";
great = "";
Great5.SetActive(false);
}
}
else if (exercise == "SideHiKick")
{
if (ReadAngles[7] < 45)
if (ReadAngles[7] < 40 || ReadAngles[8] < 40)
{
leftsidehighkick = "왼쪽 다리를 좀 더 높이 들어올리세요";
Debug.Log(ReadAngles[7] + " , " + ReadAngles[8]); //7,8 동일함
LegUp3.SetActive(true); //다리를 더 높이 들어올리세요
Great5.SetActive(false);
}
else if (ReadAngles[7] <= 5)
{
LegUp3.SetActive(false);
}
else
{
leftsidehighkick = "";
LegUp3.SetActive(false);
}
if (ReadAngles[8] < 45)
if (ReadAngles[7] >= 40)
{
rightsidehighkick = "오른쪽 다리를 좀 더 높이 들어올리세요";
Great5.SetActive(true); //Great
}
else
else if (ReadAngles[8] >= 40)
{
rightsidehighkick = "";
}
Great5.SetActive(true); //Great
if (ReadAngles[0] < 170 || ReadAngles[0] > 190)
}
else
{
spinestraight = "허리를 곧게 펴세요!";
Great5.SetActive(false);
}
else {
spinestraight = "";
}
else if (exercise == "Lunge")
{
if (ReadAngles[3] < 100 || ReadAngles[4] < 100)
if (ReadAngles[3] < 95 || ReadAngles[4] < 95)
{
great = "GREAT!";
Great5.SetActive(true);
}
else {
else
{
great = "";
Great5.SetActive(false);
}
}
//공통된 사항
if (ReadAngles[0] < 170 || ReadAngles[0] > 190)
{
spinestraight = "허리를 곧게 펴세요!";
SpineStraight4.SetActive(true);
}
else
{
spinestraight = "";
SpineStraight4.SetActive(false);
}
IfSpineIsStraight.text =spinestraight;
......@@ -466,13 +563,18 @@ public class Move : MonoBehaviour
double AngleLeftHip = AngleBetweenTwoVectors(SpineBase - SpineShoulder, HipLeft - KneeLeft); //스쿼트, 런지
double AngleRightHip = AngleBetweenTwoVectors(SpineBase - SpineShoulder, HipRight - KneeRight); //스쿼트, 런지
double AngleLeftKnee = AngleBetweenTwoVectors(KneeLeft - HipLeft, KneeLeft - AnkleLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double AngleRightKnee = AngleBetweenTwoVectors(KneeRight - HipRight, KneeRight - AnkleRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
//double AngleLeftKnee = AngleBetweenTwoVectors(KneeLeft - HipLeft, KneeLeft - AnkleLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double AngleLeftKnee = AngleBetweenTwoVectors(HipLeft - KneeLeft, AnkleLeft - KneeLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
//double AngleRightKnee = AngleBetweenTwoVectors(KneeRight - HipRight, KneeRight - AnkleRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double AngleRightKnee = AngleBetweenTwoVectors(HipRight - KneeRight, AnkleRight - KneeRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능
double KneeToeLeft = AngleBetweenTwoVectors(AnkleLeft - FootLeft, KneeLeft - FootLeft); //스쿼트 - Joint 3개로도 가능
double KneeToeRight = AngleBetweenTwoVectors(AnkleRight - FootRight, KneeRight - FootRight); //스쿼트 - Joint 3개로도 가능
double LeftLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeLeft - HipLeft); //사이드 하이킥
double RightLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeRight - HipRight); //사이드 하이킥
//double LeftLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeLeft - HipLeft); //사이드 하이킥
//double RightLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeRight - HipRight); //사이드 하이킥
double LeftLegUp = AngleBetweenTwoVectors(KneeRight - HipRight, KneeLeft - HipLeft); //사이드 하이킥
double RightLegUp = AngleBetweenTwoVectors(KneeLeft - HipLeft, KneeRight - HipRight); //사이드 하이킥
//LeftLegUp이랑 RightLegUp이랑 각도 동일
byte[] Angles = { Convert.ToByte(StraightSpine),
......