Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
LSK_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고다경
2020-06-19 02:26:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25bc71f3e0690fddce972a3c4b4b3efcdf0bc119
25bc71f3
1 parent
86d77896
트레이너 속도 조절
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
93 deletions
sourcecode/capstone/Assets/Scenes/humanoid.unity
sourcecode/capstone/Assets/Script/Move.cs
sourcecode/capstone/Assets/Scenes/humanoid.unity
View file @
25bc71f
...
...
@@ -2141,7 +2141,7 @@ MonoBehaviour:
SideHighKick_Instruction
:
{
fileID
:
1616699126
}
Lunge_Left_Instruction
:
{
fileID
:
1914474766
}
Lunge_Right_Instruction
:
{
fileID
:
1540314533
}
Right_Start
:
{
fileID
:
0
}
Right_Start
:
{
fileID
:
779933557
}
---
!u!4
&1461362268
Transform
:
m_ObjectHideFlags
:
0
...
...
sourcecode/capstone/Assets/Script/Move.cs
View file @
25bc71f
...
...
@@ -44,7 +44,7 @@ public class Move : MonoBehaviour
public
bool
trainer_check_outside
=
true
;
public
float
trainer_timer
=
0
;
public
bool
trainer_other_side
=
false
;
public
int
trainer_speed
=
5
;
public
int
trainer_speed
=
0
;
//lsy end
public
Text
AngleLeftKnee
;
...
...
@@ -149,7 +149,7 @@ public class Move : MonoBehaviour
{
Lunge_Right_Instruction
.
SetActive
(
false
);
trainer_speed
=
8
;
trainer_speed
=
7
;
trainer_count
=
0
;
lines
=
lines_right
;
trainer_other_side
=
true
;
...
...
@@ -242,7 +242,7 @@ public class Move : MonoBehaviour
//lsy end
exercise
=
ClickExercise
.
selected_exercise
;
//ClickExercise에서 선택한 운동이 무엇인지 String으로 넘어옴.
exercise
=
"
Squat
"
;
exercise
=
"
Lunge
"
;
Debug
.
Log
(
exercise
);
//Squat, SideHiKick, Lunge 에 따라서 Trainer움직이고, 사용자에게 instruction주기
if
(
exercise
==
"Squat"
)
...
...
@@ -258,7 +258,6 @@ public class Move : MonoBehaviour
}
else
if
(
exercise
==
"Lunge"
)
{
trainer_speed
=
5
;
lines
=
File
.
ReadAllLines
(
@"Trainer_txt/runzi_right.txt"
);
lines_right
=
File
.
ReadAllLines
(
@"Trainer_txt/runzi_left.txt"
);
Debug
.
Log
(
"읽음"
);
...
...
@@ -364,47 +363,21 @@ public class Move : MonoBehaviour
count1
.
SetActive
(
false
);
ex_start
.
SetActive
(
true
);
HipBalance1
.
SetActive
(
false
);
PullHipBack2
.
SetActive
(
false
);
LegUp3
.
SetActive
(
false
);
SpineStraight4
.
SetActive
(
false
);
Great5
.
SetActive
(
false
);
KneeDown6
.
SetActive
(
false
);
}
else
if
(
timer
<
5
)
{
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
);
KneeDown6
.
SetActive
(
false
);
}
else
if
(
timer
<
6
)
{
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
);
KneeDown6
.
SetActive
(
false
);
}
else
{
count3
.
SetActive
(
false
);
count2
.
SetActive
(
false
);
count1
.
SetActive
(
false
);
ex_start
.
SetActive
(
false
);
...
...
@@ -417,19 +390,6 @@ public class Move : MonoBehaviour
}
//lsy end
IfSpineIsStraight
.
text
=
"허리를 곧게: Tracking"
;
HipBalance
.
text
=
"양쪽 힙 균형: Calculating"
;
AngleLeftKnee
.
text
=
""
;
AngleRightKnee
.
text
=
""
;
KneeToeLeft
.
text
=
""
;
KneeToeRight
.
text
=
""
;
LeftLegUp
.
text
=
"왼쪽 다리 들어올린 각도: Tracking"
;
RightLegUp
.
text
=
"오른쪽 다리 들어올린 각도: Tracking"
;
PullHipBack
.
text
=
""
;
Great
.
text
=
""
;
float
[]
data1
=
new
float
[
bodyCount
*
jointCount
*
3
];
int
[]
state
=
new
int
[
bodyCount
*
jointCount
];
int
[]
id
=
new
int
[
bodyCount
];
...
...
@@ -539,6 +499,46 @@ public class Move : MonoBehaviour
Kinect
.
Joint
sourceJoint
=
body
.
Joints
[
jt
];
Kinect
.
Joint
?
targetJoint
=
null
;
if
(
_BoneMap
.
ContainsKey
(
jt
))
{
targetJoint
=
body
.
Joints
[
_BoneMap
[
jt
]];
}
Transform
jointObj
=
bodyObject
.
transform
.
Find
(
jt
.
ToString
());
jointObj
.
localPosition
=
GetVector3FromJoint
(
sourceJoint
);
//Debug.Log(i);
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
X
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Y
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Z
;
if
((
sourceJoint
.
Position
.
X
+
sourceJoint
.
Position
.
Y
+
sourceJoint
.
Position
.
Z
)
!=
0
)
{
state
[
i
-
2
]
=
1
;
}
skeleton_Trainnne
.
dasomset
(
data1
,
state
,
0
,
true
,
true
,
body
.
Joints
[
jt
],
jointObj
);
/*
LineRenderer lr = jointObj.GetComponent<LineRenderer>();
if (targetJoint.HasValue)
{
//Debug.Log(jointObj.localPosition);
//Debug.Log(GetVector3FromJoint(targetJoint.Value));
lr.SetPosition(0, jointObj.localPosition);
lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
}
else
{
lr.enabled = false;
}
*/
}
///////////////////////////
Angles
MyAngles
=
new
Angles
();
byte
[]
ReadAngles
=
MyAngles
.
GetVector
(
body
);
...
...
@@ -547,19 +547,17 @@ public class Move : MonoBehaviour
{
if
(
ReadAngles
[
1
]
-
ReadAngles
[
2
]
<=
5
)
{
hipbal
=
""
;
//hipbal = "양쪽 균형이 잡혀있습니다.";
HipBalance1
.
SetActive
(
false
);
}
else
{
hipbal
=
"양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!"
;
//
"양쪽 힘이 동일하지 않습니다. \n균형을 잡으세요!";
HipBalance1
.
SetActive
(
true
);
}
if
(
ReadAngles
[
5
]
>
95
||
ReadAngles
[
6
]
>
95
)
{
pullhipback
=
"엉덩이를 뒤로 더 빼세요!"
;
//
"엉덩이를 뒤로 더 빼세요!";
PullHipBack2
.
SetActive
(
true
);
}
else
...
...
@@ -569,8 +567,6 @@ public class Move : MonoBehaviour
if
(
ReadAngles
[
3
]
<
95
&&
ReadAngles
[
4
]
<
95
)
{
great
=
"GREAT!"
;
//Debug.Log(ReadAngles[3]);
Great5
.
SetActive
(
true
);
}
else
...
...
@@ -657,11 +653,13 @@ public class Move : MonoBehaviour
flag
=
1
;
}
}
else
{
else
{
flag_timer
+=
Time
.
deltaTime
;
//Debug.Log(flag_timer);
if
(
flag_timer
>
50
)
{
if
(
flag_timer
>
5
)
{
flag
=
0
;
flag_timer
=
0
;
Debug
.
Log
(
"5초넘음"
);
...
...
@@ -684,7 +682,8 @@ public class Move : MonoBehaviour
workout
=
true
;
}
}
else
{
else
{
if
(
flag
==
0
)
{
if
(
lunge_flag_r
<
120
&&
ReadAngles
[
4
]
>=
91
&&
lunge_flag_r
>
ReadAngles
[
4
])
...
...
@@ -709,7 +708,7 @@ public class Move : MonoBehaviour
flag_timer
+=
Time
.
deltaTime
;
//Debug.Log(flag_timer);
if
(
flag_timer
>
50
)
if
(
flag_timer
>
5
)
{
flag
=
0
;
flag_timer
=
0
;
...
...
@@ -750,46 +749,7 @@ public class Move : MonoBehaviour
SpineStraight4
.
SetActive
(
false
);
}
///////////////////////////
if
(
_BoneMap
.
ContainsKey
(
jt
))
{
targetJoint
=
body
.
Joints
[
_BoneMap
[
jt
]];
}
Transform
jointObj
=
bodyObject
.
transform
.
Find
(
jt
.
ToString
());
jointObj
.
localPosition
=
GetVector3FromJoint
(
sourceJoint
);
//Debug.Log(i);
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
X
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Y
;
i
++;
data1
[
i
]
=
sourceJoint
.
Position
.
Z
;
if
((
sourceJoint
.
Position
.
X
+
sourceJoint
.
Position
.
Y
+
sourceJoint
.
Position
.
Z
)
!=
0
)
{
state
[
i
-
2
]
=
1
;
}
skeleton_Trainnne
.
dasomset
(
data1
,
state
,
0
,
true
,
true
,
body
.
Joints
[
jt
],
jointObj
);
/*
LineRenderer lr = jointObj.GetComponent<LineRenderer>();
if (targetJoint.HasValue)
{
//Debug.Log(jointObj.localPosition);
//Debug.Log(GetVector3FromJoint(targetJoint.Value));
lr.SetPosition(0, jointObj.localPosition);
lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
}
else
{
lr.enabled = false;
}
*/
}
}
private
static
Color
GetColorForState
(
Kinect
.
TrackingState
state
)
...
...
Please
register
or
login
to post a comment