Browse Source

rework recording

Kenkart 2 years ago
parent
commit
766b113327

+ 2 - 2
Assets/KinectView/Materials/BoneMaterial.mat

@@ -26,6 +26,6 @@ Material:
     m_Floats:
     - _InvFade: 1
     m_Colors:
-    - _Color: {r: 1, g: 1, b: 1, a: 1}
-    - _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
+    - _Color: {r: 1, g: 0, b: 0, a: 0.2}
+    - _TintColor: {r: 1, g: 1, b: 1, a: 0.49019608}
   m_BuildTextureStacks: []

+ 3 - 2
Assets/KinectView/Scripts/BodySourceView.cs

@@ -161,9 +161,10 @@ public class BodySourceView : MonoBehaviour
             {
                 lr.SetPosition(0, jointObj.localPosition);
                 lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
+                // Coloring the line renderer
                 //lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
-                lr.startColor = GetColorForState(sourceJoint.TrackingState);
-                lr.endColor = GetColorForState(targetJoint.Value.TrackingState);
+                //lr.startColor = GetColorForState(sourceJoint.TrackingState);
+                //lr.endColor = GetColorForState(targetJoint.Value.TrackingState);
             }
             else
             {

+ 256 - 202
Assets/Scenes/Main.unity

@@ -38,7 +38,7 @@ RenderSettings:
   m_ReflectionIntensity: 1
   m_CustomReflection: {fileID: 0}
   m_Sun: {fileID: 0}
-  m_IndirectSpecularColor: {r: 0.18264514, g: 0.22835582, b: 0.307145, a: 1}
+  m_IndirectSpecularColor: {r: 0.1826408, g: 0.2283514, b: 0.3071478, a: 1}
   m_UseRadianceAmbientProbe: 0
 --- !u!157 &3
 LightmapSettings:
@@ -179,6 +179,7 @@ MonoBehaviour:
   - {fileID: 0}
   - {fileID: 0}
   boneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
+  transparentMat: {fileID: 2100000, guid: 803645c956e5ae64a9b99ae13a11cd41, type: 2}
 --- !u!4 &65057766
 Transform:
   m_ObjectHideFlags: 0
@@ -204,6 +205,10 @@ PrefabInstance:
       propertyPath: m_Name
       value: '[CameraRig]'
       objectReference: {fileID: 0}
+    - target: {fileID: 146900, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
+      propertyPath: m_IsActive
+      value: 1
+      objectReference: {fileID: 0}
     - target: {fileID: 420908, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_RootOrder
       value: 2
@@ -251,11 +256,11 @@ PrefabInstance:
     - target: {fileID: 2348914, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Materials.Array.data[0]
       value: 
-      objectReference: {fileID: 816811092}
+      objectReference: {fileID: 1307535905}
     - target: {fileID: 3380982, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Mesh
       value: 
-      objectReference: {fileID: 342663038}
+      objectReference: {fileID: 1343328533}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
 --- !u!4 &110216683 stripped
@@ -311,170 +316,6 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!43 &342663038
-Mesh:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_Name: 
-  serializedVersion: 10
-  m_SubMeshes:
-  - serializedVersion: 2
-    firstByte: 0
-    indexCount: 24
-    topology: 0
-    baseVertex: 0
-    firstVertex: 0
-    vertexCount: 8
-    localAABB:
-      m_Center: {x: 0, y: 0.01, z: 0}
-      m_Extent: {x: 1.65, y: 0, z: 1.275}
-  m_Shapes:
-    vertices: []
-    shapes: []
-    channels: []
-    fullWeights: []
-  m_BindPose: []
-  m_BoneNameHashes: 
-  m_RootBoneNameHash: 0
-  m_BonesAABB: []
-  m_VariableBoneCountWeights:
-    m_Data: 
-  m_MeshCompression: 0
-  m_IsReadable: 1
-  m_KeepVertices: 1
-  m_KeepIndices: 1
-  m_IndexFormat: 0
-  m_IndexBuffer: 000004000100010004000500010005000200020005000600020006000300030006000700030007000000000007000400
-  m_VertexData:
-    serializedVersion: 3
-    m_VertexCount: 8
-    m_Channels:
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 3
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 12
-      format: 0
-      dimension: 4
-    - stream: 0
-      offset: 28
-      format: 0
-      dimension: 2
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    - stream: 0
-      offset: 0
-      format: 0
-      dimension: 0
-    m_DataSize: 288
-    _typelessdata: 0000c03f0ad7233c000090bf000000000000803f0000803f0000803f00000000000000000000c0bf0ad7233c000090bf000000000000803f0000803f0000803f0000803f000000000000c0bf0ad7233c0000903f000000000000803f0000803f0000803f00000000000000000000c03f0ad7233c0000903f000000000000803f0000803f0000803f0000803f000000003333d33f0ad7233c3333a3bf000000000000803f0000803f00000000000000000000803f3333d3bf0ad7233c3333a3bf000000000000803f0000803f000000000000803f0000803f3333d3bf0ad7233c3333a33f000000000000803f0000803f00000000000000000000803f3333d33f0ad7233c3333a33f000000000000803f0000803f000000000000803f0000803f
-  m_CompressedMesh:
-    m_Vertices:
-      m_NumItems: 0
-      m_Range: 0
-      m_Start: 0
-      m_Data: 
-      m_BitSize: 0
-    m_UV:
-      m_NumItems: 0
-      m_Range: 0
-      m_Start: 0
-      m_Data: 
-      m_BitSize: 0
-    m_Normals:
-      m_NumItems: 0
-      m_Range: 0
-      m_Start: 0
-      m_Data: 
-      m_BitSize: 0
-    m_Tangents:
-      m_NumItems: 0
-      m_Range: 0
-      m_Start: 0
-      m_Data: 
-      m_BitSize: 0
-    m_Weights:
-      m_NumItems: 0
-      m_Data: 
-      m_BitSize: 0
-    m_NormalSigns:
-      m_NumItems: 0
-      m_Data: 
-      m_BitSize: 0
-    m_TangentSigns:
-      m_NumItems: 0
-      m_Data: 
-      m_BitSize: 0
-    m_FloatColors:
-      m_NumItems: 0
-      m_Range: 0
-      m_Start: 0
-      m_Data: 
-      m_BitSize: 0
-    m_BoneIndices:
-      m_NumItems: 0
-      m_Data: 
-      m_BitSize: 0
-    m_Triangles:
-      m_NumItems: 0
-      m_Data: 
-      m_BitSize: 0
-    m_UVInfo: 0
-  m_LocalAABB:
-    m_Center: {x: 0, y: 0.01, z: 0}
-    m_Extent: {x: 1.65, y: 0, z: 1.275}
-  m_MeshUsageFlags: 0
-  m_BakedConvexCollisionMesh: 
-  m_BakedTriangleCollisionMesh: 
-  m_MeshMetrics[0]: 1
-  m_MeshMetrics[1]: 1
-  m_MeshOptimizationFlags: 1
-  m_StreamData:
-    serializedVersion: 2
-    offset: 0
-    size: 0
-    path: 
 --- !u!1 &573329778
 GameObject:
   m_ObjectHideFlags: 0
@@ -519,41 +360,6 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!21 &816811092
-Material:
-  serializedVersion: 6
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_Name: Sprites/Default
-  m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
-  m_ShaderKeywords: 
-  m_LightmapFlags: 4
-  m_EnableInstancingVariants: 0
-  m_DoubleSidedGI: 0
-  m_CustomRenderQueue: -1
-  stringTagMap: {}
-  disabledShaderPasses: []
-  m_SavedProperties:
-    serializedVersion: 3
-    m_TexEnvs:
-    - _AlphaTex:
-        m_Texture: {fileID: 0}
-        m_Scale: {x: 1, y: 1}
-        m_Offset: {x: 0, y: 0}
-    - _MainTex:
-        m_Texture: {fileID: 0}
-        m_Scale: {x: 1, y: 1}
-        m_Offset: {x: 0, y: 0}
-    m_Floats:
-    - PixelSnap: 0
-    - _EnableExternalAlpha: 0
-    m_Colors:
-    - _Color: {r: 1, g: 1, b: 1, a: 1}
-    - _Flip: {r: 1, g: 1, b: 1, a: 1}
-    - _RendererColor: {r: 1, g: 1, b: 1, a: 1}
-  m_BuildTextureStacks: []
 --- !u!1001 &833043381
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -780,6 +586,10 @@ PrefabInstance:
       propertyPath: m_Name
       value: '[SteamVR]'
       objectReference: {fileID: 0}
+    - target: {fileID: 132594, guid: 4f35fa249b5008c44ac2998be6f82d4d, type: 3}
+      propertyPath: m_IsActive
+      value: 1
+      objectReference: {fileID: 0}
     - target: {fileID: 458990, guid: 4f35fa249b5008c44ac2998be6f82d4d, type: 3}
       propertyPath: m_RootOrder
       value: 1
@@ -826,6 +636,205 @@ PrefabInstance:
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 4f35fa249b5008c44ac2998be6f82d4d, type: 3}
+--- !u!21 &1307535905
+Material:
+  serializedVersion: 6
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: Sprites/Default
+  m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
+  m_ShaderKeywords: 
+  m_LightmapFlags: 4
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: -1
+  stringTagMap: {}
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - _AlphaTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MainTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Floats:
+    - PixelSnap: 0
+    - _EnableExternalAlpha: 0
+    m_Colors:
+    - _Color: {r: 1, g: 1, b: 1, a: 1}
+    - _Flip: {r: 1, g: 1, b: 1, a: 1}
+    - _RendererColor: {r: 1, g: 1, b: 1, a: 1}
+  m_BuildTextureStacks: []
+--- !u!43 &1343328533
+Mesh:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: 
+  serializedVersion: 10
+  m_SubMeshes:
+  - serializedVersion: 2
+    firstByte: 0
+    indexCount: 24
+    topology: 0
+    baseVertex: 0
+    firstVertex: 0
+    vertexCount: 8
+    localAABB:
+      m_Center: {x: 0, y: 0.01, z: 0}
+      m_Extent: {x: 1.65, y: 0, z: 1.275}
+  m_Shapes:
+    vertices: []
+    shapes: []
+    channels: []
+    fullWeights: []
+  m_BindPose: []
+  m_BoneNameHashes: 
+  m_RootBoneNameHash: 0
+  m_BonesAABB: []
+  m_VariableBoneCountWeights:
+    m_Data: 
+  m_MeshCompression: 0
+  m_IsReadable: 1
+  m_KeepVertices: 1
+  m_KeepIndices: 1
+  m_IndexFormat: 0
+  m_IndexBuffer: 000004000100010004000500010005000200020005000600020006000300030006000700030007000000000007000400
+  m_VertexData:
+    serializedVersion: 3
+    m_VertexCount: 8
+    m_Channels:
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 3
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 12
+      format: 0
+      dimension: 4
+    - stream: 0
+      offset: 28
+      format: 0
+      dimension: 2
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    - stream: 0
+      offset: 0
+      format: 0
+      dimension: 0
+    m_DataSize: 288
+    _typelessdata: 0000c03f0ad7233c000090bf000000000000803f0000803f0000803f00000000000000000000c0bf0ad7233c000090bf000000000000803f0000803f0000803f0000803f000000000000c0bf0ad7233c0000903f000000000000803f0000803f0000803f00000000000000000000c03f0ad7233c0000903f000000000000803f0000803f0000803f0000803f000000003333d33f0ad7233c3333a3bf000000000000803f0000803f00000000000000000000803f3333d3bf0ad7233c3333a3bf000000000000803f0000803f000000000000803f0000803f3333d3bf0ad7233c3333a33f000000000000803f0000803f00000000000000000000803f3333d33f0ad7233c3333a33f000000000000803f0000803f000000000000803f0000803f
+  m_CompressedMesh:
+    m_Vertices:
+      m_NumItems: 0
+      m_Range: 0
+      m_Start: 0
+      m_Data: 
+      m_BitSize: 0
+    m_UV:
+      m_NumItems: 0
+      m_Range: 0
+      m_Start: 0
+      m_Data: 
+      m_BitSize: 0
+    m_Normals:
+      m_NumItems: 0
+      m_Range: 0
+      m_Start: 0
+      m_Data: 
+      m_BitSize: 0
+    m_Tangents:
+      m_NumItems: 0
+      m_Range: 0
+      m_Start: 0
+      m_Data: 
+      m_BitSize: 0
+    m_Weights:
+      m_NumItems: 0
+      m_Data: 
+      m_BitSize: 0
+    m_NormalSigns:
+      m_NumItems: 0
+      m_Data: 
+      m_BitSize: 0
+    m_TangentSigns:
+      m_NumItems: 0
+      m_Data: 
+      m_BitSize: 0
+    m_FloatColors:
+      m_NumItems: 0
+      m_Range: 0
+      m_Start: 0
+      m_Data: 
+      m_BitSize: 0
+    m_BoneIndices:
+      m_NumItems: 0
+      m_Data: 
+      m_BitSize: 0
+    m_Triangles:
+      m_NumItems: 0
+      m_Data: 
+      m_BitSize: 0
+    m_UVInfo: 0
+  m_LocalAABB:
+    m_Center: {x: 0, y: 0.01, z: 0}
+    m_Extent: {x: 1.65, y: 0, z: 1.275}
+  m_MeshUsageFlags: 0
+  m_BakedConvexCollisionMesh: 
+  m_BakedTriangleCollisionMesh: 
+  m_MeshMetrics[0]: 1
+  m_MeshMetrics[1]: 1
+  m_MeshOptimizationFlags: 1
+  m_StreamData:
+    serializedVersion: 2
+    offset: 0
+    size: 0
+    path: 
 --- !u!1 &1715140921
 GameObject:
   m_ObjectHideFlags: 0
@@ -919,6 +928,51 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 40, y: -90, z: 0}
+--- !u!1 &1754081256
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1754081258}
+  - component: {fileID: 1754081257}
+  m_Layer: 0
+  m_Name: GameObject
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &1754081257
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1754081256}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 2ad1483381ce54340b2627cca0fcec23, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  transparentMat: {fileID: 2100000, guid: 803645c956e5ae64a9b99ae13a11cd41, type: 2}
+  boneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
+--- !u!4 &1754081258
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1754081256}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 20.35241, y: -4.21, z: -11.566158}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 9
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &1865471484
 GameObject:
   m_ObjectHideFlags: 0

