|
@@ -100,45 +100,7 @@ public class PlayerReplay : MonoBehaviour
|
|
|
{
|
|
|
List<JointsData> jointsData = data.jointsDataSequence;
|
|
|
List<float> recordingTimes = data.recordingTimes;
|
|
|
-
|
|
|
- // Filtered datas according to distance
|
|
|
- List<JointsData> newJointsData = new List<JointsData>();
|
|
|
- List<float> newRecordingTimes = new List<float>();
|
|
|
-
|
|
|
- JointsData prevJd = jointsData[0];
|
|
|
-
|
|
|
- // Add first pose
|
|
|
- newJointsData.Add(jointsData[0]);
|
|
|
- newRecordingTimes.Add(recordingTimes[0]);
|
|
|
-
|
|
|
- for (int i = 1; i < jointsData.Count; i++)
|
|
|
- {
|
|
|
- JointsData jd = jointsData[i];
|
|
|
-
|
|
|
- for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
|
|
|
- {
|
|
|
- // Skip these joints
|
|
|
- if (jt == Kinect.JointType.Head || jt == Kinect.JointType.ThumbLeft || jt == Kinect.JointType.ThumbRight
|
|
|
- || jt == Kinect.JointType.HandLeft || jt == Kinect.JointType.HandRight
|
|
|
- || jt == Kinect.JointType.HandTipLeft || jt == Kinect.JointType.HandTipRight)
|
|
|
- continue;
|
|
|
-
|
|
|
- Vector3 prevJointPosition = new Vector3(prevJd.jointsPositionsX[(int)jt], prevJd.jointsPositionsY[(int)jt], prevJd.jointsPositionsZ[(int)jt]);
|
|
|
- Vector3 jointPosition = new Vector3(jd.jointsPositionsX[(int)jt], jd.jointsPositionsY[(int)jt], jd.jointsPositionsZ[(int)jt]);
|
|
|
- float distance = Vector3.Distance(prevJointPosition, jointPosition);
|
|
|
-
|
|
|
- // If a joint is bigger than a certain distance, add it to the replay, else ignore it
|
|
|
- if (distance >= 0.15f)
|
|
|
- {
|
|
|
- newJointsData.Add(jd);
|
|
|
- newRecordingTimes.Add(recordingTimes[i]);
|
|
|
- prevJd = jd;
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- StartCoroutine(VisualizeFadeInSeries(jointsData, recordingTimes, newJointsData, newRecordingTimes));
|
|
|
+ StartCoroutine(VisualizeFadeInSeries(jointsData, recordingTimes));
|
|
|
}
|
|
|
|
|
|
private IEnumerator Visualize(List<JointsData> newJointsData, List<float> newRecordingTimes)
|
|
@@ -228,113 +190,108 @@ public class PlayerReplay : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private IEnumerator VisualizeFadeInSeries(List<JointsData> jointsData, List<float> recordingTimes, List<JointsData> newJointsData, List<float> newRecordingTimes)
|
|
|
+ private IEnumerator VisualizeFadeInSeries(List<JointsData> jointsData, List<float> recordingTimes)
|
|
|
{
|
|
|
float waitTime = 3;
|
|
|
List<JointsData> jointsDataDemo = new List<JointsData>();
|
|
|
List<float> recordingTimesDemo = new List<float>();
|
|
|
- List<JointsData> jointsDataSeries = new List<JointsData>();
|
|
|
- List<float> recordingTimesSeries = new List<float>();
|
|
|
-
|
|
|
int indexDemo = 0;
|
|
|
- int indexSeries = 0;
|
|
|
+ bool finish = false;
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
- // Visualization demo
|
|
|
for (int i = indexDemo; i < jointsData.Count; i++)
|
|
|
{
|
|
|
if (recordingTimes[i] < waitTime)
|
|
|
{
|
|
|
jointsDataDemo.Add(jointsData[i]);
|
|
|
recordingTimesDemo.Add(recordingTimes[i]);
|
|
|
+ finish = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
indexDemo = i;
|
|
|
-
|
|
|
- yield return Visualize(jointsDataDemo, recordingTimesDemo);
|
|
|
-
|
|
|
- bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
|
|
|
-
|
|
|
+ waitTime += 3;
|
|
|
+ finish = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Visualization steps/series
|
|
|
- for (int i = indexSeries; i < newJointsData.Count; i++)
|
|
|
- {
|
|
|
- if (newRecordingTimes[i] < waitTime)
|
|
|
- {
|
|
|
- jointsDataSeries.Add(newJointsData[i]);
|
|
|
- recordingTimesSeries.Add(newRecordingTimes[i]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Show start position of steps
|
|
|
- startStepPreview.SetData(jointsDataSeries[0]);
|
|
|
- startStepPreview.ShowBody();
|
|
|
-
|
|
|
- // Wait for input
|
|
|
- yield return ViveInput.WaitForControllerPress();
|
|
|
+ // Visualization demo
|
|
|
+ yield return Visualize(jointsDataDemo, recordingTimesDemo);
|
|
|
|
|
|
- // Delete start position of steps
|
|
|
- startStepPreview.DeleteBody();
|
|
|
+ bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
|
|
|
|
|
|
+ // Visualization steps/series
|
|
|
|
|
|
- indexSeries = i;
|
|
|
- waitTime += 3;
|
|
|
+ // Filtered datas according to distance
|
|
|
+ List<JointsData> filteredJointsData = new List<JointsData>();
|
|
|
+ List<float> filteredRecordingTimes = new List<float>();
|
|
|
|
|
|
- Visualizer_FadeInSeries body = Instantiate(vfis) as Visualizer_FadeInSeries;
|
|
|
- body.transform.parent = gameObject.transform;
|
|
|
- body.SetData(jointsDataSeries, recordingTimesSeries);
|
|
|
- body.ShowBody();
|
|
|
+ JointsData prevJd = jointsDataDemo[0];
|
|
|
|
|
|
- // Compare visualization demo with body
|
|
|
- yield return bc.StartCompare();
|
|
|
+ // Add first pose
|
|
|
+ filteredJointsData.Add(jointsDataDemo[0]);
|
|
|
+ filteredRecordingTimes.Add(recordingTimesDemo[0]);
|
|
|
|
|
|
- jointsDataDemo.Clear();
|
|
|
- recordingTimesDemo.Clear();
|
|
|
- jointsDataSeries.Clear();
|
|
|
- recordingTimesSeries.Clear();
|
|
|
+ for (int i = 1; i < jointsDataDemo.Count; i++)
|
|
|
+ {
|
|
|
+ JointsData jd = jointsDataDemo[i];
|
|
|
|
|
|
- // Wait for input
|
|
|
- yield return ViveInput.WaitForControllerPress();
|
|
|
- break;
|
|
|
+ for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
|
|
|
+ {
|
|
|
+ // Skip these joints
|
|
|
+ if (jt == Kinect.JointType.Head || jt == Kinect.JointType.ThumbLeft || jt == Kinect.JointType.ThumbRight
|
|
|
+ || jt == Kinect.JointType.HandLeft || jt == Kinect.JointType.HandRight
|
|
|
+ || jt == Kinect.JointType.HandTipLeft || jt == Kinect.JointType.HandTipRight)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ Vector3 prevJointPosition = new Vector3(prevJd.jointsPositionsX[(int)jt], prevJd.jointsPositionsY[(int)jt], prevJd.jointsPositionsZ[(int)jt]);
|
|
|
+ Vector3 jointPosition = new Vector3(jd.jointsPositionsX[(int)jt], jd.jointsPositionsY[(int)jt], jd.jointsPositionsZ[(int)jt]);
|
|
|
+ float distance = Vector3.Distance(prevJointPosition, jointPosition);
|
|
|
+
|
|
|
+ // If a joint is bigger than a certain distance, add it to the replay, else ignore it
|
|
|
+ if (distance >= 0.15f)
|
|
|
+ {
|
|
|
+ filteredJointsData.Add(jd);
|
|
|
+ filteredRecordingTimes.Add(recordingTimesDemo[i]);
|
|
|
+ prevJd = jd;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // Add last step of demo
|
|
|
+ filteredJointsData.Add(jointsDataDemo[jointsDataDemo.Count - 1]);
|
|
|
|
|
|
- if (jointsDataSeries.Count != 0)
|
|
|
- break;
|
|
|
- }
|
|
|
+ // Show start position of steps
|
|
|
+ startStepPreview.SetData(filteredJointsData[0]);
|
|
|
+ startStepPreview.ShowBody();
|
|
|
|
|
|
- // Last visualization
|
|
|
- yield return Visualize(jointsDataDemo, recordingTimesDemo);
|
|
|
+ // Wait for input
|
|
|
+ yield return ViveInput.WaitForControllerPress();
|
|
|
|
|
|
- bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
|
|
|
+ // Delete start position of steps
|
|
|
+ startStepPreview.DeleteBody();
|
|
|
|
|
|
- // Show start position of steps
|
|
|
- startStepPreview.SetData(jointsDataSeries[0]);
|
|
|
- startStepPreview.ShowBody();
|
|
|
-
|
|
|
- // Wait for input
|
|
|
- yield return ViveInput.WaitForControllerPress();
|
|
|
-
|
|
|
- // Delete start position of steps
|
|
|
- startStepPreview.DeleteBody();
|
|
|
+ Visualizer_FadeInSeries body = Instantiate(vfis) as Visualizer_FadeInSeries;
|
|
|
+ body.transform.parent = gameObject.transform;
|
|
|
+ body.SetData(filteredJointsData, filteredRecordingTimes);
|
|
|
+ body.ShowBody();
|
|
|
|
|
|
- Visualizer_FadeInSeries bodyEnd = Instantiate(vfis) as Visualizer_FadeInSeries;
|
|
|
- bodyEnd.transform.parent = gameObject.transform;
|
|
|
- bodyEnd.SetData(jointsDataSeries, recordingTimesSeries);
|
|
|
- bodyEnd.ShowBody();
|
|
|
+ // Compare visualization demo with body
|
|
|
+ yield return bc.StartCompare();
|
|
|
|
|
|
- // Compare visualization demo with body
|
|
|
- yield return bc.StartCompare();
|
|
|
+ // Clear list
|
|
|
+ jointsDataDemo.Clear();
|
|
|
+ recordingTimesDemo.Clear();
|
|
|
|
|
|
- jointsDataDemo.Clear();
|
|
|
- recordingTimesDemo.Clear();
|
|
|
- jointsDataSeries.Clear();
|
|
|
- recordingTimesSeries.Clear();
|
|
|
+ // Wait for input
|
|
|
+ yield return ViveInput.WaitForControllerPress();
|
|
|
+
|
|
|
+ if (finish)
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
textFinish.SetActive(true);
|
|
|
yield return new WaitForSeconds(3);
|