Showing
1 changed file
with
114 additions
and
39 deletions
... | @@ -40,6 +40,11 @@ public class Move : MonoBehaviour | ... | @@ -40,6 +40,11 @@ public class Move : MonoBehaviour |
40 | public int[] trainer_state; | 40 | public int[] trainer_state; |
41 | public int speed = 0; | 41 | public int speed = 0; |
42 | public int trainer_count = 0; | 42 | public int trainer_count = 0; |
43 | + public bool trainer_check = true; | ||
44 | + public bool trainer_check_outside = true; | ||
45 | + public float trainer_timer = 0; | ||
46 | + public bool trainer_other_side = false; | ||
47 | + public int trainer_speed = 5; | ||
43 | //lsy end | 48 | //lsy end |
44 | 49 | ||
45 | public Text AngleLeftKnee; | 50 | public Text AngleLeftKnee; |
... | @@ -53,7 +58,7 @@ public class Move : MonoBehaviour | ... | @@ -53,7 +58,7 @@ public class Move : MonoBehaviour |
53 | public Text HipBalance; | 58 | public Text HipBalance; |
54 | public Text PullHipBack; | 59 | public Text PullHipBack; |
55 | public Text Great; | 60 | public Text Great; |
56 | - | 61 | + |
57 | string hipbal, leftkneewarning, rightkneewarning, leftsidehighkick, rightsidehighkick; | 62 | string hipbal, leftkneewarning, rightkneewarning, leftsidehighkick, rightsidehighkick; |
58 | string spinestraight, pullhipback, great; | 63 | string spinestraight, pullhipback, great; |
59 | 64 | ||
... | @@ -71,79 +76,141 @@ public class Move : MonoBehaviour | ... | @@ -71,79 +76,141 @@ public class Move : MonoBehaviour |
71 | //lsy | 76 | //lsy |
72 | void Trainer_Run() | 77 | void Trainer_Run() |
73 | { | 78 | { |
79 | + if (!trainer_check)//운동 끝났을 때 | ||
80 | + { | ||
81 | + trainer_timer += Time.deltaTime; | ||
82 | + if (trainer_timer > 3) | ||
83 | + { | ||
84 | + Debug.Log("3초 됨 운동 끝!!!!!"); //결과씬이나 다른씬으로 | ||
85 | + trainer_check_outside = false; | ||
86 | + } | ||
87 | + return; | ||
88 | + } | ||
74 | //Thread.Sleep(50); | 89 | //Thread.Sleep(50); |
75 | if (trainer_j >= lines.Length - 3) | 90 | if (trainer_j >= lines.Length - 3) |
76 | { | 91 | { |
77 | - trainer_count++; | 92 | + if (trainer_count < 20 && exercise == "Squat") |
78 | - Debug.Log("카운트 : " + trainer_count); | 93 | + { |
94 | + trainer_count++; | ||
95 | + Debug.Log("카운트 : " + trainer_count); | ||
96 | + } | ||
97 | + if (trainer_count < 10 && exercise == "SideHiKick") | ||
98 | + { | ||
99 | + trainer_count++; | ||
100 | + Debug.Log("카운트 : " + trainer_count); | ||
101 | + } | ||
102 | + if (trainer_count < 10 && exercise == "Lunge") | ||
103 | + { | ||
104 | + trainer_count++; | ||
105 | + Debug.Log("카운트 : " + trainer_count); | ||
106 | + } | ||
107 | + if (trainer_count >= 20 && exercise == "Squat") | ||
108 | + { | ||
109 | + trainer_check = false;//스쿼트일때 운동 끝나는 시점!!!!! | ||
110 | + } | ||
111 | + if (trainer_count >= 10 && exercise == "SideHiKick") | ||
112 | + { | ||
113 | + if (!trainer_other_side) | ||
114 | + { | ||
115 | + if (trainer_timer > 3) | ||
116 | + { | ||
117 | + trainer_count = 0; | ||
118 | + lines = lines_right; | ||
119 | + trainer_other_side = true; | ||
120 | + trainer_timer = 0; | ||
121 | + } | ||
122 | + else | ||
123 | + { | ||
124 | + trainer_timer += Time.deltaTime; | ||
125 | + return; | ||
126 | + } | ||
127 | + } | ||
128 | + else | ||
129 | + { | ||
130 | + trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!! | ||
131 | + } | ||
132 | + } | ||
133 | + if (trainer_count >= 10 && exercise == "Lunge") | ||
134 | + { | ||
135 | + if (!trainer_other_side) | ||
136 | + { | ||
137 | + if (trainer_timer > 3) | ||
138 | + { | ||
139 | + trainer_speed = 8; | ||
140 | + trainer_count = 0; | ||
141 | + lines = lines_right; | ||
142 | + trainer_other_side = true; | ||
143 | + trainer_timer = 0; | ||
144 | + } | ||
145 | + else | ||
146 | + { | ||
147 | + trainer_timer += Time.deltaTime; | ||
148 | + return; | ||
149 | + } | ||
150 | + } | ||
151 | + else | ||
152 | + { | ||
153 | + trainer_check = false;//사이드하이킥일때 운동 끝나는 시점!!!!! | ||
154 | + } | ||
155 | + } | ||
79 | trainer_j = 0; | 156 | trainer_j = 0; |
80 | return; | 157 | return; |
81 | } | 158 | } |
82 | trainer_i = -1; | 159 | trainer_i = -1; |
83 | trainer_data1 = new float[bodyCount * jointCount * 3]; | 160 | trainer_data1 = new float[bodyCount * jointCount * 3]; |
84 | trainer_state = new int[bodyCount * jointCount]; | 161 | trainer_state = new int[bodyCount * jointCount]; |
85 | - //Debug.Log("초기화"); | ||
86 | - //Thread.Sleep(5000); | ||
87 | for (int k = 0; k < 25; k++) | 162 | for (int k = 0; k < 25; k++) |
88 | { | 163 | { |
89 | - //Debug.Log("trainer_j: " + trainer_j); | ||
90 | - //Debug.Log("test1"); | ||
91 | - //Debug.Log(lines[trainer_j]); | ||
92 | - | ||
93 | trainer_i++; | 164 | trainer_i++; |
94 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j]); | 165 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j]); |
95 | - //Debug.Log("test2" + trainer_i); | ||
96 | trainer_i++; | 166 | trainer_i++; |
97 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 1]); | 167 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 1]); |
98 | - //Debug.Log("test3" + trainer_i); | ||
99 | trainer_i++; | 168 | trainer_i++; |
100 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 2]); | 169 | trainer_data1[trainer_i] = float.Parse(lines[trainer_j + 2]); |
101 | - //Debug.Log("test4" + trainer_i); | ||
102 | if ((float.Parse(lines[trainer_j]) + float.Parse(lines[trainer_j + 1]) + float.Parse(lines[trainer_j + 2])) != 0) | 170 | if ((float.Parse(lines[trainer_j]) + float.Parse(lines[trainer_j + 1]) + float.Parse(lines[trainer_j + 2])) != 0) |
103 | { | 171 | { |
104 | trainer_state[trainer_i - 2] = 1; | 172 | trainer_state[trainer_i - 2] = 1; |
105 | } | 173 | } |
106 | - //Debug.Log("test4-1"); | ||
107 | skeleton_Trainnner.dasomset_trainer(trainer_data1, trainer_state, 0, true, true); | 174 | skeleton_Trainnner.dasomset_trainer(trainer_data1, trainer_state, 0, true, true); |
108 | - //Debug.Log("test5"); | ||
109 | - //Debug.Log(trainer_i); | ||
110 | - //Debug.Log("메모라인 : " + trainer_j); | ||
111 | trainer_j = trainer_j + 3; | 175 | trainer_j = trainer_j + 3; |
112 | } | 176 | } |
113 | - if (speed < 5) | 177 | + if (speed < trainer_speed) |
114 | { | 178 | { |
115 | trainer_j -= 75; | 179 | trainer_j -= 75; |
116 | speed++; | 180 | speed++; |
117 | } | 181 | } |
118 | else | 182 | else |
119 | { | 183 | { |
120 | - // Debug.Log("다음"); | 184 | + // Debug.Log("다음"); |
121 | - // Debug.Log(trainer_j); | 185 | + // Debug.Log(trainer_j); |
122 | speed = 0; | 186 | speed = 0; |
123 | 187 | ||
124 | } | 188 | } |
125 | - //Debug.Log("탈출!======================================================"); | ||
126 | } | 189 | } |
127 | //lsy end | 190 | //lsy end |
128 | 191 | ||
129 | - void Trainee_Count() { | 192 | + void Trainee_Count() |
193 | + { | ||
130 | 194 | ||
131 | - if (exercise == "Squat") { | 195 | + if (exercise == "Squat") |
196 | + { | ||
132 | 197 | ||
133 | workout_flag = 0; | 198 | workout_flag = 0; |
134 | workout_flag2 = 0; | 199 | workout_flag2 = 0; |
135 | } | 200 | } |
136 | - else if (exercise == "SideHiKick") { | 201 | + else if (exercise == "SideHiKick") |
202 | + { | ||
137 | workout_flag = 0; | 203 | workout_flag = 0; |
138 | 204 | ||
139 | } | 205 | } |
140 | - else if (exercise == "Lunge") { | 206 | + else if (exercise == "Lunge") |
207 | + { | ||
141 | workout_flag = 0; | 208 | workout_flag = 0; |
142 | } | 209 | } |
143 | 210 | ||
144 | workout_count++; | 211 | workout_count++; |
145 | workout = false; | 212 | workout = false; |
146 | - | 213 | + |
147 | } | 214 | } |
148 | 215 | ||
149 | void Start() | 216 | void Start() |
... | @@ -157,8 +224,9 @@ public class Move : MonoBehaviour | ... | @@ -157,8 +224,9 @@ public class Move : MonoBehaviour |
157 | trainer_state = new int[bodyCount * jointCount]; | 224 | trainer_state = new int[bodyCount * jointCount]; |
158 | trainer_data1 = new float[bodyCount * jointCount * 3]; | 225 | trainer_data1 = new float[bodyCount * jointCount * 3]; |
159 | //lsy end | 226 | //lsy end |
160 | - | 227 | + |
161 | exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴. | 228 | exercise = ClickExercise.selected_exercise; //ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴. |
229 | + exercise = "SideHiKick"; | ||
162 | Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기 | 230 | Debug.Log(exercise); //Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기 |
163 | 231 | ||
164 | if (exercise == "Squat") | 232 | if (exercise == "Squat") |
... | @@ -168,19 +236,20 @@ public class Move : MonoBehaviour | ... | @@ -168,19 +236,20 @@ public class Move : MonoBehaviour |
168 | } | 236 | } |
169 | else if (exercise == "SideHiKick") | 237 | else if (exercise == "SideHiKick") |
170 | { | 238 | { |
171 | - lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt"); | 239 | + lines = File.ReadAllLines(@"Trainer_txt/leg_right.txt"); |
172 | - lines_right = File.ReadAllLines(@"Trainer_txt/leg_right.txt"); | 240 | + lines_right = File.ReadAllLines(@"Trainer_txt/leg_left.txt"); |
173 | Debug.Log("읽음"); | 241 | Debug.Log("읽음"); |
174 | } | 242 | } |
175 | else if (exercise == "Lunge") | 243 | else if (exercise == "Lunge") |
176 | { | 244 | { |
177 | - lines = File.ReadAllLines(@"Trainer_txt/runzi_left.txt"); | 245 | + trainer_speed = 5; |
178 | - lines_right = File.ReadAllLines(@"Trainer_txt/runzi_right.txt"); | 246 | + lines = File.ReadAllLines(@"Trainer_txt/runzi_right.txt"); |
247 | + lines_right = File.ReadAllLines(@"Trainer_txt/runzi_left.txt"); | ||
179 | Debug.Log("읽음"); | 248 | Debug.Log("읽음"); |
180 | } | 249 | } |
181 | - else { | 250 | + else |
182 | - | 251 | + { |
183 | - lines = File.ReadAllLines(@"Trainer_txt/leg_left.txt"); | 252 | + lines = File.ReadAllLines(@"Trainer_txt/squart.txt"); |
184 | Debug.Log("읽음"); | 253 | Debug.Log("읽음"); |
185 | } | 254 | } |
186 | 255 | ||
... | @@ -249,7 +318,8 @@ public class Move : MonoBehaviour | ... | @@ -249,7 +318,8 @@ public class Move : MonoBehaviour |
249 | KneeDown6.SetActive(false); | 318 | KneeDown6.SetActive(false); |
250 | 319 | ||
251 | } | 320 | } |
252 | - else if (timer >= 1 && timer < 2) { | 321 | + else if (timer >= 1 && timer < 2) |
322 | + { | ||
253 | count3.SetActive(false); | 323 | count3.SetActive(false); |
254 | count2.SetActive(true); | 324 | count2.SetActive(true); |
255 | count1.SetActive(false); | 325 | count1.SetActive(false); |
... | @@ -286,10 +356,15 @@ public class Move : MonoBehaviour | ... | @@ -286,10 +356,15 @@ public class Move : MonoBehaviour |
286 | ex_start.SetActive(false); | 356 | ex_start.SetActive(false); |
287 | 357 | ||
288 | //lsy | 358 | //lsy |
289 | - Trainer_Run(); | 359 | + if (trainer_check_outside) |
360 | + { | ||
361 | + | ||
362 | + Trainer_Run(); | ||
363 | + | ||
364 | + } | ||
290 | //lsy end | 365 | //lsy end |
291 | 366 | ||
292 | - | 367 | + |
293 | IfSpineIsStraight.text = "허리를 곧게: Tracking"; | 368 | IfSpineIsStraight.text = "허리를 곧게: Tracking"; |
294 | HipBalance.text = "양쪽 힙 균형: Calculating"; | 369 | HipBalance.text = "양쪽 힙 균형: Calculating"; |
295 | AngleLeftKnee.text = ""; | 370 | AngleLeftKnee.text = ""; |
... | @@ -372,7 +447,7 @@ public class Move : MonoBehaviour | ... | @@ -372,7 +447,7 @@ public class Move : MonoBehaviour |
372 | } | 447 | } |
373 | } | 448 | } |
374 | } | 449 | } |
375 | - | 450 | + |
376 | } | 451 | } |
377 | 452 | ||
378 | private GameObject CreateBodyObject(ulong id) | 453 | private GameObject CreateBodyObject(ulong id) |
... | @@ -558,7 +633,7 @@ public class Move : MonoBehaviour | ... | @@ -558,7 +633,7 @@ public class Move : MonoBehaviour |
558 | SpineStraight4.SetActive(false); | 633 | SpineStraight4.SetActive(false); |
559 | } | 634 | } |
560 | 635 | ||
561 | - | 636 | + |
562 | /////////////////////////// | 637 | /////////////////////////// |
563 | 638 | ||
564 | if (_BoneMap.ContainsKey(jt)) | 639 | if (_BoneMap.ContainsKey(jt)) |
... | @@ -665,7 +740,7 @@ public class Move : MonoBehaviour | ... | @@ -665,7 +740,7 @@ public class Move : MonoBehaviour |
665 | double AngleLeftKnee = AngleBetweenTwoVectors(HipLeft - KneeLeft, AnkleLeft - KneeLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 | 740 | double AngleLeftKnee = AngleBetweenTwoVectors(HipLeft - KneeLeft, AnkleLeft - KneeLeft); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 |
666 | //double AngleRightKnee = AngleBetweenTwoVectors(KneeRight - HipRight, KneeRight - AnkleRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 | 741 | //double AngleRightKnee = AngleBetweenTwoVectors(KneeRight - HipRight, KneeRight - AnkleRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 |
667 | double AngleRightKnee = AngleBetweenTwoVectors(HipRight - KneeRight, AnkleRight - KneeRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 | 742 | double AngleRightKnee = AngleBetweenTwoVectors(HipRight - KneeRight, AnkleRight - KneeRight); //스쿼트, 런지, 사이드하이킥 - Joint 3개로도 가능 |
668 | - | 743 | + |
669 | double KneeToeLeft = AngleBetweenTwoVectors(AnkleLeft - FootLeft, KneeLeft - FootLeft); //스쿼트 - Joint 3개로도 가능 | 744 | double KneeToeLeft = AngleBetweenTwoVectors(AnkleLeft - FootLeft, KneeLeft - FootLeft); //스쿼트 - Joint 3개로도 가능 |
670 | double KneeToeRight = AngleBetweenTwoVectors(AnkleRight - FootRight, KneeRight - FootRight); //스쿼트 - Joint 3개로도 가능 | 745 | double KneeToeRight = AngleBetweenTwoVectors(AnkleRight - FootRight, KneeRight - FootRight); //스쿼트 - Joint 3개로도 가능 |
671 | //double LeftLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeLeft - HipLeft); //사이드 하이킥 | 746 | //double LeftLegUp = AngleBetweenTwoVectors(SpineMid - SpineShoulder, KneeLeft - HipLeft); //사이드 하이킥 | ... | ... |
-
Please register or login to post a comment