diff --git a/Build/Kinect2Motion_binary/Kinect2Motion-KinectV2.exe b/Build/Kinect2Motion_binary/Kinect2Motion-KinectV2.exe index 7b27bbf..7093024 100644 Binary files a/Build/Kinect2Motion_binary/Kinect2Motion-KinectV2.exe and b/Build/Kinect2Motion_binary/Kinect2Motion-KinectV2.exe differ diff --git a/Unity_2018_Frozen/Assets/Frozen/Frozen.unity b/Unity_2018_Frozen/Assets/Frozen/Frozen.unity index c77e50b..758c8d3 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Frozen.unity +++ b/Unity_2018_Frozen/Assets/Frozen/Frozen.unity @@ -205,7 +205,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &145750430 GameObject: @@ -233,7 +233,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 9 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &147055504 GameObject: @@ -595,7 +595,7 @@ Transform: m_Children: - {fileID: 917676528} m_Father: {fileID: 0} - m_RootOrder: 15 + m_RootOrder: 16 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &350883107 GameObject: @@ -713,7 +713,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 10 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!1 &386695295 GameObject: @@ -743,8 +743,9 @@ Transform: - {fileID: 774429924} - {fileID: 850228141} - {fileID: 1848145250} + - {fileID: 887356093} m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &401185750 GameObject: @@ -760,7 +761,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &401185751 Transform: m_ObjectHideFlags: 0 @@ -775,7 +776,7 @@ Transform: - {fileID: 694714222} - {fileID: 1553193321} m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &411383572 GameObject: @@ -831,7 +832,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 19 + m_RootOrder: 20 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &438615021 GameObject: @@ -923,7 +924,7 @@ RectTransform: - {fileID: 770059767} - {fileID: 1774693142} m_Father: {fileID: 0} - m_RootOrder: 18 + m_RootOrder: 19 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1037,7 +1038,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 23 + m_RootOrder: 24 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &528715328 GameObject: @@ -1232,7 +1233,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 12 + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &671544960 GameObject: @@ -1598,7 +1599,7 @@ Transform: - {fileID: 441718964} - {fileID: 1167120023} m_Father: {fileID: 0} - m_RootOrder: 11 + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &750667758 GameObject: @@ -1609,7 +1610,6 @@ GameObject: m_Component: - component: {fileID: 750667763} - component: {fileID: 750667762} - - component: {fileID: 750667759} m_Layer: 5 m_Name: Spout Canvas m_TagString: Untagged @@ -1617,24 +1617,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &750667759 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 750667758} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0c29cacbda07285449365329adeb3b02, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 - MonitorCamera: {fileID: 520040868} - castMouseOnly: 0 --- !u!223 &750667762 Canvas: m_ObjectHideFlags: 0 @@ -1667,7 +1649,7 @@ RectTransform: m_Children: - {fileID: 1000268179} m_Father: {fileID: 0} - m_RootOrder: 21 + m_RootOrder: 22 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1700,7 +1682,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 16 + m_RootOrder: 17 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &770059766 GameObject: @@ -2150,6 +2132,53 @@ MonoBehaviour: m_EditorClassIdentifier: fluidSimulation: {fileID: 774429923} uniforms: {fileID: 11400000, guid: 4dcbc9a971de5974da304d60289ebe0f, type: 2} +--- !u!1 &887356092 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 887356093} + - component: {fileID: 887356094} + m_Layer: 0 + m_Name: Kinect2MotionGrpc + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &887356093 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 887356092} + 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: 386695297} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &887356094 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 887356092} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d47d55be359a57741a6fecbcc7efaf2b, type: 3} + m_Name: + m_EditorClassIdentifier: + port: 50051 + shader: {fileID: 7200000, guid: bd9793649dc30c046875df07338824bb, type: 3} + collectShader: {fileID: 7200000, guid: 7a8ac615a5434b24d83dbec67effb820, type: 3} + connectedDevices: [] + debug: + debugDraw: 1 + debugShader: {fileID: 4800000, guid: 6ffbbc1e44667e348b62c7f3ea93ae4b, type: 3} --- !u!1 &917676527 GameObject: m_ObjectHideFlags: 0 @@ -2762,7 +2791,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 17 + m_RootOrder: 18 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1390635887 GameObject: @@ -2871,7 +2900,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 13 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!1 &1553193320 GameObject: @@ -3019,6 +3048,61 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1621860758} +--- !u!1 &1761700811 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1761700813} + - component: {fileID: 1761700812} + m_Layer: 0 + m_Name: GrpcNetworkDiscovery + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1761700812 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1761700811} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2bd8ad095eeba3e4faab18e84e7fae76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_BroadcastPort: 47777 + m_BroadcastKey: 2222 + m_BroadcastVersion: 1 + m_BroadcastSubVersion: 1 + m_BroadcastInterval: 1000 + m_UseNetworkManager: 0 + m_BroadcastData: HELLO + m_ShowGUI: 0 + m_OffsetX: 0 + m_OffsetY: 0 + onReceivedBroadcast: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UltraCombos.GrpcNetworkDiscovery+MessageEvent, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!4 &1761700813 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1761700811} + 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: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1765914293 GameObject: m_ObjectHideFlags: 0 @@ -3108,7 +3192,7 @@ RectTransform: - {fileID: 1227078085} - {fileID: 2084135710} m_Father: {fileID: 0} - m_RootOrder: 24 + m_RootOrder: 25 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -3227,7 +3311,7 @@ MonoBehaviour: textureFormat: 28 yFlip: 1 output: {fileID: 0} - m_Shader: {fileID: 0} + m_Shader: {fileID: 4800000, guid: ca95743014f24fd49897e12abbe931fc, type: 3} --- !u!20 &1817143148 Camera: m_ObjectHideFlags: 0 @@ -3275,7 +3359,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 20 + m_RootOrder: 21 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1817143150 MonoBehaviour: @@ -3496,6 +3580,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 639d7a6f2452c7d4cab5ffcb304b1d8c, type: 3} m_Name: m_EditorClassIdentifier: + server: {fileID: 887356094} kinectBuffers: - {fileID: 810572923} - {fileID: 563719738} @@ -3505,10 +3590,6 @@ MonoBehaviour: clipMin: {x: -0.85, y: 0.3, z: 0} clipMax: {x: 0.71, y: 0.45, z: 1.63} fluidSimulation: {fileID: 774429923} - kinectAmount: 4 - renderTextures: - - {fileID: 8400000, guid: f9c2cef894c9cc54f807a92207bf6eda, type: 2} - - {fileID: 8400000, guid: 1276428e64b9c6444aaa6e9b476ebb1c, type: 2} debug: 0 colorize: 1 debugMaterial: {fileID: 2100000, guid: 95b4d9b25b7a7e3449627228b10d9009, type: 2} @@ -3732,7 +3813,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 14 + m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1974547830 GameObject: @@ -3840,7 +3921,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 22 + m_RootOrder: 23 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2084135709 GameObject: @@ -3955,7 +4036,7 @@ MonoBehaviour: - {fileID: 1906326619} nightCharacters: - {fileID: 147055507} - debug: 1 + debug: 0 --- !u!4 &2084936104 Transform: m_ObjectHideFlags: 0 diff --git a/Unity_2018_Frozen/Assets/Frozen/Material/Point.mat b/Unity_2018_Frozen/Assets/Frozen/Material/Point.mat index 2716760..f618567 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Material/Point.mat +++ b/Unity_2018_Frozen/Assets/Frozen/Material/Point.mat @@ -81,7 +81,7 @@ Material: - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 - - _Size: 0 + - _Size: 0.0051771435 - _SmoothnessTextureChannel: 0 - _SoftParticlesEnabled: 0 - _SoftParticlesFarFadeDistance: 1 diff --git a/Unity_2018_Frozen/Assets/Frozen/Material/Space.mat b/Unity_2018_Frozen/Assets/Frozen/Material/Space.mat index 2fcd2ca..5090d4d 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Material/Space.mat +++ b/Unity_2018_Frozen/Assets/Frozen/Material/Space.mat @@ -70,7 +70,7 @@ Material: - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 - - _Rate: 0 + - _Rate: 0.3156795 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 diff --git a/Unity_2018_Frozen/Assets/Frozen/Script/CharacterBehaviour.cs b/Unity_2018_Frozen/Assets/Frozen/Script/CharacterBehaviour.cs index 91f3fa3..bc83be0 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Script/CharacterBehaviour.cs +++ b/Unity_2018_Frozen/Assets/Frozen/Script/CharacterBehaviour.cs @@ -96,13 +96,13 @@ public class CharacterBehaviour : MonoBehaviour private void Start() { - standby = true; - isSleep = false; + //standby = true; + //isSleep = false; mat.mainTextureScale = new Vector2(1, -1); mat.mainTextureOffset = new Vector2(0, -1); - StartCoroutine(PlayOnStart()); - InitialTouchButton(); - StartCoroutine(RandomPosNoTriggerOther()); + //StartCoroutine(PlayOnStart()); + //InitialTouchButton(); + //StartCoroutine(RandomPosNoTriggerOther()); } private void OnEnable() @@ -110,7 +110,9 @@ public class CharacterBehaviour : MonoBehaviour standby = true; isSleep = false; StartCoroutine(PlayOnStart()); + InitialTouchButton(); StartCoroutine(RandomPosNoTriggerOther()); + color = Color.white; } IEnumerator PlayOnStart() diff --git a/Unity_2018_Frozen/Assets/Frozen/Script/FrozenScreenToWorldSpace.cs.meta b/Unity_2018_Frozen/Assets/Frozen/Script/FrozenScreenToWorldSpace.cs.meta index aac73b8..367c1e5 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Script/FrozenScreenToWorldSpace.cs.meta +++ b/Unity_2018_Frozen/Assets/Frozen/Script/FrozenScreenToWorldSpace.cs.meta @@ -6,7 +6,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -10 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Unity_2018_Frozen/Assets/Frozen/Script/SceneController.cs b/Unity_2018_Frozen/Assets/Frozen/Script/SceneController.cs index 5dc6f05..f07df92 100644 --- a/Unity_2018_Frozen/Assets/Frozen/Script/SceneController.cs +++ b/Unity_2018_Frozen/Assets/Frozen/Script/SceneController.cs @@ -34,7 +34,7 @@ namespace UltraCombos.Frozen private void Start() { - debug = false; + //debug = false; } private void Update() diff --git a/Unity_2018_Frozen/Assets/Grpc.meta b/Unity_2018_Frozen/Assets/Grpc.meta new file mode 100644 index 0000000..05868e6 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6f6b5b47aa125be4aa9abe68fcf892ac +folderAsset: yes +timeCreated: 1525257095 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins.meta new file mode 100644 index 0000000..82b06e6 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d0bdbcbef356b804d884dd930d38ae8b +folderAsset: yes +timeCreated: 1518015320 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll b/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll new file mode 100644 index 0000000..e1f3cff Binary files /dev/null and b/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll differ diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll.meta new file mode 100644 index 0000000..ef41a9d --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/Google.Protobuf.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 9504153c153a2624e9da519e92cf5542 +timeCreated: 1518015297 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll b/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll new file mode 100644 index 0000000..48d134c Binary files /dev/null and b/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll differ diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll.meta new file mode 100644 index 0000000..1b78f7a --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/Grpc.Core.dll.meta @@ -0,0 +1,30 @@ +fileFormatVersion: 2 +guid: dbf1aea72c6b57649b8bfb462b093c00 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll b/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll new file mode 100644 index 0000000..48efea4 Binary files /dev/null and b/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll differ diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll.meta new file mode 100644 index 0000000..6b19559 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/System.Interactive.Async.dll.meta @@ -0,0 +1,30 @@ +fileFormatVersion: 2 +guid: 495e81e1d71d1314bb494527410dccb0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes.meta new file mode 100644 index 0000000..a32a420 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1152917cc2daa11438d537680ad5f9d4 +folderAsset: yes +timeCreated: 1518001842 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win.meta new file mode 100644 index 0000000..1af9bcb --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dfc7c55cf51ee0b489c4b8f996fa221a +folderAsset: yes +timeCreated: 1517972283 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native.meta new file mode 100644 index 0000000..d3435ff --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9d801733b0f4ed842a4226da283a9575 +folderAsset: yes +timeCreated: 1518001790 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll new file mode 100644 index 0000000..8d0845e Binary files /dev/null and b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll differ diff --git a/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll.meta b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll.meta new file mode 100644 index 0000000..94d556c --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Plugins/runtimes/win/native/grpc_csharp_ext.dll.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: c45a46b26d79cea4bbe365f12000d367 +timeCreated: 1518001685 +licenseType: Free +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXUniversal: 0 + Exclude Win: 1 + Exclude Win64: 0 + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: Windows + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 1 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 1 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Script.meta b/Unity_2018_Frozen/Assets/Grpc/Script.meta new file mode 100644 index 0000000..21a96c2 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e61dbedb9243085418be7e788fc4b7d7 +folderAsset: yes +timeCreated: 1518408269 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Script/Editor.meta b/Unity_2018_Frozen/Assets/Grpc/Script/Editor.meta new file mode 100644 index 0000000..632318f --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 069493b6cf88a674b8ea05d8ce5ede27 +folderAsset: yes +timeCreated: 1518162534 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs b/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs new file mode 100644 index 0000000..e4fa2f3 --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs @@ -0,0 +1,61 @@ +using UnityEngine; +using UnityEditor; +using UnityEditor.Callbacks; +using System.IO; +using System.Collections; +#if UNITY_EDITOR_OSX +using UnityEditor.iOS.Xcode; + +public class GrpcBuildPostProcess +{ + + [PostProcessBuild] + public static void OnPostprocessBuild(BuildTarget buildTarget, string path) + { + if (buildTarget == BuildTarget.iOS) + { + /* .xcodeproj/project.pbxproj */ + + //Get path to the PBX project + string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; + + //Read the pbx project + PBXProject proj = new PBXProject(); + proj.ReadFromString(File.ReadAllText(projPath)); + + //Get the build target + string target = proj.TargetGuidByName("Unity-iPhone"); + + //set ENABLE_BITCODE to false (this shouldn't be required in Unity 5.2+) + proj.SetBuildProperty(target, "ENABLE_BITCODE", "No"); + + //Add libz.dylib + string name = proj.AddFile("/usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Source); + proj.AddFileToBuild(target, name); + //proj.AddFrameworkToProject(target, "/usr/lib/libz.dylib", false); + + //Write back out the PBX project + File.WriteAllText(projPath, proj.WriteToString()); + + /* Info.plist */ + + // Read the Info.plist file + string plistPath = path + "/Info.plist"; + PlistDocument plist = new PlistDocument(); + plist.ReadFromString(File.ReadAllText(plistPath)); + + // Get root of plist + PlistElementDict rootDict = plist.root; + //Set Requires full screen = true. This was needed only with Xcode 9. + rootDict.SetBoolean("UIRequiresFullScreen", true); + //Adding background modes for remote notification (For Push notifications - OneSignal) + var bgModes = rootDict.CreateArray("UIBackgroundModes"); + bgModes.AddString("remote-notification"); + + //Write out the Info.plist file + plist.WriteToFile(plistPath); + } + + } +} +#endif \ No newline at end of file diff --git a/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs.meta b/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs.meta new file mode 100644 index 0000000..bd0c53b --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script/Editor/GrpcBuildPostProcess.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2c2dc5ab2aeed034fa54b99ce7684e86 +timeCreated: 1518162353 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs b/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs new file mode 100644 index 0000000..0bce5ba --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs @@ -0,0 +1,40 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.Networking; + +namespace UltraCombos +{ + public class GrpcNetworkDiscovery : NetworkDiscovery + { + public class Config + { + public string serviceName; + public string host; + public int port; + } + + [System.Serializable] + public class MessageEvent : UnityEvent + { + } + + public MessageEvent onReceivedBroadcast = new MessageEvent(); + + private void Start() + { + Initialize(); + StartAsServer(); + } + + public override void OnReceivedBroadcast(string fromAddress, string data) + { + var config = JsonUtility.FromJson(data); + //config.host = System.Net.IPAddress.Parse(fromAddress).MapToIPv4().ToString(); + + onReceivedBroadcast.Invoke(config); + } + + } +} diff --git a/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs.meta b/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs.meta new file mode 100644 index 0000000..ceeeddf --- /dev/null +++ b/Unity_2018_Frozen/Assets/Grpc/Script/GrpcNetworkDiscovery.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2bd8ad095eeba3e4faab18e84e7fae76 +timeCreated: 1518487708 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc.meta new file mode 100644 index 0000000..d2bbea2 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 56032ca3ec67ba3449b295b605a3b7be +folderAsset: yes +timeCreated: 1524647267 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader new file mode 100644 index 0000000..7198434 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader @@ -0,0 +1,64 @@ +Shader "Hidden/Kinect2MotionDebug" +{ + Properties + { + _Color("Color", Color) = (1,1,1,1) + } + + SubShader + { + Tags{ "RenderType" = "Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma geometry geom + #pragma fragment frag + + #include "UnityCG.cginc" + + struct v2g + { + float4 vertex : SV_POSITION; + }; + + struct g2f + { + float4 vertex : SV_POSITION; + }; + + fixed4 _Color; + + #ifdef SHADER_API_D3D11 + StructuredBuffer ssbo; + #endif + + v2g vert(appdata_base v, uint vid : SV_VertexID) + { + v2g o = (v2g)0; + #ifdef SHADER_API_D3D11 + o.vertex = float4(ssbo[vid].xyz, 1); + #endif + return o; + } + + [maxvertexcount(1)] + void geom(point v2g input[1], inout PointStream OutputStream) + { + g2f o = (g2f)0; + o.vertex = UnityObjectToClipPos(input[0].vertex.xyz); + + OutputStream.Append(o); + } + + fixed4 frag(g2f i) : SV_Target + { + fixed4 col = fixed4(1, 1, 1, 1); + return col; + } + ENDCG + } + } +} diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader.meta new file mode 100644 index 0000000..f8d92d9 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/Kinect2MotionDebug.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6ffbbc1e44667e348b62c7f3ea93ae4b +timeCreated: 1525233718 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute new file mode 100644 index 0000000..ff95537 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute @@ -0,0 +1,19 @@ +#pragma kernel CSMain + +#include "UnityCG.cginc" + +StructuredBuffer position_buffer; +StructuredBuffer velocity_buffer; +RWStructuredBuffer FinalPositionBuffer; +RWStructuredBuffer FinalVelocityBuffer; + +int count; + +[numthreads(512, 1, 1)] +void CSMain(uint3 id : SV_DispatchThreadID) +{ + int final_index = 512 * 424 * count + id.x; + + FinalPositionBuffer[final_index] = position_buffer[id.x]; + FinalVelocityBuffer[final_index] = velocity_buffer[id.x]; +} diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute.meta new file mode 100644 index 0000000..679bd38 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferCollect.compute.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7a8ac615a5434b24d83dbec67effb820 +timeCreated: 1524801314 +licenseType: Free +ComputeShaderImporter: + externalObjects: {} + currentAPIMask: 4 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute new file mode 100644 index 0000000..3b7cc4a --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute @@ -0,0 +1,83 @@ +#define WIDTH 512 +#define HEIGHT 424 + +#pragma kernel CSMain + +#include "UnityCG.cginc" + +RWStructuredBuffer kinect_motion_buffer; +RWStructuredBuffer position_buffer; +RWStructuredBuffer velocity_buffer; + +Texture2D depth_high_texture; +Texture2D depth_low_texture; +Texture2D velocity_texture; + +float4x4 kinect_matrix; +float3 clip_box; + + +[numthreads(32, 32, 1)] +void CSMain(uint3 id : SV_DispatchThreadID) +{ + int index = id.y * WIDTH + id.x; + int high = (int)(depth_high_texture[id.xy].x * 255.0); + int low = (int)(depth_low_texture[id.xy].x * 255.0); + float depth = (float)((high << 8) + low) * 0.001; + + float2 vel = velocity_texture[id.xy].xy * 255.0 - 128.0; + + float pre_depth = kinect_motion_buffer[index].z; + kinect_motion_buffer[index] = float4(vel, depth, pre_depth); + + /////////////////////////////////// + + float2 img_size = float2(512.0, 424.0); + float fovy = 60.0; + float PI = UNITY_PI; + + float focal = img_size.y / 2.0 / tan(fovy / 2.0 * PI / 180.0); + float2 vel2d = vel; + + float2 f_pos = float2(id.xy) + 0.5; + float2 t_pos = f_pos + vel2d; + + float f_depth = pre_depth; + float t_depth = depth; + + float3 flip = float3(1.0, -1.0, -1.0); + float3 f_vec = float3((f_pos - 0.5 * img_size) / focal, -1.0) * flip; + float3 t_vec = float3((t_pos - 0.5 * img_size) / focal, -1.0) * flip; + + float3 f_p3d = float3(f_vec * f_depth); + float3 t_p3d = float3(t_vec * t_depth); + + float3 vel3d = t_p3d - f_p3d; + + float depth_diff_threshold = 0.14; + float cam_dot_threshold = 0.955; + if (f_depth == 0.0 || t_depth == 0.0 || abs(f_depth - t_depth) > depth_diff_threshold) + { + f_p3d = float3(0, 0, 0); + vel3d = float3(0, 0, 0); + } + else if (abs(dot(normalize(vel3d), normalize(f_vec))) > cam_dot_threshold) + { + f_p3d = float3(0, 0, 0); + vel3d = float3(0, 0, 0); + } + + float3 kpos = mul(kinect_matrix, float4(t_p3d, 1.0)).xyz; + float3 kvel = mul(kinect_matrix, float4(vel3d, 0.0)).xyz; + + if (kpos.x < -clip_box.x * 0.5 || kpos.x > clip_box.x * 0.5 || + kpos.z < -clip_box.z * 0.5 || kpos.z > clip_box.z * 0.5 || + kpos.y < 0.0 || kpos.y > clip_box.y) + { + kpos = float3(0, 0, 0); + kvel = float3(0, 0, 0); + } + + position_buffer[index] = float4(kpos, 1.0); + velocity_buffer[index] = float4(kvel, 0.0); +} diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute.meta new file mode 100644 index 0000000..ef25dea --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectBufferComposite.compute.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bd9793649dc30c046875df07338824bb +timeCreated: 1524801314 +licenseType: Free +ComputeShaderImporter: + externalObjects: {} + currentAPIMask: 4 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs new file mode 100644 index 0000000..997247b --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs @@ -0,0 +1,362 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Grpc.Core; +using System.Threading.Tasks; + +namespace UltraCombos.Kinect2MotionTransmit +{ + public class KinectGrpcServer : MonoBehaviour + { + public int port = 50051; + Server server; + + [SerializeField] + ComputeShader shader; + public ComputeBuffer buffer; + + [SerializeField] + ComputeShader collectShader; + + class KinectBuffer + { + ~KinectBuffer() + { + Release(); + } + + public void Release() + { + if (position != null) + { + position.Release(); + position = null; + } + if (velocity != null) + { + velocity.Release(); + velocity = null; + } + } + + public ComputeBuffer position; + public ComputeBuffer velocity; + + public object mutex = new object(); + public DataRequest[] data_pool = new DataRequest[3]; + public bool has_new_data = false; + public int READY = 0; + public int FRONT = 1; + public int BACK = 2; + + public float fps = 30.0f; + public float stamp = 0.0f; + + public Matrix4x4 matrix; + public Vector3 ClipBox; + } + + List> kinect_buffers = new List>(); + + int final_count = 1; + ComputeBuffer final_position_buffer; + public ComputeBuffer FinalPositionBuffer { get { return final_position_buffer; } } + ComputeBuffer final_velocity_buffer; + public ComputeBuffer FinalVelocityBuffer { get { return final_velocity_buffer; } } + + + Texture2D depth_high_texture; + byte[] depth_high_data; + Texture2D depth_low_texture; + byte[] depth_low_data; + Texture2D velocity_texture; + byte[] velocity_data; + + const int width = 512; + const int height = 424; + + + [SerializeField] + List connectedDevices = new List(); + [SerializeField] + string debug; + [SerializeField] + bool debugDraw = false; + [SerializeField] + Shader debugShader = null; + + private void Start() + { + buffer = new ComputeBuffer(width * height, sizeof(float) * 4); + Debug.LogFormat("Buffer is created by count {0} and stride {1}", buffer.count, buffer.stride); + depth_high_data = new byte[buffer.count / 2]; + depth_low_data = new byte[buffer.count / 2]; + velocity_data = new byte[buffer.count]; + + depth_high_texture = new Texture2D(width, height, TextureFormat.BC4, false); + depth_low_texture = new Texture2D(width, height, TextureFormat.BC4, false); + velocity_texture = new Texture2D(width, height, TextureFormat.BC5, false); + + final_position_buffer = new ComputeBuffer(width * height, sizeof(float) * 4); + final_velocity_buffer = new ComputeBuffer(width * height, sizeof(float) * 4); + + StartServer(); + } + + private void Update() + { + uint x, y, z; + shader.GetKernelThreadGroupSizes(0, out x, out y, out z); + int[] args = new int[3] + { + (int)Mathf.CeilToInt((float)width / x), + (int)Mathf.CeilToInt((float)height / y), + (int)Mathf.CeilToInt((float)1 / z) + }; + + connectedDevices.Clear(); + debug = ""; + foreach (var buf in kinect_buffers) + { + connectedDevices.Add(buf.Key); + debug += string.Format("{0} ", buf.Value.fps); + + var kinect = buf.Value; + + if (kinect.position == null) + kinect.position = new ComputeBuffer(width * height, sizeof(float) * 4); + if (kinect.velocity == null) + kinect.velocity = new ComputeBuffer(width * height, sizeof(float) * 4); + + if (kinect.has_new_data) + { + lock (kinect.mutex) + { + Swap(ref kinect.FRONT, ref kinect.READY); + kinect.has_new_data = false; + } + + DataRequest data = kinect.data_pool[kinect.READY]; + + Vector3 pos = new Vector3(data.PositionX, data.PositionY, -data.PositionZ); +#if false + Quaternion q = Quaternion.Euler(-data.RotationX, -data.RotationY, data.RotationZ); +#else + Quaternion q = Quaternion.Euler(0, 0, data.RotationZ); + q *= Quaternion.Euler(0, -data.RotationY, 0); + q *= Quaternion.Euler(-data.RotationX, 0, 0); +#endif + kinect.matrix = Matrix4x4.TRS(pos, q, Vector3.one); + kinect.ClipBox = new Vector3(data.ClipSizeX, data.ClipSizeY, data.ClipSizeZ); + + data.DepthHighData.CopyTo(depth_high_data, 0); + data.DepthLowData.CopyTo(depth_low_data, 0); + data.VelocityData.CopyTo(velocity_data, 0); + + depth_high_texture.LoadRawTextureData(depth_high_data); + depth_high_texture.Apply(); + depth_low_texture.LoadRawTextureData(depth_low_data); + depth_low_texture.Apply(); + velocity_texture.LoadRawTextureData(velocity_data); + velocity_texture.Apply(); + + shader.SetTexture(0, "depth_high_texture", depth_high_texture); + shader.SetTexture(0, "depth_low_texture", depth_low_texture); + shader.SetTexture(0, "velocity_texture", velocity_texture); + shader.SetBuffer(0, "kinect_motion_buffer", buffer); + shader.SetBuffer(0, "position_buffer", kinect.position); + shader.SetBuffer(0, "velocity_buffer", kinect.velocity); + shader.SetMatrix("kinect_matrix", kinect.matrix); + shader.SetVector("clip_box", kinect.ClipBox); + shader.Dispatch(0, args[0], args[1], args[2]); + + kinect.fps = Mathf.Lerp(kinect.fps, 1.0f / (Time.time - kinect.stamp), 0.02f); + kinect.stamp = Time.time; + } + } + + } + + private void FixedUpdate() + { + uint x, y, z; + collectShader.GetKernelThreadGroupSizes(0, out x, out y, out z); + int[] args = new int[3] + { + (int)Mathf.CeilToInt((float)(width * height) / x), + (int)Mathf.CeilToInt((float)1 / y), + (int)Mathf.CeilToInt((float)1 / z) + }; + + if (final_count < kinect_buffers.Count) + { + final_count = kinect_buffers.Count; + int buf_count = final_count * width * height; + final_position_buffer.Release(); + final_position_buffer = new ComputeBuffer(buf_count, sizeof(float) * 4); + final_velocity_buffer.Release(); + final_velocity_buffer = new ComputeBuffer(buf_count, sizeof(float) * 4); + } + + int count = 0; + foreach (var buf in kinect_buffers) + { + if (buf.Value.position == null || buf.Value.velocity == null) + continue; + collectShader.SetInt("count", count++); + collectShader.SetBuffer(0, "position_buffer", buf.Value.position); + collectShader.SetBuffer(0, "velocity_buffer", buf.Value.velocity); + collectShader.SetBuffer(0, "FinalPositionBuffer", final_position_buffer); + collectShader.SetBuffer(0, "FinalVelocityBuffer", final_velocity_buffer); + collectShader.Dispatch(0, args[0], args[1], args[2]); + } + + } + + private void OnDestroy() + { + server.ShutdownAsync().Wait(); + + if (buffer != null) + { + buffer.Release(); + buffer = null; + } + + if (final_position_buffer != null) + { + final_position_buffer.Release(); + final_position_buffer = null; + } + + if (final_velocity_buffer != null) + { + final_velocity_buffer.Release(); + final_velocity_buffer = null; + } + + foreach (var buf in kinect_buffers) + { + buf.Value.Release(); + } + } + + private void StartServer() + { + try + { + var options = new List { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue) }; + server = new Server(options) + { + Services = { Resource.BindService(new ResourceImpl(OnMessageReceived)) }, + Ports = { new ServerPort("0.0.0.0", port, ServerCredentials.Insecure) } + }; + + server.Start(); + Debug.Log("Start Server"); + } + catch (System.Exception e) + { + Debug.LogError(e.Message); + } + } + + private void OnMessageReceived(DataRequest data) + { + //Debug.Log(data.Name); + //Debug.LogFormat("message.Length: {0}", data.Content.Length); + + KinectBuffer kinect = null; + foreach (var buf in kinect_buffers) + { + if (data.Name.Equals(buf.Key)) + { + kinect = buf.Value; + } + } + + if (kinect == null) + { + kinect = new KinectBuffer(); + for (int i = 0; i < 3; i++) + kinect.data_pool[i] = new DataRequest(); + kinect_buffers.Add(new KeyValuePair(data.Name, kinect)); + } + + kinect.data_pool[kinect.BACK].MergeFrom(data); + lock (kinect.mutex) + { + Swap(ref kinect.BACK, ref kinect.FRONT); + kinect.has_new_data = true; + } + } + + private static void Swap(ref T a, ref T b) + { + T tmp = a; + a = b; + b = tmp; + } + + private void OnDrawGizmosSelected() + { + var col = Gizmos.color; + + int count = 0; + foreach (var buf in kinect_buffers) + { + var kinect = buf.Value; + Gizmos.color = Color.HSVToRGB(count++ / 5.0f, 0.8f, 0.8f); + var mat = Gizmos.matrix; + Gizmos.matrix = transform.localToWorldMatrix; + Gizmos.matrix = Matrix4x4.identity; + Gizmos.DrawWireCube(new Vector3(0, kinect.ClipBox.y * 0.5f, 0), kinect.ClipBox); + Gizmos.matrix *= kinect.matrix; + Gizmos.DrawFrustum(Vector3.zero, 60.0f, 20.0f, 0.6f, 512.0f / 424.0f); + Gizmos.matrix = mat; + } + + Gizmos.color = col; + } + + Material material = null; + + private void OnRenderObject() + { + if (debugShader == null) + return; + + if (debugDraw == false) + return; + + if (material == null) + material = new Material(debugShader); + + material.SetPass(0); + material.SetBuffer("ssbo", final_position_buffer); + + Graphics.DrawProcedural(MeshTopology.Points, final_position_buffer.count, 1); + + } + } + + internal class ResourceImpl : Resource.ResourceBase + { + public ResourceImpl(MessageDelegate func = null) + { + if (func != null) + onMessageReceived += func; + } + + public override Task SendData(DataRequest request, ServerCallContext context) + { + onMessageReceived.Invoke(request); + string res = string.Format("OK: DH({0}), DL({1}), V({2})", request.DepthHighData.Length, request.DepthLowData.Length, request.VelocityData.Length); + //Debug.Log(res); + return Task.FromResult(new DataReply { Result = res }); + } + + public delegate void MessageDelegate(DataRequest data); + public MessageDelegate onMessageReceived; + } +} diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs.meta new file mode 100644 index 0000000..16a33b1 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/KinectGrpcServer.cs.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: d47d55be359a57741a6fecbcc7efaf2b +timeCreated: 1524646292 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - shader: {fileID: 7200000, guid: bd9793649dc30c046875df07338824bb, type: 3} + - collectShader: {fileID: 7200000, guid: 7a8ac615a5434b24d83dbec67effb820, type: 3} + - FinalPositionBuffer: {instanceID: 0} + - FinalVelocityBuffer: {instanceID: 0} + - debugShader: {fileID: 4800000, guid: 6ffbbc1e44667e348b62c7f3ea93ae4b, type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs new file mode 100644 index 0000000..086e902 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs @@ -0,0 +1,97 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: UltraCombos.Kinect2MotionTransmit.proto +// +#pragma warning disable 1591 +#region Designer generated code + +using grpc = global::Grpc.Core; + +namespace UltraCombos.Kinect2MotionTransmit { + public static partial class Resource + { + static readonly string __ServiceName = "UltraCombos.Kinect2MotionTransmit.Resource"; + + static readonly grpc::Marshaller __Marshaller_DataRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::UltraCombos.Kinect2MotionTransmit.DataRequest.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_DataReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::UltraCombos.Kinect2MotionTransmit.DataReply.Parser.ParseFrom); + + static readonly grpc::Method __Method_SendData = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "SendData", + __Marshaller_DataRequest, + __Marshaller_DataReply); + + /// Service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::UltraCombos.Kinect2MotionTransmit.UltraCombosKinect2MotionTransmitReflection.Descriptor.Services[0]; } + } + + /// Base class for server-side implementations of Resource + public abstract partial class ResourceBase + { + public virtual global::System.Threading.Tasks.Task SendData(global::UltraCombos.Kinect2MotionTransmit.DataRequest request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + } + + /// Client for Resource + public partial class ResourceClient : grpc::ClientBase + { + /// Creates a new client for Resource + /// The channel to use to make remote calls. + public ResourceClient(grpc::Channel channel) : base(channel) + { + } + /// Creates a new client for Resource that uses a custom CallInvoker. + /// The callInvoker to use to make remote calls. + public ResourceClient(grpc::CallInvoker callInvoker) : base(callInvoker) + { + } + /// Protected parameterless constructor to allow creation of test doubles. + protected ResourceClient() : base() + { + } + /// Protected constructor to allow creation of configured clients. + /// The client configuration. + protected ResourceClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + public virtual global::UltraCombos.Kinect2MotionTransmit.DataReply SendData(global::UltraCombos.Kinect2MotionTransmit.DataRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return SendData(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + public virtual global::UltraCombos.Kinect2MotionTransmit.DataReply SendData(global::UltraCombos.Kinect2MotionTransmit.DataRequest request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_SendData, null, options, request); + } + public virtual grpc::AsyncUnaryCall SendDataAsync(global::UltraCombos.Kinect2MotionTransmit.DataRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + { + return SendDataAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + public virtual grpc::AsyncUnaryCall SendDataAsync(global::UltraCombos.Kinect2MotionTransmit.DataRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_SendData, null, options, request); + } + /// Creates a new instance of client from given ClientBaseConfiguration. + protected override ResourceClient NewInstance(ClientBaseConfiguration configuration) + { + return new ResourceClient(configuration); + } + } + + /// Creates service definition that can be registered with a server + /// An object implementing the server-side handling logic. + public static grpc::ServerServiceDefinition BindService(ResourceBase serviceImpl) + { + return grpc::ServerServiceDefinition.CreateBuilder() + .AddMethod(__Method_SendData, serviceImpl.SendData).Build(); + } + + } +} +#endregion diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs.meta new file mode 100644 index 0000000..abbbb7b --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombos.Kinect2MotionTransmitGrpc.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6aaa626a29978c944b18c4334a0b06dc +timeCreated: 1524800781 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs new file mode 100644 index 0000000..8e67fb0 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs @@ -0,0 +1,650 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: UltraCombos.Kinect2MotionTransmit.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace UltraCombos.Kinect2MotionTransmit { + + /// Holder for reflection information generated from UltraCombos.Kinect2MotionTransmit.proto + public static partial class UltraCombosKinect2MotionTransmitReflection { + + #region Descriptor + /// File descriptor for UltraCombos.Kinect2MotionTransmit.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static UltraCombosKinect2MotionTransmitReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CidVbHRyYUNvbWJvcy5LaW5lY3QyTW90aW9uVHJhbnNtaXQucHJvdG8SIVVs", + "dHJhQ29tYm9zLktpbmVjdDJNb3Rpb25UcmFuc21pdCKeAgoLRGF0YVJlcXVl", + "c3QSDAoEbmFtZRgBIAEoCRIVCg1kZXB0aEhpZ2hEYXRhGAIgASgMEhQKDGRl", + "cHRoTG93RGF0YRgDIAEoDBIUCgx2ZWxvY2l0eURhdGEYBCABKAwSEQoJcG9z", + "aXRpb25YGAUgASgCEhEKCXBvc2l0aW9uWRgGIAEoAhIRCglwb3NpdGlvbloY", + "ByABKAISEQoJcm90YXRpb25YGAggASgCEhEKCXJvdGF0aW9uWRgJIAEoAhIR", + "Cglyb3RhdGlvbloYCiABKAISEQoJY2xpcFNpemVYGAsgASgCEhEKCWNsaXBT", + "aXplWRgMIAEoAhIRCgljbGlwU2l6ZVoYDSABKAISEwoLaW5mb3JtYXRpb24Y", + "DiABKAkiGwoJRGF0YVJlcGx5Eg4KBnJlc3VsdBgBIAEoCTJ2CghSZXNvdXJj", + "ZRJqCghTZW5kRGF0YRIuLlVsdHJhQ29tYm9zLktpbmVjdDJNb3Rpb25UcmFu", + "c21pdC5EYXRhUmVxdWVzdBosLlVsdHJhQ29tYm9zLktpbmVjdDJNb3Rpb25U", + "cmFuc21pdC5EYXRhUmVwbHkiAGIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::UltraCombos.Kinect2MotionTransmit.DataRequest), global::UltraCombos.Kinect2MotionTransmit.DataRequest.Parser, new[]{ "Name", "DepthHighData", "DepthLowData", "VelocityData", "PositionX", "PositionY", "PositionZ", "RotationX", "RotationY", "RotationZ", "ClipSizeX", "ClipSizeY", "ClipSizeZ", "Information" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::UltraCombos.Kinect2MotionTransmit.DataReply), global::UltraCombos.Kinect2MotionTransmit.DataReply.Parser, new[]{ "Result" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class DataRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DataRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UltraCombos.Kinect2MotionTransmit.UltraCombosKinect2MotionTransmitReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataRequest(DataRequest other) : this() { + name_ = other.name_; + depthHighData_ = other.depthHighData_; + depthLowData_ = other.depthLowData_; + velocityData_ = other.velocityData_; + positionX_ = other.positionX_; + positionY_ = other.positionY_; + positionZ_ = other.positionZ_; + rotationX_ = other.rotationX_; + rotationY_ = other.rotationY_; + rotationZ_ = other.rotationZ_; + clipSizeX_ = other.clipSizeX_; + clipSizeY_ = other.clipSizeY_; + clipSizeZ_ = other.clipSizeZ_; + information_ = other.information_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataRequest Clone() { + return new DataRequest(this); + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "depthHighData" field. + public const int DepthHighDataFieldNumber = 2; + private pb::ByteString depthHighData_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString DepthHighData { + get { return depthHighData_; } + set { + depthHighData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "depthLowData" field. + public const int DepthLowDataFieldNumber = 3; + private pb::ByteString depthLowData_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString DepthLowData { + get { return depthLowData_; } + set { + depthLowData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "velocityData" field. + public const int VelocityDataFieldNumber = 4; + private pb::ByteString velocityData_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString VelocityData { + get { return velocityData_; } + set { + velocityData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "positionX" field. + public const int PositionXFieldNumber = 5; + private float positionX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PositionX { + get { return positionX_; } + set { + positionX_ = value; + } + } + + /// Field number for the "positionY" field. + public const int PositionYFieldNumber = 6; + private float positionY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PositionY { + get { return positionY_; } + set { + positionY_ = value; + } + } + + /// Field number for the "positionZ" field. + public const int PositionZFieldNumber = 7; + private float positionZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float PositionZ { + get { return positionZ_; } + set { + positionZ_ = value; + } + } + + /// Field number for the "rotationX" field. + public const int RotationXFieldNumber = 8; + private float rotationX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotationX { + get { return rotationX_; } + set { + rotationX_ = value; + } + } + + /// Field number for the "rotationY" field. + public const int RotationYFieldNumber = 9; + private float rotationY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotationY { + get { return rotationY_; } + set { + rotationY_ = value; + } + } + + /// Field number for the "rotationZ" field. + public const int RotationZFieldNumber = 10; + private float rotationZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float RotationZ { + get { return rotationZ_; } + set { + rotationZ_ = value; + } + } + + /// Field number for the "clipSizeX" field. + public const int ClipSizeXFieldNumber = 11; + private float clipSizeX_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float ClipSizeX { + get { return clipSizeX_; } + set { + clipSizeX_ = value; + } + } + + /// Field number for the "clipSizeY" field. + public const int ClipSizeYFieldNumber = 12; + private float clipSizeY_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float ClipSizeY { + get { return clipSizeY_; } + set { + clipSizeY_ = value; + } + } + + /// Field number for the "clipSizeZ" field. + public const int ClipSizeZFieldNumber = 13; + private float clipSizeZ_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public float ClipSizeZ { + get { return clipSizeZ_; } + set { + clipSizeZ_ = value; + } + } + + /// Field number for the "information" field. + public const int InformationFieldNumber = 14; + private string information_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Information { + get { return information_; } + set { + information_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DataRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DataRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (DepthHighData != other.DepthHighData) return false; + if (DepthLowData != other.DepthLowData) return false; + if (VelocityData != other.VelocityData) return false; + if (PositionX != other.PositionX) return false; + if (PositionY != other.PositionY) return false; + if (PositionZ != other.PositionZ) return false; + if (RotationX != other.RotationX) return false; + if (RotationY != other.RotationY) return false; + if (RotationZ != other.RotationZ) return false; + if (ClipSizeX != other.ClipSizeX) return false; + if (ClipSizeY != other.ClipSizeY) return false; + if (ClipSizeZ != other.ClipSizeZ) return false; + if (Information != other.Information) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (DepthHighData.Length != 0) hash ^= DepthHighData.GetHashCode(); + if (DepthLowData.Length != 0) hash ^= DepthLowData.GetHashCode(); + if (VelocityData.Length != 0) hash ^= VelocityData.GetHashCode(); + if (PositionX != 0F) hash ^= PositionX.GetHashCode(); + if (PositionY != 0F) hash ^= PositionY.GetHashCode(); + if (PositionZ != 0F) hash ^= PositionZ.GetHashCode(); + if (RotationX != 0F) hash ^= RotationX.GetHashCode(); + if (RotationY != 0F) hash ^= RotationY.GetHashCode(); + if (RotationZ != 0F) hash ^= RotationZ.GetHashCode(); + if (ClipSizeX != 0F) hash ^= ClipSizeX.GetHashCode(); + if (ClipSizeY != 0F) hash ^= ClipSizeY.GetHashCode(); + if (ClipSizeZ != 0F) hash ^= ClipSizeZ.GetHashCode(); + if (Information.Length != 0) hash ^= Information.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (DepthHighData.Length != 0) { + output.WriteRawTag(18); + output.WriteBytes(DepthHighData); + } + if (DepthLowData.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(DepthLowData); + } + if (VelocityData.Length != 0) { + output.WriteRawTag(34); + output.WriteBytes(VelocityData); + } + if (PositionX != 0F) { + output.WriteRawTag(45); + output.WriteFloat(PositionX); + } + if (PositionY != 0F) { + output.WriteRawTag(53); + output.WriteFloat(PositionY); + } + if (PositionZ != 0F) { + output.WriteRawTag(61); + output.WriteFloat(PositionZ); + } + if (RotationX != 0F) { + output.WriteRawTag(69); + output.WriteFloat(RotationX); + } + if (RotationY != 0F) { + output.WriteRawTag(77); + output.WriteFloat(RotationY); + } + if (RotationZ != 0F) { + output.WriteRawTag(85); + output.WriteFloat(RotationZ); + } + if (ClipSizeX != 0F) { + output.WriteRawTag(93); + output.WriteFloat(ClipSizeX); + } + if (ClipSizeY != 0F) { + output.WriteRawTag(101); + output.WriteFloat(ClipSizeY); + } + if (ClipSizeZ != 0F) { + output.WriteRawTag(109); + output.WriteFloat(ClipSizeZ); + } + if (Information.Length != 0) { + output.WriteRawTag(114); + output.WriteString(Information); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (DepthHighData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(DepthHighData); + } + if (DepthLowData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(DepthLowData); + } + if (VelocityData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(VelocityData); + } + if (PositionX != 0F) { + size += 1 + 4; + } + if (PositionY != 0F) { + size += 1 + 4; + } + if (PositionZ != 0F) { + size += 1 + 4; + } + if (RotationX != 0F) { + size += 1 + 4; + } + if (RotationY != 0F) { + size += 1 + 4; + } + if (RotationZ != 0F) { + size += 1 + 4; + } + if (ClipSizeX != 0F) { + size += 1 + 4; + } + if (ClipSizeY != 0F) { + size += 1 + 4; + } + if (ClipSizeZ != 0F) { + size += 1 + 4; + } + if (Information.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Information); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DataRequest other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.DepthHighData.Length != 0) { + DepthHighData = other.DepthHighData; + } + if (other.DepthLowData.Length != 0) { + DepthLowData = other.DepthLowData; + } + if (other.VelocityData.Length != 0) { + VelocityData = other.VelocityData; + } + if (other.PositionX != 0F) { + PositionX = other.PositionX; + } + if (other.PositionY != 0F) { + PositionY = other.PositionY; + } + if (other.PositionZ != 0F) { + PositionZ = other.PositionZ; + } + if (other.RotationX != 0F) { + RotationX = other.RotationX; + } + if (other.RotationY != 0F) { + RotationY = other.RotationY; + } + if (other.RotationZ != 0F) { + RotationZ = other.RotationZ; + } + if (other.ClipSizeX != 0F) { + ClipSizeX = other.ClipSizeX; + } + if (other.ClipSizeY != 0F) { + ClipSizeY = other.ClipSizeY; + } + if (other.ClipSizeZ != 0F) { + ClipSizeZ = other.ClipSizeZ; + } + if (other.Information.Length != 0) { + Information = other.Information; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + DepthHighData = input.ReadBytes(); + break; + } + case 26: { + DepthLowData = input.ReadBytes(); + break; + } + case 34: { + VelocityData = input.ReadBytes(); + break; + } + case 45: { + PositionX = input.ReadFloat(); + break; + } + case 53: { + PositionY = input.ReadFloat(); + break; + } + case 61: { + PositionZ = input.ReadFloat(); + break; + } + case 69: { + RotationX = input.ReadFloat(); + break; + } + case 77: { + RotationY = input.ReadFloat(); + break; + } + case 85: { + RotationZ = input.ReadFloat(); + break; + } + case 93: { + ClipSizeX = input.ReadFloat(); + break; + } + case 101: { + ClipSizeY = input.ReadFloat(); + break; + } + case 109: { + ClipSizeZ = input.ReadFloat(); + break; + } + case 114: { + Information = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class DataReply : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DataReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::UltraCombos.Kinect2MotionTransmit.UltraCombosKinect2MotionTransmitReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataReply() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataReply(DataReply other) : this() { + result_ = other.result_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DataReply Clone() { + return new DataReply(this); + } + + /// Field number for the "result" field. + public const int ResultFieldNumber = 1; + private string result_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Result { + get { return result_; } + set { + result_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DataReply); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DataReply other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Result != other.Result) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Result.Length != 0) hash ^= Result.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Result.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Result); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Result.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Result); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DataReply other) { + if (other == null) { + return; + } + if (other.Result.Length != 0) { + Result = other.Result; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Result = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs.meta b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs.meta new file mode 100644 index 0000000..07fe8d4 --- /dev/null +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/Grpc/UltraCombosKinect2MotionTransmit.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: fd3f3cb7e4054474fbb709ccad276dc6 +timeCreated: 1524800781 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectOpticalFlow.cs b/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectOpticalFlow.cs index e835c39..48230e2 100644 --- a/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectOpticalFlow.cs +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectOpticalFlow.cs @@ -11,6 +11,8 @@ namespace UltraCombos const int POSITION = 0; const int VELOCITY = 1; + public Kinect2MotionTransmit.KinectGrpcServer server; + [SerializeField] List kinectBuffers = new List(); public ComputeBuffer PositionBuffer { get { return kinectBuffers[POSITION].obj; } } @@ -33,10 +35,8 @@ namespace UltraCombos ComputeBuffer kinect_grid_buffer; public ComputeBuffer KinectGridBuffer { get { return kinect_grid_buffer; } } int grid_width, grid_height, grid_depth; - [Range(0, 5)] - public float kinectAmount = 0; - public List renderTextures; - Texture2DArray kinectTextureArray; + + [SerializeField, Header("Debug")] bool debug = false; @@ -53,8 +53,8 @@ namespace UltraCombos public ComputeBuffer HomeVelocityBuffer { get { return home_velocity_buffer; } } ComputeBuffer home_count_buffer; public ComputeBuffer HomeCountBuffer { get { return home_count_buffer; } } - int home_count = 0; - public int HomeCount { get { return home_count; } } + + private void Start() @@ -71,14 +71,12 @@ namespace UltraCombos } { - home_position_buffer = new ComputeBuffer(512 * 424 * renderTextures.Count, sizeof(float) * 4, ComputeBufferType.Append); - home_velocity_buffer = new ComputeBuffer(512 * 424 * renderTextures.Count, sizeof(float) * 4, ComputeBufferType.Append); + home_position_buffer = new ComputeBuffer(512 * 424, sizeof(float) * 4, ComputeBufferType.Append); + home_velocity_buffer = new ComputeBuffer(512 * 424, sizeof(float) * 4, ComputeBufferType.Append); home_count_buffer = new ComputeBuffer(1, sizeof(int), ComputeBufferType.Raw); } - { - kinectTextureArray = new Texture2DArray(512 * 2, 424, 8, TextureFormat.RGBAFloat, false); - } + } private void FixedUpdate() @@ -86,17 +84,34 @@ namespace UltraCombos if (args_buffer == null) { args_buffer = updateShader.CreateIndirectComputeArgsBuffer(width * height, 1, 1); - } - + } + + if (server != null) { - for (int i = 0; i < renderTextures.Count; i++) + if (home_position_buffer.count != server.FinalPositionBuffer.count) + { + home_position_buffer.Release(); + home_position_buffer = new ComputeBuffer(server.FinalPositionBuffer.count, + server.FinalPositionBuffer.stride, ComputeBufferType.Append); + } + + if (home_velocity_buffer.count != server.FinalVelocityBuffer.count) { - if (renderTextures[i].IsCreated()) - Graphics.CopyTexture(renderTextures[i], 0, kinectTextureArray, i); + home_velocity_buffer.Release(); + home_velocity_buffer = new ComputeBuffer(server.FinalVelocityBuffer.count, + server.FinalVelocityBuffer.stride, ComputeBufferType.Append); + } + + foreach (var buf in kinectBuffers) + { + if (buf.count != server.FinalPositionBuffer.count) + { + buf.Release(); + buf.Allocate(server.FinalVelocityBuffer.count, server.FinalVelocityBuffer.stride); + } } } - // update { var m = transform.localToWorldMatrix; @@ -113,23 +128,34 @@ namespace UltraCombos updateShader.SetVector("FluidRoot", fluidSimulation.GridRoot); updateShader.SetVector("FluidDim", fluidSimulation.GridDim); updateShader.SetInt("flipX", flipX ? 1 : 0); - updateShader.SetInt("NumKinects", renderTextures.Count); - - //updateShader.SetTexture(0, "PositionTexture", renderTextures[POSITION]); - //updateShader.SetTexture(0, "VelocityTexture", renderTextures[VELOCITY]); - updateShader.SetTexture(0, "MotionTextureArray", kinectTextureArray); - updateShader.SetTexture(0, "MotionTexture", renderTextures[0]); + foreach (var buf in kinectBuffers) updateShader.SetBuffer(0, buf.bufferName, buf.obj); updateShader.SetBuffer(0, "KinectGridBuffer", kinect_grid_buffer); updateShader.SetBuffer(0, "HomePositionBuffer", home_position_buffer); updateShader.SetBuffer(0, "HomeVelocityBuffer", home_velocity_buffer); - updateShader.DispatchIndirect(0, args_buffer); + + if (server != null) + { + updateShader.SetBuffer(0, "FinalPositionBuffer", server.FinalPositionBuffer); + updateShader.SetBuffer(0, "FinalVelocityBuffer", server.FinalVelocityBuffer); + + uint x, y, z; + updateShader.GetKernelThreadGroupSizes(0, out x, out y, out z); + int tgx = Mathf.CeilToInt((float)server.FinalPositionBuffer.count / x); + + updateShader.Dispatch(0, tgx, 1, 1); + } + else + { + updateShader.DispatchIndirect(0, args_buffer); + } } { ComputeBuffer.CopyCount(home_position_buffer, home_count_buffer, 0); + int home_count; #if false var data = new int[home_count_buffer.count]; home_count_buffer.GetData(data); @@ -157,7 +183,6 @@ namespace UltraCombos applyShader.SetFloat("timeStep", Time.fixedDeltaTime); applyShader.SetFloat("temperatureAmount", fluidSimulation.m_temperatureAmount); applyShader.SetFloat("densityAmount", fluidSimulation.m_densityAmount); - applyShader.SetFloat("kinectAmount", kinectAmount); applyShader.SetBuffer(0, "KinectGridBuffer", kinect_grid_buffer); applyShader.DispatchIndirect(0, clear_grid_buffer_args_buffer); } diff --git a/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectUpdateShader.compute b/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectUpdateShader.compute index 49027cf..d4207c2 100644 --- a/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectUpdateShader.compute +++ b/Unity_2018_Frozen/Assets/KinectOpticalFlow/KinectUpdateShader.compute @@ -8,14 +8,17 @@ RWStructuredBuffer KinectPositionBuffer; RWStructuredBuffer KinectVelocityBuffer; RWStructuredBuffer KinectGridBuffer; +//RWStructuredBuffer KinectOpticalBuffer; +RWStructuredBuffer FinalPositionBuffer; +RWStructuredBuffer FinalVelocityBuffer; AppendStructuredBuffer HomePositionBuffer; AppendStructuredBuffer HomeVelocityBuffer; //Texture2D PositionTexture; //Texture2D VelocityTexture; -Texture2D MotionTexture; -Texture2DArray MotionTextureArray; +//Texture2D MotionTexture; +//Texture2DArray MotionTextureArray; float4 ClipMin; float4 ClipMax; @@ -26,56 +29,52 @@ float4 FluidDim; int flipX; int NumKinects; -[numthreads(512,1,1)] +[numthreads(512, 1, 1)] void CSMain (uint3 id : SV_DispatchThreadID) { - uint2 tex_coord = uint2(id.x % HEIGHT, id.x / HEIGHT); + //uint2 tex_coord = uint2(id.x % WIDTH, id.x / WIDTH); + + float4 pos = FinalPositionBuffer[id.x]; + //pos.y *= -1; + //pos.z *= -1; + pos.x = lerp(pos.x, -pos.x, flipX); - for (int i = 0; i < NumKinects; i++) - { - float4 pos = float4(MotionTexture[tex_coord].xyz, 1); - pos = float4(MotionTextureArray[uint3(tex_coord, i)].xyz, 1); - //pos.y *= -1; - pos.z *= -1; - pos.x = lerp(pos.x, -pos.x, flipX); - - float pos_mag = length(pos.xyz); + float pos_mag = length(pos.xyz); + { + pos = mul(pos, ModelMatrix); + + float4 vel = FinalVelocityBuffer[id.x]; + //vel = float4(0, 0, 0.01, 0); + //vel.y *= -1; + //vel.z *= -1; + vel.x = lerp(vel.x, -vel.x, flipX); + + float3 grid_pos = (pos.xyz - FluidRoot.xyz) / FluidSize.xyz; + int grid_index = -1; + if (grid_pos.x > 0 && grid_pos.x < 1 && + grid_pos.y > 0 && grid_pos.y < 1 && + grid_pos.z > 0 && grid_pos.z < 1 && + pos_mag > 0.0f)// && length(pos) > 10.0f) { - pos = mul(pos, ModelMatrix); - - float4 vel = MotionTexture[tex_coord + uint2(WIDTH, 0)]; - vel = MotionTextureArray[uint3(tex_coord, i) + uint3(WIDTH, 0, 0)]; - //vel.y *= -1; - vel.z *= -1; - vel.x = lerp(vel.x, -vel.x, flipX); - - float3 grid_pos = (pos.xyz - FluidRoot.xyz) / FluidSize.xyz; - int grid_index = -1; - if (grid_pos.x > 0 && grid_pos.x < 1 && - grid_pos.y > 0 && grid_pos.y < 1 && - grid_pos.z > 0 && grid_pos.z < 1 && - pos_mag > 0.0f)// && length(pos) > 10.0f) + grid_pos *= FluidDim.xyz; + grid_index = (int)grid_pos.x + (int)grid_pos.y * FluidDim.x + (int)grid_pos.z * FluidDim.x * FluidDim.y; + KinectGridBuffer[grid_index] += float4(vel.xyz, 1); + + if (pos_mag > 0.1f)// && pos.y < 0.5f) { - grid_pos *= FluidDim.xyz; - grid_index = (int)grid_pos.x + (int)grid_pos.y * FluidDim.x + (int)grid_pos.z * FluidDim.x * FluidDim.y; - KinectGridBuffer[grid_index] += float4(vel.xyz, 1); - - if (pos_mag > 0.1f)// && pos.y < 0.5f) - { - //pos.y = 0.0f; - //vel.xyz = float3(0, 0, 0); - - HomePositionBuffer.Append(float4(pos.xyz, 0)); - HomeVelocityBuffer.Append(float4(vel.xyz, 0)); - } - - } + //pos.y = 0.0f; + //vel.xyz = float3(0, 0, 0); - KinectPositionBuffer[id.x] = float4(pos.xyz, grid_index); - KinectVelocityBuffer[id.x] = float4((pos_mag == 0.0f) ? float3(0, 0, 0) : vel.xyz, 0); + HomePositionBuffer.Append(float4(pos.xyz, 0)); + HomeVelocityBuffer.Append(float4(vel.xyz, 0)); + } } + + KinectPositionBuffer[id.x] = float4(pos.xyz, grid_index); + KinectVelocityBuffer[id.x] = float4((pos_mag == 0.0f) ? float3(0, 0, 0) : vel.xyz, 0); + } }