Browse Source

rework recording success

Kenkart 2 years ago
parent
commit
a9e0309675

+ 1 - 1
Assets/Scripts/JointsDataSequence.cs

@@ -18,7 +18,7 @@ public class JointsDataSequence
 
         foreach(float f in recordingTimes)
         {
-            recordingTimes.Add(f);
+            this.recordingTimes.Add(f);
         }
     }
 }

+ 10 - 5
Assets/Scripts/PlayerReplay.cs

@@ -8,6 +8,7 @@ public class PlayerReplay : MonoBehaviour
 {
     // Joints already given the values from BodySourceView.cs that keeps updating
     public Transform[] joints = new Transform[25];
+
     public List<Vector3[]> jointsSequence = new List<Vector3[]>();
     public List<float> recordingTimes = new List<float>();
     public Material boneMaterial;
@@ -82,6 +83,12 @@ public class PlayerReplay : MonoBehaviour
         recordingTimes.Add(recordingTime);
     }
 
+    public void ResetRecording()
+    {
+        jointsSequence.Clear();
+        recordingTimes.Clear();
+    }
+
     public void Save()
     {
         if (jointsSequence.Count == 0)
@@ -136,8 +143,7 @@ public class PlayerReplay : MonoBehaviour
                 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 certain distance, add it to the replay, else ignore it
-                // TODO: need to test distance value
+                // If a joint is bigger than a certain distance, add it to the replay, else ignore it
                 if (distance >= 2)
                 {
                     newJointsData.Add(jd);
@@ -148,7 +154,6 @@ public class PlayerReplay : MonoBehaviour
             }
         }
 
-        // TODO: visualize need to test
         StartCoroutine(Visualize(newJointsData, newRecordingTimes));
     }
 
@@ -167,7 +172,7 @@ public class PlayerReplay : MonoBehaviour
             GameObject body = new GameObject("Recorded Body " + i);
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
-                // skip if head joint
+                // Skip if head joint
                 if (jt == Kinect.JointType.Head)
                     continue;
 
@@ -189,7 +194,7 @@ public class PlayerReplay : MonoBehaviour
             // Connect the joints with LineRenderer
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
-                // skip if dictionary not contains the joint or neck joint
+                // Skip if dictionary not contains the joint or neck joint
                 if (!_BoneMap.ContainsKey(jt) || jt == Kinect.JointType.Neck)
                     continue;
 

+ 4 - 1
Assets/Scripts/ViveInput.cs

@@ -25,19 +25,22 @@ public class ViveInput : MonoBehaviour
     {
         if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
         {
-            //playerReplay.AddJoints();
+            Debug.Log("Recording...");
             isRecording = true;
         }
 
         if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
         {
+            Debug.Log("Saving...");
             isRecording = false;
             recordingTime = 0;
             playerReplay.Save();
+            playerReplay.ResetRecording();
         }
 
         if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
         {
+            Debug.Log("Loading...");
             playerReplay.Load();
         }