+ 7 - 1
Assets/Scripts/JointsDataSequence.cs

@@ -6,13 +6,19 @@ using UnityEngine;
 public class JointsDataSequence
 {
     public List<JointsData> jointsDataSequence = new List<JointsData>();
+    public List<float> recordingTimes = new List<float>();
 
-    public JointsDataSequence(List<Vector3[]> jointsSequence)
+    public JointsDataSequence(List<Vector3[]> jointsSequence, List<float> recordingTimes)
     {
         foreach(Vector3[] vectors in jointsSequence)
         {
             JointsData jointsData = new JointsData(vectors);
             jointsDataSequence.Add(jointsData);
         }
+
+        foreach(float f in recordingTimes)
+        {
+            recordingTimes.Add(f);
+        }
     }
 }

+ 105 - 12
Assets/Scripts/PlayerReplay.cs

@@ -1,3 +1,4 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
@@ -8,7 +9,9 @@ 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;
+    public Material transparentMat;
 
     private Dictionary<Kinect.JointType, Kinect.JointType> _BoneMap = new Dictionary<Kinect.JointType, Kinect.JointType>()
     {
@@ -42,26 +45,51 @@ public class PlayerReplay : MonoBehaviour
         { Kinect.JointType.Neck, Kinect.JointType.Head },
     };
 
-    public void AddJoints()
+    private GameObject body;
+    private bool beginAnimation;
+    private float t;
+
+    private void Update()
+    {
+        // TODO: wrong, put it to new class
+        if (!beginAnimation)
+            return;
+
+        t += Time.deltaTime / 2;
+        Color newColor = new Color(1, 1, 1, Mathf.Lerp(0, 1, t));
+
+        foreach (MeshRenderer mr in body.GetComponentsInChildren<MeshRenderer>())
+        {
+            mr.material.color = newColor;
+        }
+        foreach (LineRenderer lr in body.GetComponentsInChildren<LineRenderer>())
+        {
+            lr.startColor = newColor;
+            lr.endColor = newColor;
+        }
+    }
+
+    public void AddJoints(float recordingTime)
     {
         Vector3[] positions = new Vector3[25];
 
-        for(int i = 0; i < joints.Length; i++)
+        for (int i = 0; i < joints.Length; i++)
         {
             positions[i] = joints[i].position;
         }
 
         jointsSequence.Add(positions);
+        recordingTimes.Add(recordingTime);
     }
 
     public void Save()
     {
-        if(jointsSequence.Count == 0)
+        if (jointsSequence.Count == 0)
         {
             Debug.Log("jointsSequence is empty");
             return;
         }
-        SaveSystem.Save(jointsSequence);
+        SaveSystem.Save(jointsSequence, recordingTimes);
         Debug.Log("Save success");
     }
 
@@ -75,21 +103,68 @@ public class PlayerReplay : MonoBehaviour
             return;
         }
 
-        StartCoroutine(ShowJoints(data));
+        ShowJoints(data);
         Debug.Log("Load success");
     }
 
-    private IEnumerator ShowJoints(JointsDataSequence data)
+    private void ShowJoints(JointsDataSequence data)
     {
-        // Show joints one by one every 2 seconds
-        WaitForSeconds wait = new WaitForSeconds(2);
         List<JointsData> jointsData = data.jointsDataSequence;
-        int counter = 0;
+        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 if head joint
+                if (jt == Kinect.JointType.Head)
+                    continue;
 
-        foreach(JointsData jd in jointsData)
+                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 certain distance, add it to the replay, else ignore it
+                // TODO: need to test distance value
+                if (distance >= 2)
+                {
+                    newJointsData.Add(jd);
+                    newRecordingTimes.Add(recordingTimes[i]);
+                    prevJd = jd;
+                    continue;
+                }
+            }
+        }
+
+        // TODO: visualize need to test
+        StartCoroutine(Visualize(newJointsData, newRecordingTimes));
+    }
+
+    private IEnumerator Visualize(List<JointsData> newJointsData, List<float> newRecordingTimes)
+    {
+        for (int i = 0; i < newJointsData.Count; i++)
         {
+            float waitTime = 1;
+            if (i < newRecordingTimes.Count - 1)
+            {
+                waitTime = newRecordingTimes[i + 1] - newRecordingTimes[i];
+            }
+            WaitForSeconds wait = new WaitForSeconds(waitTime);
+
             // Create GameObject body
-            GameObject body = new GameObject("Recorded Body " + counter);
+            GameObject body = new GameObject("Recorded Body " + i);
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
                 // skip if head joint
@@ -106,6 +181,7 @@ public class PlayerReplay : MonoBehaviour
 
                 jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
                 jointObj.name = jt.ToString();
+                JointsData jd = newJointsData[i];
                 jointObj.transform.position = new Vector3(jd.jointsPositionsX[(int)jt], jd.jointsPositionsY[(int)jt], jd.jointsPositionsZ[(int)jt]);
                 jointObj.transform.parent = body.transform;
             }
@@ -126,7 +202,24 @@ public class PlayerReplay : MonoBehaviour
             }
 
             yield return wait;
