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-05-30 16:40:36 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
064a3986d8d40e83c75a3e5b19a3e95642e10150
064a3986
1 parent
c576320a
파일입출력으로 Trainner 움직이기
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
1 deletions
New_TEXT_File.txt
sourcecode/capstone/Assets/Script/CharacterSkeleton.cs
sourcecode/capstone/Assets/Script/Move.cs
New_TEXT_File.txt
0 → 100644
View file @
064a398
This diff could not be displayed because it is too large.
sourcecode/capstone/Assets/Script/CharacterSkeleton.cs
View file @
064a398
...
...
@@ -266,4 +266,77 @@ class CharacterSkeleton
}
}
public
void
dasomset_trainer
(
float
[]
jt
,
int
[]
st
,
int
offset
,
bool
mirrored
,
bool
move
)
{
if
(
isSavedPosition
==
false
&&
jointState
[
JointType_SpineBase
]
!=
TrackingState_NotTracked
)
{
isSavedPosition
=
true
;
int
j
=
offset
*
jointCount
+
JointType_SpineBase
;
savedPosition
=
new
Vector3
(
jt
[
j
*
3
],
jt
[
j
*
3
+
1
],
jt
[
j
*
3
+
2
]);
}
for
(
int
i
=
0
;
i
<
jointCount
;
i
++)
{
int
j
=
offset
*
jointCount
+
i
;
if
(
mirrored
)
{
joint
[
i
]
=
new
Vector3
(-
jt
[
j
*
3
],
jt
[
j
*
3
+
1
],
-
jt
[
j
*
3
+
2
]);
}
else
{
joint
[
i
]
=
new
Vector3
(
jt
[
j
*
3
],
jt
[
j
*
3
+
1
],
savedPosition
.
z
*
2
-
jt
[
j
*
3
+
2
]);
}
jointState
[
i
]
=
st
[
j
];
}
if
(
mirrored
)
{
swapJoint
(
JointType_ShoulderLeft
,
JointType_ShoulderRight
);
swapJoint
(
JointType_ElbowLeft
,
JointType_ElbowRight
);
swapJoint
(
JointType_WristLeft
,
JointType_WristRight
);
swapJoint
(
JointType_HandLeft
,
JointType_HandRight
);
swapJoint
(
JointType_HipLeft
,
JointType_HipRight
);
swapJoint
(
JointType_KneeLeft
,
JointType_KneeRight
);
swapJoint
(
JointType_AnkleLeft
,
JointType_AnkleRight
);
swapJoint
(
JointType_FootLeft
,
JointType_FootRight
);
swapJoint
(
JointType_HandTipLeft
,
JointType_HandTipRight
);
swapJoint
(
JointType_ThumbLeft
,
JointType_ThumbRight
);
}
for
(
int
i
=
0
;
i
<
targetBone
.
Length
;
i
++)
{
int
s
=
jointSegment
[
2
*
i
],
e
=
jointSegment
[
2
*
i
+
1
];
trackingSegment
[
targetBone
[
i
]]
=
joint
[
e
]
-
joint
[
s
];
trackingState
[
targetBone
[
i
]]
=
System
.
Math
.
Min
(
jointState
[
e
],
jointState
[
s
]);
}
Vector3
waist
=
joint
[
JointType_HipRight
]
-
joint
[
JointType_HipLeft
];
waist
=
new
Vector3
(
waist
.
x
,
0
,
waist
.
z
);
Quaternion
rot
=
Quaternion
.
FromToRotation
(
Vector3
.
right
,
waist
);
Quaternion
rotInv
=
Quaternion
.
Inverse
(
rot
);
Vector3
shoulder
=
joint
[
JointType_ShoulderRight
]
-
joint
[
JointType_ShoulderLeft
];
shoulder
=
new
Vector3
(
shoulder
.
x
,
0
,
shoulder
.
z
);
Quaternion
srot
=
Quaternion
.
FromToRotation
(
Vector3
.
right
,
shoulder
);
Quaternion
srotInv
=
Quaternion
.
Inverse
(
srot
);
humanoid
.
transform
.
rotation
=
Quaternion
.
identity
;
foreach
(
HumanBodyBones
bone
in
targetBone
)
{
rigBone
[
bone
].
transform
.
rotation
=
rotInv
*
Quaternion
.
FromToRotation
(
Vector3
.
up
,
trackingSegment
[
bone
]);
}
rigBone
[
HumanBodyBones
.
UpperChest
].
offset
(
srot
);
Quaternion
bodyRot
=
rot
;
if
(
mirrored
)
{
bodyRot
=
Quaternion
.
AngleAxis
(
180
,
Vector3
.
up
)
*
bodyRot
;
}
humanoid
.
transform
.
rotation
=
bodyRot
;
if
(
move
==
true
)
{
Vector3
m
=
joint
[
JointType_SpineBase
];
if
(
mirrored
)
m
=
new
Vector3
(-
7
,
m
.
y
-
9
,
-
2
);
humanoid
.
transform
.
position
=
m
;
}
}
}
...
...
sourcecode/capstone/Assets/Script/Move.cs
View file @
064a398
...
...
@@ -6,6 +6,7 @@ using Kinect = Windows.Kinect;
using
System.Runtime.InteropServices
;
using
System.IO
;
using
System
;
using
System.Threading
;
public
class
Move
:
MonoBehaviour
{
...
...
@@ -30,6 +31,15 @@ public class Move : MonoBehaviour
public
bool
move
=
true
;
private
System
.
IntPtr
kinect
;
//lsy
public
string
[]
lines
;
public
int
trainer_i
=
-
1
;
public
int
trainer_j
=
0
;
public
float
[]
trainer_data1
;
public
int
[]
trainer_state
;
//lsy end
public
Text
IfSpineIsStraight
;
public
Text
HipBalance
;
public
Text
AngleLeftKnee
;
...
...
@@ -41,11 +51,60 @@ public class Move : MonoBehaviour
string
hipbal
,
leftkneewarning
,
rightkneewarning
,
leftsidehighkick
,
rightsidehighkick
;
//lsy
void
Trainer_Run
()
{
if
(
trainer_j
>=
lines
.
Length
-
3
)
{
trainer_j
=
0
;
return
;
}
trainer_i
=
-
1
;
trainer_data1
=
new
float
[
bodyCount
*
jointCount
*
3
];
trainer_state
=
new
int
[
bodyCount
*
jointCount
];
Debug
.
Log
(
"초기화"
);
//Thread.Sleep(5000);
for
(
int
k
=
0
;
k
<
25
;
k
++)
{
Debug
.
Log
(
"trainer_j: "
+
trainer_j
);
Debug
.
Log
(
"test1"
);
Debug
.
Log
(
lines
[
trainer_j
]);
trainer_i
++;
trainer_data1
[
trainer_i
]
=
float
.
Parse
(
lines
[
trainer_j
]);
Debug
.
Log
(
"test2"
+
trainer_i
);
trainer_i
++;
trainer_data1
[
trainer_i
]
=
float
.
Parse
(
lines
[
trainer_j
+
1
]);
Debug
.
Log
(
"test3"
+
trainer_i
);
trainer_i
++;
trainer_data1
[
trainer_i
]
=
float
.
Parse
(
lines
[
trainer_j
+
2
]);
Debug
.
Log
(
"test4"
+
trainer_i
);
if
((
float
.
Parse
(
lines
[
trainer_j
])
+
float
.
Parse
(
lines
[
trainer_j
+
1
])
+
float
.
Parse
(
lines
[
trainer_j
+
2
]))
!=
0
)
{
trainer_state
[
trainer_i
-
2
]
=
1
;
}
Debug
.
Log
(
"test4-1"
);
skeleton_Trainnner
.
dasomset_trainer
(
trainer_data1
,
trainer_state
,
0
,
true
,
true
);
Debug
.
Log
(
"test5"
);
Debug
.
Log
(
trainer_i
);
Debug
.
Log
(
"메모라인 : "
+
trainer_j
);
trainer_j
=
trainer_j
+
3
;
}
Debug
.
Log
(
"탈출!======================================================"
);
}
//lsy end
void
Start
()
{
skeleton_Trainnner
=
new
CharacterSkeleton
(
Trainnner
);
skeleton_Trainnne
=
new
CharacterSkeleton
(
Trainnne
);
//lsy
trainer_state
=
new
int
[
bodyCount
*
jointCount
];
trainer_data1
=
new
float
[
bodyCount
*
jointCount
*
3
];
lines
=
File
.
ReadAllLines
(
@"..\..\New_TEXT_File.txt"
);
Debug
.
Log
(
"읽음"
);
//lsy end
}
private
Dictionary
<
Kinect
.
JointType
,
Kinect
.
JointType
>
_BoneMap
=
new
Dictionary
<
Kinect
.
JointType
,
Kinect
.
JointType
>()
...
...
@@ -82,6 +141,11 @@ public class Move : MonoBehaviour
void
Update
()
{
//lsy
Trainer_Run
();
//lsy end
IfSpineIsStraight
.
text
=
"허리를 곧게: Tracking"
;
HipBalance
.
text
=
"양쪽 힙 균형: Calculating"
;
AngleLeftKnee
.
text
=
"왼쪽 무릎 각도: Tracking"
;
...
...
@@ -389,4 +453,4 @@ public class Move : MonoBehaviour
return
Angles
;
}
}
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment