Explorar el Código

rework system

Kenkart hace 2 años
padre
commit
ee79b78167

+ 163 - 161
Assets/Scenes/Main.unity

@@ -751,6 +751,7 @@ MonoBehaviour:
   vfis: {fileID: 1143995017}
   bc: {fileID: 336955516}
   startStepPreview: {fileID: 1821857529}
+  mc: {fileID: 815386528}
   textFinish: {fileID: 840362527}
 --- !u!4 &65057766
 Transform:
@@ -914,11 +915,11 @@ PrefabInstance:
     - target: {fileID: 2348914, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Materials.Array.data[0]
       value: 
-      objectReference: {fileID: 110385439}
+      objectReference: {fileID: 2016484135}
     - target: {fileID: 3380982, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Mesh
       value: 
-      objectReference: {fileID: 1152508210}
+      objectReference: {fileID: 1118073685}
     - target: {fileID: 4000013889601590, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_LocalPosition.y
       value: 1
@@ -934,41 +935,6 @@ Transform:
   m_CorrespondingSourceObject: {fileID: 420908, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
   m_PrefabInstance: {fileID: 110216682}
   m_PrefabAsset: {fileID: 0}
---- !u!21 &110385439
-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 &113186067
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -3863,6 +3829,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   perspective: 0
   feedback: 1
+  speed: 0
   monitors: {fileID: 1439097805}
 --- !u!4 &815386529
 Transform:
@@ -5567,130 +5534,7 @@ PrefabInstance:
       objectReference: {fileID: 2100000, guid: f38c3a4df1a13aa43aa34ed48cb326f7, type: 2}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: c90faeda1ce307e418ee73344aa5e431, type: 3}
---- !u!1001 &1124103262
-PrefabInstance:
-  m_ObjectHideFlags: 0
-  serializedVersion: 2
-  m_Modification:
-    m_TransformParent: {fileID: 226099530}
-    m_Modifications:
-    - target: {fileID: 5040540905546997027, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_Name
-      value: floor (10)
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_RootOrder
-      value: 31
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalPosition.x
-      value: 7.662301
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalPosition.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalPosition.z
-      value: -3.8309991
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalRotation.w
-      value: 1
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalRotation.x
-      value: 0.000000021855694
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalRotation.y
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalRotation.z
-      value: -0
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalEulerAnglesHint.x
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalEulerAnglesHint.y
-      value: 0
-      objectReference: {fileID: 0}
-    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
-      propertyPath: m_LocalEulerAnglesHint.z
-      value: 0
-      objectReference: {fileID: 0}
-    m_RemovedComponents: []
-  m_SourcePrefab: {fileID: 100100000, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
---- !u!4 &1125945978 stripped
-Transform:
-  m_CorrespondingSourceObject: {fileID: 2528327074000149298, guid: 3f4814451272e874f9d7dc1534b22b63, type: 3}
-  m_PrefabInstance: {fileID: 43447574}
-  m_PrefabAsset: {fileID: 0}
---- !u!4 &1134348691 stripped
-Transform:
-  m_CorrespondingSourceObject: {fileID: 2478961553079219844, guid: b4f729d9618a65543baedfac3b0a7311, type: 3}
-  m_PrefabInstance: {fileID: 652249659}
-  m_PrefabAsset: {fileID: 0}
---- !u!4 &1141878299 stripped
-Transform:
-  m_CorrespondingSourceObject: {fileID: 7213181755310212143, guid: c90faeda1ce307e418ee73344aa5e431, type: 3}
-  m_PrefabInstance: {fileID: 2009323194}
-  m_PrefabAsset: {fileID: 0}
---- !u!1 &1143995016
-GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 1143995018}
-  - component: {fileID: 1143995017}
-  m_Layer: 0
-  m_Name: Visualizer_FadeInSeries
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 1
---- !u!114 &1143995017
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1143995016}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 07434bc363a59a34f950591f091e038f, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  boneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
-  transparentMat: {fileID: 2100000, guid: 803645c956e5ae64a9b99ae13a11cd41, type: 2}
-  bsv: {fileID: 189736995}
---- !u!4 &1143995018
-Transform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1143995016}
-  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
-  m_LocalPosition: {x: 0, y: 0, z: 0}
-  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!4 &1146542644 stripped
-Transform:
-  m_CorrespondingSourceObject: {fileID: 5675013305860159573, guid: 2f3fe288da751a2428fc82d8e5ed9f7e, type: 3}
-  m_PrefabInstance: {fileID: 30691926}
-  m_PrefabAsset: {fileID: 0}
---- !u!43 &1152508210
+--- !u!43 &1118073685
 Mesh:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
@@ -5854,6 +5698,129 @@ Mesh:
     offset: 0
     size: 0
     path: 
+--- !u!1001 &1124103262
+PrefabInstance:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_Modification:
+    m_TransformParent: {fileID: 226099530}
+    m_Modifications:
+    - target: {fileID: 5040540905546997027, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_Name
+      value: floor (10)
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_RootOrder
+      value: 31
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalPosition.x
+      value: 7.662301
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalPosition.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalPosition.z
+      value: -3.8309991
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalRotation.w
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalRotation.x
+      value: 0.000000021855694
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalRotation.y
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalRotation.z
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.z
+      value: 0
+      objectReference: {fileID: 0}
+    m_RemovedComponents: []
+  m_SourcePrefab: {fileID: 100100000, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
+--- !u!4 &1125945978 stripped
+Transform:
+  m_CorrespondingSourceObject: {fileID: 2528327074000149298, guid: 3f4814451272e874f9d7dc1534b22b63, type: 3}
+  m_PrefabInstance: {fileID: 43447574}
+  m_PrefabAsset: {fileID: 0}
+--- !u!4 &1134348691 stripped
+Transform:
+  m_CorrespondingSourceObject: {fileID: 2478961553079219844, guid: b4f729d9618a65543baedfac3b0a7311, type: 3}
+  m_PrefabInstance: {fileID: 652249659}
+  m_PrefabAsset: {fileID: 0}
+--- !u!4 &1141878299 stripped
+Transform:
+  m_CorrespondingSourceObject: {fileID: 7213181755310212143, guid: c90faeda1ce307e418ee73344aa5e431, type: 3}
+  m_PrefabInstance: {fileID: 2009323194}
+  m_PrefabAsset: {fileID: 0}
+--- !u!1 &1143995016
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1143995018}
+  - component: {fileID: 1143995017}
+  m_Layer: 0
+  m_Name: Visualizer_FadeInSeries
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &1143995017
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1143995016}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 07434bc363a59a34f950591f091e038f, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  boneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
+  transparentMat: {fileID: 2100000, guid: 803645c956e5ae64a9b99ae13a11cd41, type: 2}
+  bsv: {fileID: 189736995}
+--- !u!4 &1143995018
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1143995016}
+  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  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!4 &1146542644 stripped
+Transform:
+  m_CorrespondingSourceObject: {fileID: 5675013305860159573, guid: 2f3fe288da751a2428fc82d8e5ed9f7e, type: 3}
+  m_PrefabInstance: {fileID: 30691926}
+  m_PrefabAsset: {fileID: 0}
 --- !u!4 &1155694275 stripped
 Transform:
   m_CorrespondingSourceObject: {fileID: 5672364630614476697, guid: a8d819c88b06d5d479cad532c162c475, type: 3}
@@ -9528,6 +9495,41 @@ PrefabInstance:
       objectReference: {fileID: 2100000, guid: f38c3a4df1a13aa43aa34ed48cb326f7, type: 2}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: c90faeda1ce307e418ee73344aa5e431, type: 3}
+--- !u!21 &2016484135
+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!4 &2022921533 stripped
 Transform:
   m_CorrespondingSourceObject: {fileID: 7589819978036697002, guid: d7cd5c7975835a14cae4bcbafa34bd4b, type: 3}

+ 9 - 2
Assets/Scripts/BodyComparer.cs

@@ -79,9 +79,9 @@ public class BodyComparer : MonoBehaviour
                     if (mc.feedback == ModeController.Feedback.ColorFeedback)
                     {
                         body.GetChild((int)jt).GetComponent<Renderer>().material.color = Color.red;
-                    } else if (mc.feedback == ModeController.Feedback.HapticFeedback)
+                    }
+                    else if (mc.feedback == ModeController.Feedback.HapticFeedback)
                     {
-                        // TODO: Haptic feedback
                         if (jt == Kinect.JointType.WristLeft)
                         {
                             SteamVR_Actions.default_Haptic[SteamVR_Input_Sources.LeftHand].Execute(0, 0.1f, 10, 1);
@@ -160,6 +160,10 @@ public class BodyComparer : MonoBehaviour
                 waitTime = recordingTimesDemo[i + 1] - recordingTimesDemo[i];
             }
 
+            // TODO: need to test
+            if (mc.speed == ModeController.Speed.Fast)
+                waitTime /= 2;
+
             yield return new WaitForSeconds(waitTime);
         }
 
@@ -183,5 +187,8 @@ public class BodyComparer : MonoBehaviour
     {
         Debug.Log("Save to CSV");
         CSVWriter.WriteCSV(posJointsDemos, posJointsBodys, csvTimes, mc);
+        posJointsDemos.Clear();
+        posJointsBodys.Clear();
+        csvTimes.Clear();
     }
 }

+ 3 - 2
Assets/Scripts/CSVWriter.cs

@@ -5,7 +5,7 @@ using UnityEngine;
 
 public static class CSVWriter
 {
-    private static string path = Application.dataPath + "/data";
+    private static string path = Path.GetDirectoryName(Application.dataPath) + "/DataCSV/name/";
 
     public static void WriteCSV(List<List<Vector3>> posJointsDemos, List<List<Vector3>> posJointsBodys, List<float> csvTimes, ModeController mc)
     {
@@ -22,7 +22,8 @@ public static class CSVWriter
             bodys += "Body_" + name + ",";
         }
 
-        path += "_" + mc.perspective.ToString() + "_" + mc.feedback.ToString() + ".csv";
+        path += mc.perspective.ToString() + "_" + mc.complexity.ToString() + "_" + mc.direction.ToString() + "_"
+            + mc.feedback.ToString() + "_" + mc.speed.ToString() + ".csv";
         StreamWriter sw = new StreamWriter(path);
         sw.WriteLine(demos + bodys + "time");
 

+ 24 - 1
Assets/Scripts/ModeController.cs

@@ -11,15 +11,38 @@ public class ModeController : MonoBehaviour
         ThirdPersonPerspectiveWithMultipleViews
     };
 
+    public enum Complexity
+    {
+        OneArm,
+        TwoArms,
+        TwoArmsPlusLeg
+    }
+
+    public enum Direction
+    {
+        Sideways,
+        Forward,
+        Backward
+    }
+
     public enum Feedback
     {
-        NoFeedback,
+        None,
         ColorFeedback,
         HapticFeedback
     }
 
+    public enum Speed
+    {
+        Slow,
+        Fast
+    }
+
     public Perspective perspective;
+    public Complexity complexity;
+    public Direction direction;
     public Feedback feedback;
+    public Speed speed;
 
     public GameObject monitors;
 

+ 142 - 112
Assets/Scripts/PlayerReplay.cs

@@ -17,6 +17,7 @@ public class PlayerReplay : MonoBehaviour
     public Visualizer_FadeInSeries vfis;
     public BodyComparer bc;
     public StartStepPreview startStepPreview;
+    public ModeController mc;
 
     public GameObject textFinish;
 
@@ -84,16 +85,81 @@ public class PlayerReplay : MonoBehaviour
 
     public void Load()
     {
-        JointsDataSequence data = SaveSystem.Load();
+        string[] complexity = { "OneArm", "TwoArms", "TwoArmsPlusLeg" };
+        string[] direction = { "Sideways", "Forward", "Backward" };
+        string[] feedback = { "None", "Color", "Haptic" };
+        string[] speed = { "Slow", "Fast" };
+        List<string> config = new List<string>();
 
-        if (data == null)
+        for (int i = 0; i < complexity.Length; i++)
         {
-            Debug.Log("Load failed");
-            return;
+            for (int j = 0; j < direction.Length; j++)
+            {
+                for (int k = 0; k < feedback.Length; k++)
+                {
+                    for (int l = 0; l < speed.Length; l++)
+                    {
+                        config.Add(complexity[i] + ";" + direction[j] + ";" + feedback[k] + ";" + speed[l]);
+                    }
+                }
+            }
         }
 
-        ShowJoints(data);
-        Debug.Log("Load success");
+        // Shuffle config list
+        System.Random rand = new System.Random();
+        int n = config.Count;
+        while (n > 1)
+        {
+            n--;
+            int k = rand.Next(n + 1);
+            string value = config[k];
+            config[k] = config[n];
+            config[n] = value;
+        }
+
+
+        foreach (string s in config)
+        {
+            string[] subs = s.Split(';');
+            string path = Application.dataPath + "/Recordings/" + subs[0] + "_" + subs[1] + ".csv";
+
+            if (subs[0] == "OneArm")
+                mc.complexity = ModeController.Complexity.OneArm;
+            else if (subs[0] == "TwoArms")
+                mc.complexity = ModeController.Complexity.TwoArms;
+            else
+                mc.complexity = ModeController.Complexity.TwoArmsPlusLeg;
+
+            if (subs[1] == "Sideways")
+                mc.direction = ModeController.Direction.Sideways;
+            else if (subs[1] == "Forward")
+                mc.direction = ModeController.Direction.Forward;
+            else
+                mc.direction = ModeController.Direction.Backward;
+
+            if (subs[2] == "None")
+                mc.feedback = ModeController.Feedback.None;
+            else if (subs[2] == "Color")
+                mc.feedback = ModeController.Feedback.ColorFeedback;
+            else
+                mc.feedback = ModeController.Feedback.HapticFeedback;
+
+            mc.speed = subs[3] == "Slow" ? ModeController.Speed.Slow : ModeController.Speed.Fast;
+
+            JointsDataSequence data = SaveSystem.Load(path);
+
+            if (data == null)
+            {
+                Debug.Log("Load failed");
+                return;
+            }
+
+            ShowJoints(data);
+        }
+
+        textFinish.SetActive(true);
+        Debug.Log("Load finish");
+        ViveInput.StopPlaying();
     }
 
     private void ShowJoints(JointsDataSequence data)
@@ -107,13 +173,6 @@ public class PlayerReplay : MonoBehaviour
     {
         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 Demo " + i);
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
@@ -166,7 +225,17 @@ public class PlayerReplay : MonoBehaviour
                 lr.SetPosition(1, targetJoint.localPosition);
             }
 
-            yield return wait;
+            float waitTime = 1;
+            if (i < newRecordingTimes.Count - 1)
+            {
+                waitTime = newRecordingTimes[i + 1] - newRecordingTimes[i];
+            }
+
+            // TODO: need to test
+            if (mc.speed == ModeController.Speed.Fast)
+                waitTime /= 2;
+
+            yield return new WaitForSeconds(waitTime);
             Destroy(body);
         }
     }
@@ -192,131 +261,92 @@ public class PlayerReplay : MonoBehaviour
 
     private IEnumerator VisualizeFadeInSeries(List<JointsData> jointsData, List<float> recordingTimes)
     {
-        float waitTime = 3;
-        List<JointsData> jointsDataDemo = new List<JointsData>();
-        List<float> recordingTimesDemo = new List<float>();
-        int indexDemo = 0;
-        bool finish = false;
+        // Visualization demo
+        yield return Visualize(jointsData, recordingTimes);
 
-        while (true)
-        {
-            for (int i = indexDemo; i < jointsData.Count; i++)
-            {
-                if (recordingTimes[i] < waitTime)
-                {
-                    jointsDataDemo.Add(jointsData[i]);
-                    recordingTimesDemo.Add(recordingTimes[i]);
-                    finish = true;
-                }
-                else
-                {
-                    indexDemo = i;
-                    waitTime += 3;
-                    finish = false;
-                    break;
-                }
-            }
+        bc.SetDataDemo(jointsData, recordingTimes);
 
-            // Visualization demo
-            yield return Visualize(jointsDataDemo, recordingTimesDemo);
+        // Visualization steps/series
 
-            bc.SetDataDemo(jointsDataDemo, recordingTimesDemo);
+        // Filtered datas according to distance
+        List<JointsData> filteredJointsData = new List<JointsData>();
+        List<float> filteredRecordingTimes = new List<float>();
 
-            // Visualization steps/series
+        JointsData prevJd = jointsData[0];
 
-            // Filtered datas according to distance
-            List<JointsData> filteredJointsData = new List<JointsData>();
-            List<float> filteredRecordingTimes = new List<float>();
+        // Add first pose
+        filteredJointsData.Add(jointsData[0]);
+        filteredRecordingTimes.Add(recordingTimes[0]);
 
-            JointsData prevJd = jointsDataDemo[0];
-
-            // Add first pose
-            filteredJointsData.Add(jointsDataDemo[0]);
-            filteredRecordingTimes.Add(recordingTimesDemo[0]);
+        for (int i = 1; i < jointsData.Count; i++)
+        {
+            JointsData jd = jointsData[i];
 
-            for (int i = 1; i < jointsDataDemo.Count; i++)
+            for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
-                JointsData jd = jointsDataDemo[i];
-
-                for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
-                {
-                    // Skip these joints
-                    if (jt == Kinect.JointType.Head || jt == Kinect.JointType.ThumbLeft || jt == Kinect.JointType.ThumbRight
-                        || jt == Kinect.JointType.HandLeft || jt == Kinect.JointType.HandRight
-                        || jt == Kinect.JointType.HandTipLeft || jt == Kinect.JointType.HandTipRight)
-                        continue;
+                // Skip these joints
+                if (jt == Kinect.JointType.Head || jt == Kinect.JointType.ThumbLeft || jt == Kinect.JointType.ThumbRight
+                    || jt == Kinect.JointType.HandLeft || jt == Kinect.JointType.HandRight
+                    || jt == Kinect.JointType.HandTipLeft || jt == Kinect.JointType.HandTipRight)
+                    continue;
 
-                    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);
+                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 a certain distance, add it to the replay, else ignore it
-                    if (distance >= 0.15f)
-                    {
-                        filteredJointsData.Add(jd);
-                        filteredRecordingTimes.Add(recordingTimesDemo[i]);
-                        prevJd = jd;
-                        continue;
-                    }
+                // If a joint is bigger than a certain distance, add it to the replay, else ignore it
+                if (distance >= 0.15f)
+                {
+                    filteredJointsData.Add(jd);
+                    filteredRecordingTimes.Add(recordingTimes[i]);
+                    prevJd = jd;
+                    continue;
                 }
             }
+        }
 
-            // Add last step of demo
-            filteredJointsData.Add(jointsDataDemo[jointsDataDemo.Count - 1]);
-
-            // Show start position of steps
-            startStepPreview.SetData(filteredJointsData[0]);
-            startStepPreview.ShowBody();
-
-            // Wait for input
-            yield return ViveInput.WaitForControllerPress();
-
-            // Delete start position of steps
-            startStepPreview.DeleteBody();
+        // Add last step of demo
+        filteredJointsData.Add(jointsData[jointsData.Count - 1]);
 
-            Visualizer_FadeInSeries body = Instantiate(vfis) as Visualizer_FadeInSeries;
-            body.transform.parent = gameObject.transform;
-            body.SetData(filteredJointsData, filteredRecordingTimes);
-            body.ShowBody();
+        // Show start position of steps
+        startStepPreview.SetData(filteredJointsData[0]);
+        startStepPreview.ShowBody();
 
-            // Compare visualization demo with body
-            yield return bc.StartCompare();
+        // Wait for input
+        yield return ViveInput.WaitForControllerPress();
 
-            // Clear list
-            jointsDataDemo.Clear();
-            recordingTimesDemo.Clear();
+        // Delete start position of steps
+        startStepPreview.DeleteBody();
 
-            // Input for end steps. Wait for input if finish comparing. Don't wait for input if comparing is interupted.
-            if (!bc.endStepsPressed)
-            {
-                // Unknown reason, need 2 times (not working if only 1)
-                yield return ViveInput.WaitForControllerPress();
-                yield return ViveInput.WaitForControllerPress();
-            }
-            else
-            {
-                // Reset
-                bc.endStepsPressed = false;
-            }
+        Visualizer_FadeInSeries body = Instantiate(vfis) as Visualizer_FadeInSeries;
+        body.transform.parent = gameObject.transform;
+        body.SetData(filteredJointsData, filteredRecordingTimes);
+        body.ShowBody();
 
-            Destroy(body);
+        // Compare visualization demo with body
+        yield return bc.StartCompare();
 
-            // Wait for input
+        // Input for end steps. Wait for input if finish comparing. Don't wait for input if comparing is interupted.
+        if (!bc.endStepsPressed)
+        {
             // Unknown reason, need 2 times (not working if only 1)
             yield return ViveInput.WaitForControllerPress();
             yield return ViveInput.WaitForControllerPress();
-
-            if (finish)
-                break;
+        }
+        else
+        {
+            // Reset
+            bc.endStepsPressed = false;
         }
 
-        textFinish.SetActive(true);
-        yield return new WaitForSeconds(3);
-        textFinish.SetActive(false);
+        Destroy(body);
 
         // Write positions to csv
         bc.WriteCSV();
 
-        ViveInput.StopPlaying();
+        // Wait for input
+        // Unknown reason, need 2 times (not working if only 1)
+        yield return ViveInput.WaitForControllerPress();
+        yield return ViveInput.WaitForControllerPress();
     }
 }

+ 2 - 2
Assets/Scripts/SaveSystem.cs

@@ -6,7 +6,7 @@ using UnityEngine;
 
 public static class SaveSystem
 {
-    private static readonly string path = Application.dataPath + "/joints.sav";
+    private static readonly string path = Application.dataPath + "/Recordings/OneArm_Sideways.sav";
 
     public static void Save(List<Vector3[]> jointsSequence, List<float> recordingTimes)
     {
@@ -18,7 +18,7 @@ public static class SaveSystem
         stream.Close();
     }
 
-    public static JointsDataSequence Load()
+    public static JointsDataSequence Load(string path)
     {
         if (File.Exists(path))
         {

+ 0 - 18
Assets/Scripts/ViveInput.cs

@@ -67,24 +67,6 @@ public class ViveInput : MonoBehaviour
         {
             csvTime += Time.deltaTime;
         }
-
-        // TODO: Test haptic
-        if (Input.GetKeyDown(KeyCode.Q))
-        {
-            SteamVR_Actions.default_Haptic[SteamVR_Input_Sources.LeftHand].Execute(0, 1, 10, 1);
-        }
-        if (Input.GetKeyDown(KeyCode.W))
-        {
-            SteamVR_Actions.default_Haptic[SteamVR_Input_Sources.RightHand].Execute(0, 1, 10, 1);
-        }
-        if (Input.GetKeyDown(KeyCode.E))
-        {
-            SteamVR_Actions.default_Haptic[SteamVR_Input_Sources.LeftFoot].Execute(0, 1, 10, 1);
-        }
-        if (Input.GetKeyDown(KeyCode.R))
-        {
-            SteamVR_Actions.default_Haptic[SteamVR_Input_Sources.RightFoot].Execute(0, 1, 10, 1);
-        }
     }
 
     public static IEnumerator WaitForControllerPress()