Browse Source

fix touch steps and color feedback

Kenkart 2 years ago
parent
commit
4b4a53a797

+ 11 - 10
Assets/Scripts/BodyComparer.cs

@@ -21,8 +21,7 @@ public class BodyComparer : MonoBehaviour
     {
         for (int i = 0; i < jointsDataDemo.Count; i++)
         {
-            Transform[] joints = bsv.body.GetComponentsInChildren<Transform>();
-            int index = 0;
+            Transform body = bsv.body.transform;
 
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
@@ -36,19 +35,22 @@ public class BodyComparer : MonoBehaviour
                 JointsData jd = jointsDataDemo[i];
                 Vector3 posJointDemo = new Vector3(jd.jointsPositionsX[(int)jt], jd.jointsPositionsY[(int)jt], jd.jointsPositionsZ[(int)jt]);
 
-                float distance = (joints[index].position - posJointDemo).magnitude;
-                if (distance > 0.2f)
+                //float distance = (joints[index].position - posJointDemo).magnitude;
+                float distance = (body.GetChild((int)jt).position - posJointDemo).magnitude;
+                
+                if (distance > 0.15f)
                 {
-                    joints[index].GetComponent<Renderer>().material.color = Color.red;
+                    //joints[index].GetComponent<Renderer>().material.color = Color.red;
+                    body.GetChild((int)jt).GetComponent<Renderer>().material.color = Color.red;
                 }
                 else
                 {
-                    joints[index].GetComponent<Renderer>().material.color = Color.white;
+                    //joints[index].GetComponent<Renderer>().material.color = Color.white;
+                    body.GetChild((int)jt).GetComponent<Renderer>().material.color = Color.white;
                 }
-                index++;
             }
 
-            float waitTime = 1;
+            float waitTime = 0.01f;
             if (i < recordingTimesDemo.Count - 1)
             {
                 waitTime = recordingTimesDemo[i + 1] - recordingTimesDemo[i];
@@ -56,7 +58,6 @@ public class BodyComparer : MonoBehaviour
 
             yield return new WaitForSeconds(waitTime);
         }
-        yield return new WaitForSeconds(3);
-        // TODO: maybe at the end need to make all of them white?
+        // TODO: make all of them white
     }
 }

+ 11 - 12
Assets/Scripts/PlayerReplay.cs

@@ -129,7 +129,7 @@ public class PlayerReplay : MonoBehaviour
 
                 // If a joint is bigger than a certain distance, add it to the replay, else ignore it
                 // TODO: maybe distance need to be adjusted
-                if (distance >= 0.2f)
+                if (distance >= 0.15f)
                 {
                     newJointsData.Add(jd);
                     newRecordingTimes.Add(recordingTimes[i]);
@@ -254,12 +254,8 @@ public class PlayerReplay : MonoBehaviour
 
                     yield return Visualize(jointsDataDemo, recordingTimesDemo);
 
-                    // TODO: Implementing color feedback
                     bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
 
-                    jointsDataDemo.Clear();
-                    recordingTimesDemo.Clear();
-
                     break;
                 }
             }
@@ -293,11 +289,14 @@ public class PlayerReplay : MonoBehaviour
                     body.SetData(jointsDataSeries, recordingTimesSeries);
                     body.ShowBody();
 
+                    // Compare visualization demo with body
+                    yield return bc.StartCompare();
+
+                    jointsDataDemo.Clear();
+                    recordingTimesDemo.Clear();
                     jointsDataSeries.Clear();
                     recordingTimesSeries.Clear();
 
-                    yield return bc.StartCompare();
-
                     // Wait for input
                     yield return ViveInput.WaitForControllerPress();
                     break;
@@ -313,9 +312,6 @@ public class PlayerReplay : MonoBehaviour
 
         bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
 
-        jointsDataDemo.Clear();
-        recordingTimesDemo.Clear();
-
         // Show start position of steps
         startStepPreview.SetData(jointsDataSeries[0]);
         startStepPreview.ShowBody();
@@ -331,11 +327,14 @@ public class PlayerReplay : MonoBehaviour
         bodyEnd.SetData(jointsDataSeries, recordingTimesSeries);
         bodyEnd.ShowBody();
 
+        // Compare visualization demo with body
+        yield return bc.StartCompare();
+
+        jointsDataDemo.Clear();
+        recordingTimesDemo.Clear();
         jointsDataSeries.Clear();
         recordingTimesSeries.Clear();
 
-        yield return bc.StartCompare();
-
         textFinish.SetActive(true);
         yield return new WaitForSeconds(3);
         textFinish.SetActive(false);

+ 3 - 17
Assets/Scripts/TriggerDetectorSeries.cs

@@ -8,26 +8,12 @@ public class TriggerDetectorSeries : MonoBehaviour
     {
         if (other.CompareTag("WristLeft"))
         {
-            //other.GetComponent<Renderer>().material.color = new Color(1, 1, 1);
-            //other.GetComponent<LineRenderer>().startColor = new Color(1, 1, 1);
-            //BodySourceView bsv = other.GetComponentInParent<BodySourceView>();
-            //bsv.wristLeftLate = false;
-            //Visualizer_FadeInSeries vfi = GetComponentInParent<Visualizer_FadeInSeries>();
-            //vfi.wristLeftTriggered = true;
-
-            // TODO: Destroy visualization step if it is touched (need to test)
-            Destroy(gameObject.transform.parent);
+            // Destroy visualization step if it is touched
+            Destroy(gameObject.transform.parent.gameObject);
         }
         else if (other.CompareTag("WristRight"))
         {
-            //other.GetComponent<Renderer>().material.color = new Color(1, 1, 1);
-            //other.GetComponent<LineRenderer>().startColor = new Color(1, 1, 1);
-            //BodySourceView bsv = other.GetComponentInParent<BodySourceView>();
-            //bsv.wristRightLate = false;
-            //Visualizer_FadeInSeries vfi = GetComponentInParent<Visualizer_FadeInSeries>();
-            //vfi.wristRightTriggered = true;
-
-            Destroy(gameObject.transform.parent);
+            Destroy(gameObject.transform.parent.gameObject);
         }
     }
 }

BIN
Assets/joints.sav