Browse Source

implement visualization and feedback

Kenkart 2 years ago
parent
commit
39428a405b

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

@@ -9,6 +9,10 @@ public class BodySourceView : MonoBehaviour
     public GameObject BodySourceManager;
     public Transform cameraRig;
     public PlayerReplay playerReplay;
+    public ModeController modeController;
+
+    public bool wristLeftLate;
+    public bool wristRightLate;
 
     private Dictionary<ulong, GameObject> _Bodies = new Dictionary<ulong, GameObject>();
     private BodySourceManager _BodyManager;
@@ -117,6 +121,19 @@ public class BodySourceView : MonoBehaviour
         {
             GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
 
+            // TODO: need to test
+            if (jt == Kinect.JointType.WristLeft)
+            {
+                jointObj.tag = "WristLeft";
+                Rigidbody rb = jointObj.AddComponent<Rigidbody>();
+                rb.useGravity = false;
+            } else if (jt == Kinect.JointType.WristRight)
+            {
+                jointObj.tag = "WristRight";
+                Rigidbody rb = jointObj.AddComponent<Rigidbody>();
+                rb.useGravity = false;
+            }
+
             LineRenderer lr = jointObj.AddComponent<LineRenderer>();
             //lr.SetVertexCount(2);
             lr.positionCount = 2;
@@ -152,8 +169,22 @@ 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);
+                // TODO: need to test
+                if (modeController.perspective == ModeController.Perspective.FirstPersonPerspective)
+                {
+                    cameraRig.localPosition = new Vector3(jointObj.localPosition.x, jointObj.localPosition.y, jointObj.localPosition.z);
+                } else
+                {
+                    cameraRig.localPosition = new Vector3(jointObj.localPosition.x, jointObj.localPosition.y - 3, jointObj.localPosition.z + 2);
+                }
+            }
+
+            // TODO: need to test
+            if ((jt == Kinect.JointType.WristLeft && wristLeftLate) || (jt == Kinect.JointType.WristRight && wristRightLate))
+            {
+                jointObj.GetComponent<Renderer>().material.color = new Color(1, 0, 0);
             }
 
             LineRenderer lr = jointObj.GetComponent<LineRenderer>();
@@ -161,6 +192,7 @@ 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);

+ 302 - 203
Assets/Scenes/Main.unity

@@ -178,8 +178,10 @@ MonoBehaviour:
   - {fileID: 0}
   - {fileID: 0}
   - {fileID: 0}
+  recordingTimes: []
   boneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
   transparentMat: {fileID: 2100000, guid: 803645c956e5ae64a9b99ae13a11cd41, type: 2}
+  vfi: {fileID: 1896464126}
 --- !u!4 &65057766
 Transform:
   m_ObjectHideFlags: 0
@@ -256,11 +258,11 @@ PrefabInstance:
     - target: {fileID: 2348914, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Materials.Array.data[0]
       value: 
-      objectReference: {fileID: 1307535905}
+      objectReference: {fileID: 262321325}
     - target: {fileID: 3380982, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
       propertyPath: m_Mesh
       value: 
-      objectReference: {fileID: 1343328533}
+      objectReference: {fileID: 211536591}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 4d293c8e162f3874b982baadd71153d2, type: 3}
 --- !u!4 &110216683 stripped
@@ -302,6 +304,9 @@ MonoBehaviour:
   BodySourceManager: {fileID: 2078274386}
   cameraRig: {fileID: 110216683}
   playerReplay: {fileID: 65057765}
+  modeController: {fileID: 815386528}
+  leftWristLate: 0
+  rightWristLate: 0
 --- !u!4 &189736996
 Transform:
   m_ObjectHideFlags: 0
@@ -316,6 +321,205 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!43 &211536591
+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!21 &262321325
+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!1 &573329778
 GameObject:
   m_ObjectHideFlags: 0
@@ -360,6 +564,51 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 8
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &815386527
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 815386529}
+  - component: {fileID: 815386528}
+  m_Layer: 0
+  m_Name: ModeController
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &815386528
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 815386527}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 1d71a394b8fb98e4fa49bede70070e0d, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  perspective: 1
+  feedback: 0
+--- !u!4 &815386529
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 815386527}
+  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: 11
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1001 &833043381
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -575,6 +824,9 @@ MonoBehaviour:
   BodySourceManager: {fileID: 2078274386}
   cameraRig: {fileID: 110216683}
   playerReplay: {fileID: 0}
+  modeController: {fileID: 0}
+  leftWristLate: 0
+  rightWristLate: 0
 --- !u!1001 &841858134
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -636,205 +888,6 @@ 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
@@ -939,12 +992,12 @@ GameObject:
   - component: {fileID: 1754081258}
   - component: {fileID: 1754081257}
   m_Layer: 0
-  m_Name: GameObject
+  m_Name: TestingFadeIn
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!114 &1754081257
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -1069,6 +1122,52 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 6
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1896464125
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1896464127}
+  - component: {fileID: 1896464126}
+  m_Layer: 0
+  m_Name: Visualizer_FadeIn
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &1896464126
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1896464125}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3d7011591743c8741b52e2fa708373ca, 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 &1896464127
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1896464125}
+  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: 10
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &2078274386
 GameObject:
   m_ObjectHideFlags: 0

+ 22 - 0
Assets/Scripts/ModeController.cs

@@ -0,0 +1,22 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class ModeController : MonoBehaviour
+{
+    public enum Perspective
+    {
+        FirstPersonPerspective,
+        ThirdPersonPerspective
+    };
+
+    public enum Feedback
+    {
+        NoFeedback,
+        ColorFeedback,
+        HapticFeedback
+    }
+
+    public Perspective perspective;
+    public Feedback feedback;
+}

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

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

+ 11 - 29
Assets/Scripts/PlayerReplay.cs

@@ -14,6 +14,8 @@ public class PlayerReplay : MonoBehaviour
     public Material boneMaterial;
     public Material transparentMat;
 
+    public Visualizer_FadeIn vfi;
+
     private Dictionary<Kinect.JointType, Kinect.JointType> _BoneMap = new Dictionary<Kinect.JointType, Kinect.JointType>()
     {
         { Kinect.JointType.FootLeft, Kinect.JointType.AnkleLeft },
@@ -46,30 +48,6 @@ public class PlayerReplay : MonoBehaviour
         { Kinect.JointType.Neck, Kinect.JointType.Head },
     };
 
-    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];
@@ -135,8 +113,10 @@ public class PlayerReplay : MonoBehaviour
 
             for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
             {
-                // Skip if head joint
-                if (jt == Kinect.JointType.Head)
+                // 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]);
@@ -154,7 +134,8 @@ public class PlayerReplay : MonoBehaviour
             }
         }
 
-        StartCoroutine(Visualize(newJointsData, newRecordingTimes));
+        //StartCoroutine(Visualize(newJointsData, newRecordingTimes));
+        StartCoroutine(VisualizeFadeIn(newJointsData, newRecordingTimes));
     }
 
     private IEnumerator Visualize(List<JointsData> newJointsData, List<float> newRecordingTimes)
@@ -222,10 +203,11 @@ public class PlayerReplay : MonoBehaviour
             }
             WaitForSeconds wait = new WaitForSeconds(waitTime);
 
-            // TODO: create new class to make every body run fade in
+            Visualizer_FadeIn body = Instantiate(vfi) as Visualizer_FadeIn;
+            body.SetData(newJointsData[i]);
+            body.ShowBody();
 
             yield return wait;
-            Destroy(body);
         }
     }
 }

+ 0 - 1
Assets/Scripts/Testing.cs

@@ -9,7 +9,6 @@ public class Testing : MonoBehaviour
     private GameObject obj;
 
     private float t;
-    private int counter;
 
     // Start is called before the first frame update
     void Start()

+ 32 - 0
Assets/Scripts/TriggerDetector.cs

@@ -0,0 +1,32 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TriggerDetector : MonoBehaviour
+{
+    
+
+    private void OnTriggerEnter(Collider other)
+    {
+        // TODO: need to test
+        if (other.CompareTag("WristLeft"))
+        {
+            Debug.Log("WristLeft triggered");
+            other.GetComponent<Renderer>().material.color = new Color(1, 1, 1);
+            BodySourceView bsv = other.GetComponentInParent<BodySourceView>();
+            bsv.wristLeftLate = false;
+            Visualizer_FadeIn vfi = GetComponentInParent<Visualizer_FadeIn>();
+            vfi.wristLeftTriggered = true;
+        }
+
+        if (other.CompareTag("WristRight"))
+        {
+            Debug.Log("WristRight triggered");
+            other.GetComponent<Renderer>().material.color = new Color(1, 1, 1);
+            BodySourceView bsv = other.GetComponentInParent<BodySourceView>();
+            bsv.wristRightLate = false;
+            Visualizer_FadeIn vfi = GetComponentInParent<Visualizer_FadeIn>();
+            vfi.wristRightTriggered = true;
+        }
+    }
+}

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

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

+ 152 - 0
Assets/Scripts/Visualizer_FadeIn.cs

@@ -0,0 +1,152 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using Kinect = Windows.Kinect;
+
+public class Visualizer_FadeIn : MonoBehaviour
+{
+    public Material boneMaterial;
+    public Material transparentMat;
+    public BodySourceView bsv;
+
+    public bool wristLeftTriggered;
+    public bool wristRightTriggered;
+
+    private JointsData data;
+    private Dictionary<Kinect.JointType, Kinect.JointType> _BoneMap = new Dictionary<Kinect.JointType, Kinect.JointType>()
+    {
+        { Kinect.JointType.FootLeft, Kinect.JointType.AnkleLeft },
+        { Kinect.JointType.AnkleLeft, Kinect.JointType.KneeLeft },
+        { Kinect.JointType.KneeLeft, Kinect.JointType.HipLeft },
+        { Kinect.JointType.HipLeft, Kinect.JointType.SpineBase },
+
+        { Kinect.JointType.FootRight, Kinect.JointType.AnkleRight },
+        { Kinect.JointType.AnkleRight, Kinect.JointType.KneeRight },
+        { Kinect.JointType.KneeRight, Kinect.JointType.HipRight },
+        { Kinect.JointType.HipRight, Kinect.JointType.SpineBase },
+
+        { Kinect.JointType.HandTipLeft, Kinect.JointType.HandLeft },
+        { Kinect.JointType.ThumbLeft, Kinect.JointType.HandLeft },
+        { Kinect.JointType.HandLeft, Kinect.JointType.WristLeft },
+        { Kinect.JointType.WristLeft, Kinect.JointType.ElbowLeft },
+        { Kinect.JointType.ElbowLeft, Kinect.JointType.ShoulderLeft },
+        { Kinect.JointType.ShoulderLeft, Kinect.JointType.SpineShoulder },
+
+        { Kinect.JointType.HandTipRight, Kinect.JointType.HandRight },
+        { Kinect.JointType.ThumbRight, Kinect.JointType.HandRight },
+        { Kinect.JointType.HandRight, Kinect.JointType.WristRight },
+        { Kinect.JointType.WristRight, Kinect.JointType.ElbowRight },
+        { Kinect.JointType.ElbowRight, Kinect.JointType.ShoulderRight },
+        { Kinect.JointType.ShoulderRight, Kinect.JointType.SpineShoulder },
+
+        { Kinect.JointType.SpineBase, Kinect.JointType.SpineMid },
+        { Kinect.JointType.SpineMid, Kinect.JointType.SpineShoulder },
+        { Kinect.JointType.SpineShoulder, Kinect.JointType.Neck },
+        { Kinect.JointType.Neck, Kinect.JointType.Head },
+    };
+
+    private float t;
+    private List<GameObject> jointObjs = new List<GameObject>();
+    private bool beginUpdate;
+    private GameObject body;
+
+    void Update()
+    {
+        if (!beginUpdate)
+            return;
+        
+        if (t >= 1)
+        {
+            Destroy(body);
+            Destroy(gameObject);
+            return;
+        }
+
+        t += Time.deltaTime / 2;
+        Color newColor = new Color(1, 1, 1, Mathf.Lerp(0, 1, t));
+
+        foreach(GameObject go in jointObjs)
+        {
+            go.GetComponent<MeshRenderer>().material.color = newColor;
+            go.GetComponent<LineRenderer>().startColor = newColor;
+            go.GetComponent<LineRenderer>().endColor = newColor;
+        }
+
+        // TODO: need to test
+        if (t > 0.5f)
+        {
+            if (!wristLeftTriggered)
+            {
+                bsv.wristLeftLate = true;
+            }
+            if (!wristRightTriggered)
+            {
+                bsv.wristRightLate = true;
+            }
+        }
+    }
+
+    public void SetData(JointsData data)
+    {
+        this.data = data;
+    }
+
+    public void ShowBody()
+    {
+        // Create GameObject body
+        body = new GameObject("Recorded Body (Visualizer_FadeIn)");
+        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;
+
+            // Create GameObject cubes for joints
+            GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
+            jointObj.GetComponent<MeshRenderer>().material = transparentMat;
+
+            // TODO: need to test
+            if (jt == Kinect.JointType.WristLeft || jt == Kinect.JointType.WristRight)
+            {
+                jointObj.GetComponent<BoxCollider>().isTrigger = true;
+                jointObj.AddComponent<TriggerDetector>();
+            }
+
+            LineRenderer lr = jointObj.AddComponent<LineRenderer>();
+            lr.positionCount = 2;
+            lr.material = boneMaterial;
+            lr.startWidth = 0.3f;
+            lr.endWidth = 0.3f;
+
+            jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
+            jointObj.name = jt.ToString();
+            jointObj.transform.position = new Vector3(data.jointsPositionsX[(int)jt], data.jointsPositionsY[(int)jt], data.jointsPositionsZ[(int)jt]);
+            jointObj.transform.parent = body.transform;
+
+            // Add to list
+            jointObjs.Add(jointObj);
+        }
+
+        // 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 other these joints
+            if (!_BoneMap.ContainsKey(jt) || jt == Kinect.JointType.Neck
+                || 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;
+
+            Transform jointObj = body.transform.Find(jt.ToString());
+            Transform targetJoint = body.transform.Find(_BoneMap[jt].ToString());
+            LineRenderer lr = jointObj.GetComponent<LineRenderer>();
+
+            lr.SetPosition(0, jointObj.localPosition);
+            lr.SetPosition(1, targetJoint.localPosition);
+        }
+
+        beginUpdate = true;
+    }
+}

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

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