-            counter++;
+            Destroy(body);
+        }
+    }
+
+    private IEnumerator VisualizeFadeIn(List<JointsData> newJointsData, List<float> newRecordingTimes)
+    {
+        for (int i = 0; i < newJointsData.Count; i++)
+        {
+            float waitTime = 1;
+            if (i < newRecordingTimes.Count - 1)
+            {
+                waitTime = newRecordingTimes[i + 1] - newRecordingTimes[i];
+            }
+            WaitForSeconds wait = new WaitForSeconds(waitTime);
+
+            // TODO: create new class to make every body run fade in
+
+            yield return wait;
             Destroy(body);
         }
     }

+ 2 - 2
Assets/Scripts/SaveSystem.cs

@@ -8,12 +8,12 @@ public static class SaveSystem
 {
     private static string path = Application.persistentDataPath + "/joints.sav";
 
-    public static void Save(List<Vector3[]> jointsSequence)
+    public static void Save(List<Vector3[]> jointsSequence, List<float> recordingTimes)
     {
         BinaryFormatter formatter = new BinaryFormatter();
         FileStream stream = new FileStream(path, FileMode.Create);
 
-        JointsDataSequence data = new JointsDataSequence(jointsSequence);
+        JointsDataSequence data = new JointsDataSequence(jointsSequence, recordingTimes);
         formatter.Serialize(stream, data);
         stream.Close();
     }

+ 48 - 0
Assets/Scripts/Testing.cs

@@ -0,0 +1,48 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Testing : MonoBehaviour
+{
+    public Material transparentMat;
+    public Material boneMaterial;
+    private GameObject obj;
+
+    private float t;
+    private int counter;
+
+    // Start is called before the first frame update
+    void Start()
+    {
+        obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
+        obj.GetComponent<MeshRenderer>().material = transparentMat;
+        LineRenderer lr = obj.AddComponent<LineRenderer>();
+        lr.positionCount = 2;
+        lr.material = boneMaterial;
+
+        Color line = new Color(1, 1, 1, 0);
+        lr.startColor = line;
+        lr.endColor = line;
+
+        lr.startWidth = 0.3f;
+        lr.endWidth = 0.3f;
+        lr.SetPosition(0, obj.transform.position);
+        lr.SetPosition(1, new Vector3(1,1,1));
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        if (t >= 1)
+        {
+            Destroy(obj);
+            return;
+        }
+            
+        t += Time.deltaTime / 2;
+        Color newColor = new Color(1, 1, 1, Mathf.Lerp(0, 1, t));
+        obj.GetComponent<MeshRenderer>().material.color = newColor;
+        obj.GetComponent<LineRenderer>().startColor = newColor;
+        obj.GetComponent<LineRenderer>().endColor = newColor;
+    }
+}

+ 11 - 0
Assets/Scripts/Testing.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2ad1483381ce54340b2627cca0fcec23
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 2
Assets/Scripts/ViveInput.cs

@@ -11,6 +11,9 @@ public class ViveInput : MonoBehaviour
     private SteamVR_Action_Boolean grabGrib;
     private SteamVR_Action_Boolean teleport;
 
+    private bool isRecording;
+    private float recordingTime;
+
     private void Start()
     {
         grabPinch = SteamVR_Actions.default_GrabPinch;
@@ -18,16 +21,18 @@ public class ViveInput : MonoBehaviour
         teleport = SteamVR_Actions.default_Teleport;
     }
 
-    // Update is called once per frame
     void Update()
     {
         if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
         {
-            playerReplay.AddJoints();
+            //playerReplay.AddJoints();
+            isRecording = true;
         }
 
         if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
         {
+            isRecording = false;
+            recordingTime = 0;
             playerReplay.Save();
         }
 
@@ -35,5 +40,11 @@ public class ViveInput : MonoBehaviour
         {
             playerReplay.Load();
         }
+
+        if (isRecording)
+        {
+            playerReplay.AddJoints(recordingTime);
+            recordingTime += Time.deltaTime;
+        }
     }
 }

