Browse Source

rework steps

The flow is like this: start, stop, start, stop, ...
Kenkart 2 years ago
parent
commit
f40f23a348
2 changed files with 27 additions and 2 deletions
  1. 21 2
      Assets/Scripts/BodyComparer.cs
  2. 6 0
      Assets/Scripts/PlayerReplay.cs

+ 21 - 2
Assets/Scripts/BodyComparer.cs

@@ -17,6 +17,21 @@ public class BodyComparer : MonoBehaviour
     private List<List<Vector3>> posJointsBodys = new List<List<Vector3>>();
     private List<float> csvTimes = new List<float>();
 
+    private bool isComparing;
+    public bool endStepsPressed;
+
+    private void Update()
+    {
+        if (!isComparing)
+            return;
+
+        if (SteamVR_Actions.default_GrabPinch.GetStateDown(SteamVR_Input_Sources.Any) || Input.GetKeyDown(KeyCode.Space))
+        {
+            isComparing = false;
+            endStepsPressed = true;
+        }
+    }
+
     public void SetDataDemo(List<JointsData> jointsDataDemo, List<float> recordingTimesDemo)
     {
         this.jointsDataDemo = jointsDataDemo;
@@ -31,6 +46,8 @@ public class BodyComparer : MonoBehaviour
             yield break;
         }
 
+        isComparing = true;
+
         for (int i = 0; i < jointsDataDemo.Count; i++)
         {
             Transform body = bsv.body.transform;
@@ -88,8 +105,8 @@ public class BodyComparer : MonoBehaviour
             posJointsBodys.Add(oneBodyReal);
             csvTimes.Add(viveInput.csvTime);
 
-            float waitTime = 0.01f;
-            if (i < recordingTimesDemo.Count - 1)
+            float waitTime = 0;
+            if (isComparing && i < recordingTimesDemo.Count - 1)
             {
                 waitTime = recordingTimesDemo[i + 1] - recordingTimesDemo[i];
             }
@@ -97,6 +114,8 @@ public class BodyComparer : MonoBehaviour
             yield return new WaitForSeconds(waitTime);
         }
 
+        isComparing = false;
+
         // Make all joints white
         Transform bodyEnd = bsv.body.transform;
         for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)

+ 6 - 0
Assets/Scripts/PlayerReplay.cs

@@ -286,6 +286,12 @@ public class PlayerReplay : MonoBehaviour
             jointsDataDemo.Clear();
             recordingTimesDemo.Clear();
 
+            // Input for end steps. Wait for input if finish comparing. Not if comparing is interupted.
+            if (!bc.endStepsPressed)
+            {
+                yield return ViveInput.WaitForControllerPress();
+            }
+
             // Wait for input
             yield return ViveInput.WaitForControllerPress();