Browse Source

able to replay the recorded joints

Kenkart 2 years ago
parent
commit
003c3c42f4
2 changed files with 5 additions and 9 deletions
  1. 1 1
      Assets/KinectView/Scripts/BodySourceView.cs
  2. 4 8
      Assets/Scripts/PlayerReplay.cs

+ 1 - 1
Assets/KinectView/Scripts/BodySourceView.cs

@@ -153,7 +153,7 @@ public class BodySourceView : MonoBehaviour
                 // Make head joint invisible
                 jointObj.GetComponent<Renderer>().enabled = false;
                 // Make camera follow the head
-                cameraRig.localPosition = new Vector3(jointObj.localPosition.x, jointObj.localPosition.y - 3, jointObj.localPosition.z + 2);
+                cameraRig.localPosition = new Vector3(jointObj.localPosition.x, jointObj.localPosition.y - 2, jointObj.localPosition.z + 2);
             }
 
             LineRenderer lr = jointObj.GetComponent<LineRenderer>();

+ 4 - 8
Assets/Scripts/PlayerReplay.cs

@@ -44,7 +44,6 @@ public class PlayerReplay : MonoBehaviour
 
     public void AddJoints()
     {
-        // TODO: still not working, all elements are replaced with new added array
         Vector3[] positions = new Vector3[25];
 
         for(int i = 0; i < joints.Length; i++)
@@ -77,13 +76,12 @@ public class PlayerReplay : MonoBehaviour
         }
 
         StartCoroutine(ShowJoints(data));
-
         Debug.Log("Load success");
     }
 
     private IEnumerator ShowJoints(JointsDataSequence data)
     {
-        // Show joints every 2 seconds
+        // Show joints one by one every 2 seconds
         WaitForSeconds wait = new WaitForSeconds(2);
         List<JointsData> jointsData = data.jointsDataSequence;
         int counter = 0;
@@ -119,19 +117,17 @@ public class PlayerReplay : MonoBehaviour
                 if (!_BoneMap.ContainsKey(jt) || jt == Kinect.JointType.Neck)
                     continue;
 
-
                 Transform jointObj = body.transform.Find(jt.ToString());
-                LineRenderer lr = jointObj.GetComponent<LineRenderer>();
-
-
                 Transform targetJoint = body.transform.Find(_BoneMap[jt].ToString());
+                LineRenderer lr = jointObj.GetComponent<LineRenderer>();
 
                 lr.SetPosition(0, jointObj.localPosition);
                 lr.SetPosition(1, targetJoint.localPosition);
             }
 
-            counter++;
             yield return wait;
+            counter++;
+            Destroy(body);
         }
     }
 }