+ 79 - 0
Assets/Transparent Material.mat

@@ -0,0 +1,79 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+  serializedVersion: 6
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: Transparent Material
+  m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
+  m_ShaderKeywords: _ALPHAPREMULTIPLY_ON
+  m_LightmapFlags: 4
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: 3000
+  stringTagMap:
+    RenderType: Transparent
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - _BumpMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailAlbedoMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailMask:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _DetailNormalMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _EmissionMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MainTex:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MetallicGlossMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _OcclusionMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _ParallaxMap:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Floats:
+    - _BumpScale: 1
+    - _Cutoff: 0.5
+    - _DetailNormalMapScale: 1
+    - _DstBlend: 10
+    - _GlossMapScale: 1
+    - _Glossiness: 0.5
+    - _GlossyReflections: 1
+    - _Metallic: 0
+    - _Mode: 3
+    - _OcclusionStrength: 1
+    - _Parallax: 0.02
+    - _SmoothnessTextureChannel: 0
+    - _SpecularHighlights: 1
+    - _SrcBlend: 1
+    - _UVSec: 0
+    - _ZWrite: 0
+    m_Colors:
+    - _Color: {r: 1, g: 1, b: 1, a: 0}
+    - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+  m_BuildTextureStacks: []

+ 8 - 0
Assets/Transparent Material.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 803645c956e5ae64a9b99ae13a11cd41
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 2100000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: