From 37be74a4239a5b5f71d4593d3f26a2aedb0afd05 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 27 Oct 2019 22:17:49 +0900 Subject: [PATCH 01/22] =?UTF-8?q?V3.0=E5=90=91=E3=81=91=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs b/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs index 5020bc3..933a1ad 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs +++ b/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs @@ -45,6 +45,7 @@ public class EVMC4U_HandCatch : MonoBehaviour public float SpeedMultiplier = 1.0f; ExternalReceiver exrcv; + InputReceiver inputrcv; Transform leftHand; Transform rightHand; @@ -76,8 +77,10 @@ void Start() { //ExternalReceiverにキー操作を登録 exrcv = GetComponent(); - exrcv.ControllerInputAction.AddListener(ControllerInputEvent); - exrcv.KeyInputAction.AddListener(KeyInputEvent); + inputrcv = GetComponentInChildren(); + + inputrcv.ControllerInputAction.AddListener(ControllerInputEvent); + inputrcv.KeyInputAction.AddListener(KeyInputEvent); //ブレ防止用にフィルタを設定 exrcv.BonePositionFilterEnable = true; From 16390b28cc7943629c8ab7eb6331924235887fb0 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 27 Oct 2019 23:11:41 +0900 Subject: [PATCH 02/22] =?UTF-8?q?=E5=BD=93=E3=81=9F=E3=82=8A=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=84=E3=82=AA=E3=83=95=E3=82=BB=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=AA=BF=E6=95=B4=E5=8F=AF=E8=83=BD=E3=81=AB=E3=80=82?= =?UTF-8?q?=E6=8E=B4=E3=82=93=E3=81=A7=E3=81=84=E3=82=8B=E3=82=82=E3=81=AE?= =?UTF-8?q?=E3=82=92=E5=8F=8D=E5=AF=BE=E3=81=AE=E6=89=8B=E3=81=A7=E6=8E=B4?= =?UTF-8?q?=E3=82=80=E3=81=A8=E8=A6=AA=E5=AD=90=E9=96=A2=E4=BF=82=E3=81=8C?= =?UTF-8?q?=E5=B4=A9=E5=A3=8A=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3(=E3=81=A4=E3=81=8B=E3=82=81=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB)=E3=80=82StickyMode(?= =?UTF-8?q?=E6=8A=BC=E3=81=97=E3=81=A6=E3=81=A4=E3=81=8B=E3=81=BF=E3=80=81?= =?UTF-8?q?=E6=8A=BC=E3=81=97=E3=81=A6=E9=9B=A2=E3=81=99=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=89)=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EVMC4U_HandCatch/EVMC4U_HandCatch.cs | 121 ++++++++++++++---- 1 file changed, 98 insertions(+), 23 deletions(-) diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs b/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs index 933a1ad..5a96786 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs +++ b/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs @@ -40,10 +40,22 @@ public class EVMC4U_HandCatch : MonoBehaviour public float NonHoldFilter = 0f; public float InHoldFilter = 0.90f; + float offset = 0.06f; + float size = 0.15f; + public string CollisionTag = ""; public float SpeedMultiplier = 1.0f; + public string LeftKey = "Z"; + public string RightKey = "X"; + public string ControllerButton = "ClickTrigger"; + + public bool StickyMode = false; + + bool stickyLeft = false; + bool stickyRight = false; + ExternalReceiver exrcv; InputReceiver inputrcv; @@ -95,8 +107,8 @@ void Start() //左手当たり判定スフィア生成 leftSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); leftSphere.transform.parent = leftHand; - leftSphere.transform.localPosition = new Vector3(-0.12f, 0f, 0f); - leftSphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); + leftSphere.transform.localPosition = new Vector3(-offset, 0f, 0f); + leftSphere.transform.localScale = new Vector3(size, size, size); //左手当たり判定スフィアコライダー設定 var leftCollider = leftSphere.GetComponent(); @@ -114,8 +126,8 @@ void Start() //右手当たり判定スフィア生成 rightSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); rightSphere.transform.parent = rightHand; - rightSphere.transform.localPosition = new Vector3(0.12f, 0f, 0f); - rightSphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); + rightSphere.transform.localPosition = new Vector3(offset, 0f, 0f); + rightSphere.transform.localScale = new Vector3(size, size, size); //右手当たり判定スフィアコライダー設定 var rightCollider = rightSphere.GetComponent(); @@ -136,9 +148,11 @@ void FixedUpdate() { //剥がれ防止で親を設定 leftSphere.transform.parent = leftHand; - leftSphere.transform.localPosition = new Vector3(-0.12f, 0f, 0f); + leftSphere.transform.localPosition = new Vector3(-offset, 0f, 0f); + leftSphere.transform.localScale = new Vector3(size, size, size); rightSphere.transform.parent = rightHand; - rightSphere.transform.localPosition = new Vector3(0.12f, 0f, 0f); + rightSphere.transform.localPosition = new Vector3(offset, 0f, 0f); + rightSphere.transform.localScale = new Vector3(size, size, size); //表示非表示を反映 if (ShowColliderOld != ShowCollider) { @@ -167,6 +181,16 @@ void CatchLeft(bool s) if (CollisionTag != "" && CollisionTag != leftHelper.other.tag) { return; } + //左手ですでに掴んでいるものは掴まない + if (leftHelper.other.gameObject.transform.parent == leftSphere.transform) + { + return; + } + //右手ですでに掴んでいるものは掴まない + if (leftHelper.other.gameObject.transform.parent == rightSphere.transform) + { + return; + } //解除用に保持 leftCatchedObject = leftHelper.other.gameObject; @@ -225,6 +249,16 @@ void CatchRight(bool s) { return; } + //左手ですでに掴んでいるものは掴まない + if (rightHelper.other.gameObject.transform.parent == leftSphere.transform) + { + return; + } + //右手ですでに掴んでいるものは掴まない + if (rightHelper.other.gameObject.transform.parent == rightSphere.transform) + { + return; + } //解除用に保持 rightCatchedObject = rightHelper.other.gameObject; @@ -276,34 +310,75 @@ void CatchRight(bool s) public void KeyInputEvent(EVMC4U.KeyInput key) { - //Zキーが押されたか - if (key.name == "Z") + if (!StickyMode) { - //つかみ・離し - CatchLeft(key.active == 1); + //Zキーが押されたか + if (key.name == LeftKey) + { + //つかみ・離し + CatchLeft(key.active == 1); + } + //Xキー押されたか + if (key.name == RightKey) + { + //つかみ・離し + CatchRight(key.active == 1); + } } - //Xキー押されたか - if (key.name == "X") - { - //つかみ・離し - CatchRight(key.active == 1); + else { + if (key.active == 1) + { + //Zキーが押されたか + if (key.name == LeftKey) + { + //つかみ・離し + stickyLeft = !stickyLeft; + CatchLeft(stickyLeft); + } + //Xキー押されたか + if (key.name == RightKey) + { + //つかみ・離し + stickyRight = !stickyRight; + CatchRight(stickyRight); + } + } } } public void ControllerInputEvent(EVMC4U.ControllerInput con) { //トリガー引かれたか - if (con.name == "ClickTrigger") + if (con.name == ControllerButton) { - if (con.IsLeft == 1) + if (!StickyMode) { - //つかみ・離し - CatchLeft(con.active == 1); + if (con.IsLeft == 1) + { + //つかみ・離し + CatchLeft(con.active == 1); + } + else + { + //つかみ・離し + CatchRight(con.active == 1); + } } - else - { - //つかみ・離し - CatchRight(con.active == 1); + else { + if (con.active == 1) { + if (con.IsLeft == 1) + { + //つかみ・離し + stickyLeft = !stickyLeft; + CatchLeft(stickyLeft); + } + else + { + //つかみ・離し + stickyRight = !stickyRight; + CatchRight(stickyRight); + } + } } } } From 5564f4dad36c6745ea0cecf686fee97afc981c3e Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 27 Oct 2019 23:45:45 +0900 Subject: [PATCH 03/22] =?UTF-8?q?=E3=82=AB=E3=83=A1=E3=83=A9=E5=88=B6?= =?UTF-8?q?=E5=BE=A1=E3=82=B5=E3=83=B3=E3=83=97=E3=83=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EVMC4U_CCCameraControl.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs b/EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs new file mode 100644 index 0000000..b573d06 --- /dev/null +++ b/EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs @@ -0,0 +1,44 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace EVMC4U +{ + public class EVMC4U_CCCameraControl : MonoBehaviour + { + public InputReceiver r; + public Camera c; + private void Update() + { + c.fieldOfView = r.CCValuesMonitor[16] * 90 + 1; + c.transform.position = new Vector3((r.CCValuesMonitor[0] - 0.5f) * 3f, (r.CCValuesMonitor[1] - 0.5f) * 3f, (r.CCValuesMonitor[2]-0.5f)*3f); + c.transform.rotation = Quaternion.Euler(r.CCValuesMonitor[3]*360f, r.CCValuesMonitor[4] * 360f, r.CCValuesMonitor[5] * 360f); + } + } +} \ No newline at end of file From ce1c547aeb8f38f1c89e293a657b330204649189 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 28 Oct 2019 23:10:05 +0900 Subject: [PATCH 04/22] =?UTF-8?q?C#=E3=81=A3=E3=81=BD=E3=81=8F=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CCCameraControl/CCCameraControl.cs} | 2 +- .../CapsuleRigidbodyMover.cs} | 2 +- .../HandCatch/HandCatch.cs} | 10 +-- .../HandCatch/HandCatch_Helper.cs} | 2 +- .../AddComponentTest.cs} | 2 +- .../DaisyChainTesting.cs} | 2 +- .../InputTesting.cs} | 2 +- EVMC4U/class/EVMC4UeventClass.cs | 45 +++++++++++ EVMC4U/class/EVMC4Ustructs.cs | 75 +++++++++++++++++++ .../ExternalReceiverManager.cs} | 61 --------------- EVMC4U/class/IExternalReceiver.cs | 39 ++++++++++ 11 files changed, 170 insertions(+), 72 deletions(-) rename EVMC4U/{EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs => SampleScripts/CCCameraControl/CCCameraControl.cs} (96%) rename EVMC4U/{EVMC4U_Script/EVMC4U_CapsuleRigidbodyMover/EVMC4U_CapsuleRigidbodyMover.cs => SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs} (98%) rename EVMC4U/{EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs => SampleScripts/HandCatch/HandCatch.cs} (97%) rename EVMC4U/{EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch_Helper.cs => SampleScripts/HandCatch/HandCatch_Helper.cs} (96%) rename EVMC4U/{EVMC4U_Test/EVMC4UAddComponentTest.cs => Test/AddComponentTest.cs} (96%) rename EVMC4U/{EVMC4U_Test/EVMC4UDaisyChainTesting.cs => Test/DaisyChainTesting.cs} (95%) rename EVMC4U/{EVMC4U_Test/EVMC4UInputTesting.cs => Test/InputTesting.cs} (98%) create mode 100644 EVMC4U/class/EVMC4UeventClass.cs create mode 100644 EVMC4U/class/EVMC4Ustructs.cs rename EVMC4U/{InterfaceAndStruct.cs => class/ExternalReceiverManager.cs} (67%) create mode 100644 EVMC4U/class/IExternalReceiver.cs diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs b/EVMC4U/SampleScripts/CCCameraControl/CCCameraControl.cs similarity index 96% rename from EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs rename to EVMC4U/SampleScripts/CCCameraControl/CCCameraControl.cs index b573d06..dc2270f 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_CCCameraControl/EVMC4U_CCCameraControl.cs +++ b/EVMC4U/SampleScripts/CCCameraControl/CCCameraControl.cs @@ -30,7 +30,7 @@ namespace EVMC4U { - public class EVMC4U_CCCameraControl : MonoBehaviour + public class CCCameraControl : MonoBehaviour { public InputReceiver r; public Camera c; diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_CapsuleRigidbodyMover/EVMC4U_CapsuleRigidbodyMover.cs b/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs similarity index 98% rename from EVMC4U/EVMC4U_Script/EVMC4U_CapsuleRigidbodyMover/EVMC4U_CapsuleRigidbodyMover.cs rename to EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs index be5db3e..3362335 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_CapsuleRigidbodyMover/EVMC4U_CapsuleRigidbodyMover.cs +++ b/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs @@ -29,7 +29,7 @@ using UnityEngine; namespace EVMC4U { - public class EVMC4U_CapsuleRigidbodyMover : MonoBehaviour + public class CapsuleRigidbodyMover : MonoBehaviour { Rigidbody r; public Transform model; diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch.cs similarity index 97% rename from EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs rename to EVMC4U/SampleScripts/HandCatch/HandCatch.cs index 5a96786..9c8f79f 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch.cs @@ -31,7 +31,7 @@ namespace EVMC4U { [RequireComponent(typeof(EVMC4U.ExternalReceiver))] - public class EVMC4U_HandCatch : MonoBehaviour + public class HandCatch : MonoBehaviour { //表示オンオフ public bool ShowCollider = true; @@ -73,8 +73,8 @@ public class EVMC4U_HandCatch : MonoBehaviour Vector3 leftLastSpeed; Vector3 rightLastSpeed; - EVMC4U_HandCatch_Helper leftHelper; - EVMC4U_HandCatch_Helper rightHelper; + HandCatch_Helper leftHelper; + HandCatch_Helper rightHelper; GameObject leftCatchedObject; GameObject rightCatchedObject; @@ -121,7 +121,7 @@ void Start() leftRigidBody.isKinematic = true; //左手当たり判定ヘルパー追加 - leftHelper = leftSphere.AddComponent(); + leftHelper = leftSphere.AddComponent(); //右手当たり判定スフィア生成 rightSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); @@ -140,7 +140,7 @@ void Start() rightRigidBody.isKinematic = true; //右手当たり判定ヘルパー追加 - rightHelper = rightSphere.AddComponent(); + rightHelper = rightSphere.AddComponent(); } //物理演算のためFixedUpdate diff --git a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch_Helper.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs similarity index 96% rename from EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch_Helper.cs rename to EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs index 779adf4..930329c 100644 --- a/EVMC4U/EVMC4U_Script/EVMC4U_HandCatch/EVMC4U_HandCatch_Helper.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs @@ -31,7 +31,7 @@ namespace EVMC4U { - public class EVMC4U_HandCatch_Helper : MonoBehaviour + public class HandCatch_Helper : MonoBehaviour { public bool Trigger = false; public Collider other; diff --git a/EVMC4U/EVMC4U_Test/EVMC4UAddComponentTest.cs b/EVMC4U/Test/AddComponentTest.cs similarity index 96% rename from EVMC4U/EVMC4U_Test/EVMC4UAddComponentTest.cs rename to EVMC4U/Test/AddComponentTest.cs index cd51be9..dbd8023 100644 --- a/EVMC4U/EVMC4U_Test/EVMC4UAddComponentTest.cs +++ b/EVMC4U/Test/AddComponentTest.cs @@ -31,7 +31,7 @@ namespace EVMC4U { - public class EVMC4UAddComponentTest : MonoBehaviour + public class AddComponentTest : MonoBehaviour { public GameObject Model; diff --git a/EVMC4U/EVMC4U_Test/EVMC4UDaisyChainTesting.cs b/EVMC4U/Test/DaisyChainTesting.cs similarity index 95% rename from EVMC4U/EVMC4U_Test/EVMC4UDaisyChainTesting.cs rename to EVMC4U/Test/DaisyChainTesting.cs index cf6e581..c26810c 100644 --- a/EVMC4U/EVMC4U_Test/EVMC4UDaisyChainTesting.cs +++ b/EVMC4U/Test/DaisyChainTesting.cs @@ -31,7 +31,7 @@ namespace EVMC4U { - public class EVMC4UDaisyChainTesting : MonoBehaviour, EVMC4U.IExternalReceiver + public class DaisyChainTesting : MonoBehaviour, EVMC4U.IExternalReceiver { //デイジーチェーンテスト public void MessageDaisyChain(ref Message message, int callCount) diff --git a/EVMC4U/EVMC4U_Test/EVMC4UInputTesting.cs b/EVMC4U/Test/InputTesting.cs similarity index 98% rename from EVMC4U/EVMC4U_Test/EVMC4UInputTesting.cs rename to EVMC4U/Test/InputTesting.cs index a0be94e..3b94bd9 100644 --- a/EVMC4U/EVMC4U_Test/EVMC4UInputTesting.cs +++ b/EVMC4U/Test/InputTesting.cs @@ -30,7 +30,7 @@ namespace EVMC4U { - public class EVMC4UInputTesting : MonoBehaviour + public class InputTesting : MonoBehaviour { public InputReceiver receiver; private void Start() diff --git a/EVMC4U/class/EVMC4UeventClass.cs b/EVMC4U/class/EVMC4UeventClass.cs new file mode 100644 index 0000000..1dd7cc0 --- /dev/null +++ b/EVMC4U/class/EVMC4UeventClass.cs @@ -0,0 +1,45 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +namespace EVMC4U { + //イベント定義 + [Serializable] + public class KeyInputEvent : UnityEvent { }; + [Serializable] + public class ControllerInputEvent : UnityEvent { }; + [Serializable] + public class MidiNoteInputEvent : UnityEvent { }; + [Serializable] + public class MidiCCValueInputEvent : UnityEvent { }; + [Serializable] + public class MidiCCButtonInputEvent : UnityEvent { }; +} diff --git a/EVMC4U/class/EVMC4Ustructs.cs b/EVMC4U/class/EVMC4Ustructs.cs new file mode 100644 index 0000000..9923f3e --- /dev/null +++ b/EVMC4U/class/EVMC4Ustructs.cs @@ -0,0 +1,75 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +namespace EVMC4U { + //キーボード入力情報 + public struct KeyInput + { + public int active; + public string name; + public int keycode; + } + + //コントローラ入力情報 + public struct ControllerInput + { + public int active; + public string name; + public int IsLeft; + public int IsTouch; + public int IsAxis; + public Vector3 Axis; + } + + //MIDI Note入力情報 + public struct MidiNote + { + public int active; + public int channel; + public int note; + public float velocity; + } + + //MIDI CC Value入力情報 + public struct MidiCCValue + { + public int knob; + public float value; + } + + //MIDI CC Button入力情報 + public struct MidiCCButton + { + public int knob; + public float active; + } +} diff --git a/EVMC4U/InterfaceAndStruct.cs b/EVMC4U/class/ExternalReceiverManager.cs similarity index 67% rename from EVMC4U/InterfaceAndStruct.cs rename to EVMC4U/class/ExternalReceiverManager.cs index a0cbaf4..3a2f855 100644 --- a/EVMC4U/InterfaceAndStruct.cs +++ b/EVMC4U/class/ExternalReceiverManager.cs @@ -31,12 +31,6 @@ using UnityEngine.Events; namespace EVMC4U { - //デイジーチェーン受信の最低限のインターフェース - public interface IExternalReceiver - { - void MessageDaisyChain(ref uOSC.Message message, int callCount); - } - public class ExternalReceiverManager { List receivers = new List(); @@ -88,59 +82,4 @@ public bool SendNextReceivers(uOSC.Message message, int callCount) return true; } } - - //キーボード入力情報 - public struct KeyInput - { - public int active; - public string name; - public int keycode; - } - - //コントローラ入力情報 - public struct ControllerInput - { - public int active; - public string name; - public int IsLeft; - public int IsTouch; - public int IsAxis; - public Vector3 Axis; - } - - //MIDI Note入力情報 - public struct MidiNote - { - public int active; - public int channel; - public int note; - public float velocity; - } - - //MIDI CC Value入力情報 - public struct MidiCCValue - { - public int knob; - public float value; - } - - //MIDI CC Button入力情報 - public struct MidiCCButton - { - public int knob; - public float active; - } - - - //イベント定義 - [Serializable] - public class KeyInputEvent : UnityEvent { }; - [Serializable] - public class ControllerInputEvent : UnityEvent { }; - [Serializable] - public class MidiNoteInputEvent : UnityEvent { }; - [Serializable] - public class MidiCCValueInputEvent : UnityEvent { }; - [Serializable] - public class MidiCCButtonInputEvent : UnityEvent { }; } diff --git a/EVMC4U/class/IExternalReceiver.cs b/EVMC4U/class/IExternalReceiver.cs new file mode 100644 index 0000000..25c2e1a --- /dev/null +++ b/EVMC4U/class/IExternalReceiver.cs @@ -0,0 +1,39 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +namespace EVMC4U { + //デイジーチェーン受信の最低限のインターフェース + public interface IExternalReceiver + { + void MessageDaisyChain(ref uOSC.Message message, int callCount); + } +} From 6718b19b32c2e9b45564586fce50699c82d5bd3e Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Thu, 31 Oct 2019 23:19:05 +0900 Subject: [PATCH 05/22] =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=88=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E3=83=BB=E3=83=AB=E3=83=BC=E3=83=88=E5=9B=9E=E8=BB=A2?= =?UTF-8?q?=E5=88=86=E9=9B=A2=E5=8C=96=20VR=E7=A7=BB=E5=8B=95=E3=82=B5?= =?UTF-8?q?=E3=83=B3=E3=83=97=E3=83=AB=E3=82=92=E3=83=AB=E3=83=BC=E3=83=88?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=9B=9E=E8=BB=A2=E5=88=86=E9=9B=A2=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/ExternalReceiver.cs | 43 +++++++++++++------ .../CapsuleRigidbodyMover.cs | 14 +++--- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/EVMC4U/ExternalReceiver.cs b/EVMC4U/ExternalReceiver.cs index 6d5de36..196eb08 100644 --- a/EVMC4U/ExternalReceiver.cs +++ b/EVMC4U/ExternalReceiver.cs @@ -41,7 +41,8 @@ public class ExternalReceiver : MonoBehaviour, IExternalReceiver public GameObject Model = null; [Header("Root Synchronize Option")] - public Transform RootTransform = null; + public Transform RootPositionTransform = null; + public Transform RootRotationTransform = null; public bool RootPositionSynchronize = true; //ルート座標同期(ルームスケール移動) public bool RootRotationSynchronize = true; //ルート回転同期 public bool RootScaleOffsetSynchronize = false; //MRスケール適用 @@ -153,11 +154,18 @@ void Update() blendShapeProxy = Model.GetComponent(); } - //ルート姿勢がない場合 - if (RootTransform == null && Model != null) + //ルート位置がない場合 + if (RootPositionTransform == null && Model != null) { //モデル姿勢をルート姿勢にする - RootTransform = Model.transform; + RootPositionTransform = Model.transform; + } + + //ルート回転がない場合 + if (RootRotationTransform == null && Model != null) + { + //モデル姿勢をルート姿勢にする + RootRotationTransform = Model.transform; } //モデルがない場合はエラー表示をしておく(親切心) @@ -213,15 +221,22 @@ private void ProcessMessage(ref uOSC.Message message) return; } - //ルート姿勢がない場合 - if (RootTransform == null && Model != null) + //ルート位置がない場合 + if (RootPositionTransform == null && Model != null) + { + //モデル姿勢をルート姿勢にする + RootPositionTransform = Model.transform; + } + + //ルート回転がない場合 + if (RootRotationTransform == null && Model != null) { //モデル姿勢をルート姿勢にする - RootTransform = Model.transform; + RootRotationTransform = Model.transform; } //モデルがないか、モデル姿勢、ルート姿勢が取得できないなら何もしない - if (Model == null || Model.transform == null || RootTransform == null) + if (Model == null || Model.transform == null || RootPositionTransform == null || RootRotationTransform == null) { return; } @@ -268,12 +283,12 @@ private void ProcessMessage(ref uOSC.Message message) //位置同期 if (RootPositionSynchronize) { - RootTransform.localPosition = pos; + RootPositionTransform.localPosition = pos; } //回転同期 if (RootRotationSynchronize) { - RootTransform.localRotation = rot; + RootRotationTransform.localRotation = rot; } //スケール同期とオフセット補正(v2.1拡張プロトコルの場合のみ) if (RootScaleOffsetSynchronize && message.values.Length > RootPacketLengthOfScaleAndOffset @@ -292,8 +307,12 @@ private void ProcessMessage(ref uOSC.Message message) offset.y = (float)message.values[12]; offset.z = (float)message.values[13]; - RootTransform.localScale = scale; - RootTransform.position -= offset; + Model.transform.localScale = scale; + + //位置同期が有効な場合のみオフセットを反映する + if (RootPositionSynchronize) { + RootPositionTransform.position -= offset; + } } } //ボーン姿勢 diff --git a/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs b/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs index 3362335..b19dbf4 100644 --- a/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs +++ b/EVMC4U/SampleScripts/CapsuleRigidbodyMover/CapsuleRigidbodyMover.cs @@ -31,8 +31,9 @@ namespace EVMC4U { public class CapsuleRigidbodyMover : MonoBehaviour { - Rigidbody r; - public Transform model; + public Transform MovePos; + public Transform MoveRot; + public Transform chest; EDirection direction = EDirection.STOP; bool click = false; @@ -48,17 +49,16 @@ enum EDirection { // Start is called before the first frame update void Start() { - r = GetComponent(); } // Update is called once per frame void Update() { switch (direction) { - case EDirection.FORWARD: transform.position += model.forward * 10f * Time.deltaTime; break; - case EDirection.BACK: transform.position += model.forward * -10f * Time.deltaTime; break; - case EDirection.LEFT: transform.Rotate(new Vector3(0, -100f * Time.deltaTime, 0)); break; - case EDirection.RIGHT: transform.Rotate(new Vector3(0, 100f * Time.deltaTime, 0)); break; + case EDirection.FORWARD: MovePos.position += chest.forward * 10f * Time.deltaTime; break; + case EDirection.BACK: MovePos.position += chest.forward * -10f * Time.deltaTime; break; + case EDirection.LEFT: MoveRot.Rotate(new Vector3(0, -100f * Time.deltaTime, 0)); break; + case EDirection.RIGHT: MoveRot.Rotate(new Vector3(0, 100f * Time.deltaTime, 0)); break; default: break; } } From 01c3c1bfaf1c6475d3315184f50398d974362f1d Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sat, 2 Nov 2019 22:16:15 +0900 Subject: [PATCH 06/22] =?UTF-8?q?XR=E3=82=AB=E3=83=A1=E3=83=A9=E8=BF=BD?= =?UTF-8?q?=E5=BE=93=E7=84=A1=E5=8A=B9=E5=8C=96=E3=82=B9=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=97=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extra/DisableXRCamera.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 extra/DisableXRCamera.cs diff --git a/extra/DisableXRCamera.cs b/extra/DisableXRCamera.cs new file mode 100644 index 0000000..7110292 --- /dev/null +++ b/extra/DisableXRCamera.cs @@ -0,0 +1,40 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.XR; + +public class DisableXRCamera : MonoBehaviour +{ + void Start() + { + XRDevice.DisableAutoXRCameraTracking(GetComponent(), false); + transform.localPosition = Vector3.zero; + transform.localRotation = Quaternion.identity; + } +} From d9ae55b4fe9b8561a0e679a21badd6588bedde18 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 3 Nov 2019 00:54:30 +0900 Subject: [PATCH 07/22] =?UTF-8?q?=E9=80=81=E4=BF=A1=E3=82=B5=E3=83=B3?= =?UTF-8?q?=E3=83=97=E3=83=AB=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extra/SendTest.cs | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 extra/SendTest.cs diff --git a/extra/SendTest.cs b/extra/SendTest.cs new file mode 100644 index 0000000..c11bbf5 --- /dev/null +++ b/extra/SendTest.cs @@ -0,0 +1,59 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[RequireComponent(typeof(uOSC.uOscClient))] +public class SendTest : MonoBehaviour { + public Transform HMD; + public Transform con1; + public Transform con2; + public Transform tra; + + uOSC.uOscClient client; + // Use this for initialization + void Start () { + client = GetComponent(); + } + + // Update is called once per frame + void Update () { + client.Send("/VMC/Ext/Hmd/Pos", "HMD", + HMD.position.x, HMD.position.y, HMD.position.z, + HMD.rotation.x, HMD.rotation.y, HMD.rotation.z, HMD.rotation.w); + client.Send("/VMC/Ext/Con/Pos", "Con1", + con1.position.x, con1.position.y, con1.position.z, + con1.rotation.x, con1.rotation.y, con1.rotation.z, con1.rotation.w); + client.Send("/VMC/Ext/Con/Pos", "Con2", + con2.position.x, con2.position.y, con2.position.z, + con2.rotation.x, con2.rotation.y, con2.rotation.z, con2.rotation.w); + client.Send("/VMC/Ext/Tra/Pos", "Tra", + tra.position.x, tra.position.y, tra.position.z, + tra.rotation.x, tra.rotation.y, tra.rotation.z, tra.rotation.w); + } +} From d85c10eb6b906612e162304f278a93edfefa067f Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 3 Nov 2019 02:57:29 +0900 Subject: [PATCH 08/22] =?UTF-8?q?=E9=AB=98=E8=A7=A3=E5=83=8F=E5=BA=A6?= =?UTF-8?q?=E3=82=AB=E3=83=A1=E3=83=A9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../misc/HiResolutionPhotoCamera.cs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 EVMC4U/SampleScripts/misc/HiResolutionPhotoCamera.cs diff --git a/EVMC4U/SampleScripts/misc/HiResolutionPhotoCamera.cs b/EVMC4U/SampleScripts/misc/HiResolutionPhotoCamera.cs new file mode 100644 index 0000000..a6b33a9 --- /dev/null +++ b/EVMC4U/SampleScripts/misc/HiResolutionPhotoCamera.cs @@ -0,0 +1,83 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class HiResolutionPhotoCamera : MonoBehaviour { + //撮影したい解像度 + public int width = 4096; + public int height = 2160; + + //撮影したいカメラ + public Camera cam; + + //撮影ボタン + public bool shot = false; + + void Update () { + //撮影ボタンが押されたら撮影する + if (shot) { + shot = false; + TakePhoto(); + } + } + + void TakePhoto() { + //撮影したい解像度のRenderテクスチャを作成 + var renderTexture = new RenderTexture(width, height, 24); + //アクティブなレンダーテクスチャを保存 + var save = RenderTexture.active; + + //カメラに描画対象を設定 + cam.targetTexture = renderTexture; + //ReadPixelsの取得元(アクティブなレンダーテクスチャ)を設定 + RenderTexture.active = renderTexture; + + //即座にレンダリングする + cam.Render(); + + //テクスチャを生成して読み取り + Texture2D texture = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.ARGB32, false); + texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0); + texture.Apply(); + + //テクスチャをpngファイルに保存 + byte[] data = texture.EncodeToPNG(); + File.WriteAllBytes("output" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss-ff")+ ".png", data); + + //破棄 + DestroyImmediate(texture); + + //カメラの描画対象を元に戻す + cam.targetTexture = null; + //アクティブなレンダーテクスチャを復元 + RenderTexture.active = save; + } +} From b91e36c6187851cac491e4bb0ad06c70fc912e2b Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 3 Nov 2019 03:03:32 +0900 Subject: [PATCH 09/22] =?UTF-8?q?=E9=9D=99=E6=AD=A2=E7=94=BB=E6=92=AE?= =?UTF-8?q?=E5=BD=B1=E5=90=91=E3=81=91=E3=83=95=E3=83=AA=E3=83=BC=E3=82=BA?= =?UTF-8?q?(=E4=BD=8D=E7=BD=AE=E5=90=8C=E6=9C=9F=E5=81=9C=E6=AD=A2)?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/ExternalReceiver.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/EVMC4U/ExternalReceiver.cs b/EVMC4U/ExternalReceiver.cs index 196eb08..ef0fd55 100644 --- a/EVMC4U/ExternalReceiver.cs +++ b/EVMC4U/ExternalReceiver.cs @@ -39,10 +39,11 @@ public class ExternalReceiver : MonoBehaviour, IExternalReceiver { [Header("ExternalReceiver v3.0")] public GameObject Model = null; + public bool Freeze = false; //すべての同期を止める(撮影向け) [Header("Root Synchronize Option")] - public Transform RootPositionTransform = null; - public Transform RootRotationTransform = null; + public Transform RootPositionTransform = null; //VR向けroot位置同期オブジェクト指定 + public Transform RootRotationTransform = null; //VR向けroot回転同期オブジェクト指定 public bool RootPositionSynchronize = true; //ルート座標同期(ルームスケール移動) public bool RootRotationSynchronize = true; //ルート回転同期 public bool RootScaleOffsetSynchronize = false; //MRスケール適用 @@ -198,7 +199,9 @@ public void MessageDaisyChain(ref uOSC.Message message, int callCount) } //メッセージを処理 - ProcessMessage(ref message); + if (!Freeze) { + ProcessMessage(ref message); + } //次のデイジーチェーンへ伝える if (!externalReceiverManager.SendNextReceivers(message, callCount)) From 62d7b107350916f64796f86a7010592d6ed715a7 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 3 Nov 2019 10:46:20 +0900 Subject: [PATCH 10/22] =?UTF-8?q?=E4=BB=AE=E6=83=B3MIDICC=E3=80=81VMC?= =?UTF-8?q?=E3=82=AB=E3=83=A1=E3=83=A9=E5=88=B6=E5=BE=A1=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extra/SendTest.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/extra/SendTest.cs b/extra/SendTest.cs index c11bbf5..aa9499b 100644 --- a/extra/SendTest.cs +++ b/extra/SendTest.cs @@ -34,6 +34,7 @@ public class SendTest : MonoBehaviour { public Transform con1; public Transform con2; public Transform tra; + public Transform cam; uOSC.uOscClient client; // Use this for initialization @@ -43,6 +44,19 @@ void Start () { // Update is called once per frame void Update () { + client.Send("/VMC/Ext/Set/Period", + 1, 2, 3, 4, 5, 6); + + client.Send("/VMC/Ext/Midi/CC/Val", 0, Mathf.Sin(Time.time)); + + client.Send("/VMC/Ext/Cam", 0, Mathf.Sin(Time.time)); + + + client.Send("/VMC/Ext/Cam", "FreeCam", + cam.position.x, cam.position.y, cam.position.z, + cam.rotation.x, cam.rotation.y, cam.rotation.z, cam.rotation.w, + (float)90f); + client.Send("/VMC/Ext/Hmd/Pos", "HMD", HMD.position.x, HMD.position.y, HMD.position.z, HMD.rotation.x, HMD.rotation.y, HMD.rotation.z, HMD.rotation.w); From f7c8d6e73fb6bf1d5815375e693cf63262d67d45 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Sun, 3 Nov 2019 11:58:01 +0900 Subject: [PATCH 11/22] =?UTF-8?q?=E8=A6=96=E7=B7=9A=E5=88=B6=E5=BE=A1?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=81=E4=BD=99=E8=A8=88=E3=81=AA=E3=82=AB=E3=83=A1=E3=83=A9?= =?UTF-8?q?=E5=88=B6=E5=BE=A1=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extra/SendTest.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/extra/SendTest.cs b/extra/SendTest.cs index aa9499b..89e138a 100644 --- a/extra/SendTest.cs +++ b/extra/SendTest.cs @@ -35,6 +35,8 @@ public class SendTest : MonoBehaviour { public Transform con2; public Transform tra; public Transform cam; + public Transform eye; + public bool eyeEnable = false; uOSC.uOscClient client; // Use this for initialization @@ -47,16 +49,17 @@ void Update () { client.Send("/VMC/Ext/Set/Period", 1, 2, 3, 4, 5, 6); - client.Send("/VMC/Ext/Midi/CC/Val", 0, Mathf.Sin(Time.time)); - - client.Send("/VMC/Ext/Cam", 0, Mathf.Sin(Time.time)); - - - client.Send("/VMC/Ext/Cam", "FreeCam", - cam.position.x, cam.position.y, cam.position.z, - cam.rotation.x, cam.rotation.y, cam.rotation.z, cam.rotation.w, - (float)90f); - +// client.Send("/VMC/Ext/Midi/CC/Val", 0, Mathf.Sin(Time.time)); +// client.Send("/VMC/Ext/Blend/Val", "JOY", 1.0f); + client.Send("/VMC/Ext/Blend/Apply"); + /* + client.Send("/VMC/Ext/Cam", "FreeCam", + cam.position.x, cam.position.y, cam.position.z, + cam.rotation.x, cam.rotation.y, cam.rotation.z, cam.rotation.w, + (float)90f); + */ + client.Send("/VMC/Ext/Set/Eye", eyeEnable?1:0, + eye.position.x, eye.position.y, eye.position.z); client.Send("/VMC/Ext/Hmd/Pos", "HMD", HMD.position.x, HMD.position.y, HMD.position.z, HMD.rotation.x, HMD.rotation.y, HMD.rotation.z, HMD.rotation.w); From 60fa5e018d56b525982afbed2f54feacebadc5ff Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 19:09:59 +0900 Subject: [PATCH 12/22] =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=91=E3=82=B9?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF=E5=AF=BE=E8=B1=A1=E3=81=AE?= =?UTF-8?q?=E5=A7=BF=E5=8B=A2(=E3=83=9C=E3=83=BC=E3=83=B3=E5=A7=BF?= =?UTF-8?q?=E5=8B=A2=E3=81=8A=E3=82=88=E3=81=B3=E3=82=AB=E3=83=A1=E3=83=A9?= =?UTF-8?q?=E5=A7=BF=E5=8B=A2)=E3=81=AE=E5=8F=8D=E6=98=A0=E3=82=92?= =?UTF-8?q?=E3=80=81=E5=8F=97=E4=BF=A1=E6=99=82=E5=8D=B3=E6=99=82=E3=81=A7?= =?UTF-8?q?=E3=81=AF=E3=81=AA=E3=81=8F=E3=80=81=E3=82=AD=E3=83=A3=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=81=97=E3=81=A6=E6=9B=B4=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/CameraReceiver.cs | 83 +++++++++-------- EVMC4U/ExternalReceiver.cs | 182 ++++++++++++++++++++++--------------- 2 files changed, 157 insertions(+), 108 deletions(-) diff --git a/EVMC4U/CameraReceiver.cs b/EVMC4U/CameraReceiver.cs index 7f780a0..7822544 100644 --- a/EVMC4U/CameraReceiver.cs +++ b/EVMC4U/CameraReceiver.cs @@ -56,8 +56,13 @@ public class CameraReceiver : MonoBehaviour, IExternalReceiver private Quaternion cameraRotFilter = Quaternion.identity; //メッセージ処理一時変数struct(負荷対策) - Vector3 pos; - Quaternion rot; + //Vector3 pos; + //Quaternion rot; + + //カメラ情報のキャッシュ + Vector3 cameraPos = Vector3.zero; + Quaternion cameraRot = Quaternion.identity; + float fov = 0; void Start() { @@ -65,6 +70,36 @@ void Start() StatusMessage = "Waiting for Master..."; } + void Update() + { + //カメラがセットされているならば + if (VMCControlledCamera != null && VMCControlledCamera.transform != null) + { + //カメラ移動フィルタ + if (CameraPositionFilterEnable) + { + cameraPosFilter = (cameraPosFilter * CameraFilter) + cameraPos * (1.0f - CameraFilter); + VMCControlledCamera.transform.localPosition = cameraPosFilter; + } + else + { + VMCControlledCamera.transform.localPosition = cameraPos; + } + //カメラ回転フィルタ + if (CameraRotationFilterEnable) + { + cameraRotFilter = Quaternion.Slerp(cameraRotFilter, cameraRot, 1.0f - CameraFilter); + VMCControlledCamera.transform.localRotation = cameraRotFilter; + } + else + { + VMCControlledCamera.transform.localRotation = cameraRot; + } + //FOV同期 + VMCControlledCamera.fieldOfView = fov; + } + } + public void MessageDaisyChain(ref uOSC.Message message, int callCount) { //Startされていない場合無視 @@ -111,41 +146,15 @@ private void ProcessMessage(ref uOSC.Message message) && (message.values[8] is float) ) { - //カメラがセットされているならば - if (VMCControlledCamera != null && VMCControlledCamera.transform != null) - { - pos.x = (float)message.values[1]; - pos.y = (float)message.values[2]; - pos.z = (float)message.values[3]; - rot.x = (float)message.values[4]; - rot.y = (float)message.values[5]; - rot.z = (float)message.values[6]; - rot.w = (float)message.values[7]; - float fov = (float)message.values[8]; - - //カメラ移動フィルタ - if (CameraPositionFilterEnable) - { - cameraPosFilter = (cameraPosFilter * CameraFilter) + pos * (1.0f - CameraFilter); - VMCControlledCamera.transform.localPosition = cameraPosFilter; - } - else - { - VMCControlledCamera.transform.localPosition = pos; - } - //カメラ回転フィルタ - if (CameraRotationFilterEnable) - { - cameraRotFilter = Quaternion.Slerp(cameraRotFilter, rot, 1.0f - CameraFilter); - VMCControlledCamera.transform.localRotation = cameraRotFilter; - } - else - { - VMCControlledCamera.transform.localRotation = rot; - } - //FOV同期 - VMCControlledCamera.fieldOfView = fov; - } + cameraPos.x = (float)message.values[1]; + cameraPos.y = (float)message.values[2]; + cameraPos.z = (float)message.values[3]; + cameraRot.x = (float)message.values[4]; + cameraRot.y = (float)message.values[5]; + cameraRot.z = (float)message.values[6]; + cameraRot.w = (float)message.values[7]; + fov = (float)message.values[8]; + //受信と更新のタイミングは切り離した } } } diff --git a/EVMC4U/ExternalReceiver.cs b/EVMC4U/ExternalReceiver.cs index ef0fd55..65f3a94 100644 --- a/EVMC4U/ExternalReceiver.cs +++ b/EVMC4U/ExternalReceiver.cs @@ -97,6 +97,10 @@ public class ExternalReceiver : MonoBehaviour, IExternalReceiver //ボーンENUM情報テーブル Dictionary HumanBodyBonesTable = new Dictionary(); + //ボーン情報テーブル + Dictionary HumanBodyBonesPositionTable = new Dictionary(); + Dictionary HumanBodyBonesRotationTable = new Dictionary(); + //uOSCサーバー uOSC.uOscServer server = null; @@ -175,6 +179,18 @@ void Update() StatusMessage = "Model not found."; return; } + + //モデルが更新されたときに関連情報を更新する + if (OldModel != Model && Model != null) + { + animator = Model.GetComponent(); + blendShapeProxy = Model.GetComponent(); + OldModel = Model; + Debug.Log("[ExternalReceiver] New model detected"); + } + + BoneSynchronizeByTable(); + } //データ受信イベント @@ -313,7 +329,8 @@ private void ProcessMessage(ref uOSC.Message message) Model.transform.localScale = scale; //位置同期が有効な場合のみオフセットを反映する - if (RootPositionSynchronize) { + if (RootPositionSynchronize) + { RootPositionTransform.position -= offset; } } @@ -330,6 +347,7 @@ private void ProcessMessage(ref uOSC.Message message) && (message.values[7] is float) ) { + string boneName = (string)message.values[0]; pos.x = (float)message.values[1]; pos.y = (float)message.values[2]; pos.z = (float)message.values[3]; @@ -338,9 +356,31 @@ private void ProcessMessage(ref uOSC.Message message) rot.z = (float)message.values[6]; rot.w = (float)message.values[7]; - BoneSynchronize((string)message.values[0], ref pos, ref rot); - } + //Humanoidボーンに該当するボーンがあるか調べる + HumanBodyBones bone; + if (HumanBodyBonesTryParse(ref boneName, out bone)) + { + //あれば位置と回転をキャッシュする + if (HumanBodyBonesPositionTable.ContainsKey(bone)) + { + HumanBodyBonesPositionTable[bone] = pos; + } + else + { + HumanBodyBonesPositionTable.Add(bone, pos); + } + if (HumanBodyBonesRotationTable.ContainsKey(bone)) + { + HumanBodyBonesRotationTable[bone] = rot; + } + else + { + HumanBodyBonesRotationTable.Add(bone, rot); + } + } + //受信と更新のタイミングは切り離した + } //ブレンドシェープ同期 else if (message.address == "/VMC/Ext/Blend/Val" && (message.values[0] is string) @@ -362,86 +402,86 @@ private void ProcessMessage(ref uOSC.Message message) } } - //ボーン位置同期 - private void BoneSynchronize(string boneName, ref Vector3 pos, ref Quaternion rot) + //ボーン位置をキャッシュテーブルに基づいて更新 + private void BoneSynchronizeByTable() { - //モデルが更新されたときに関連情報を更新する - if (OldModel != Model && Model != null) + //キャッシュテーブルを参照 + foreach (var bone in HumanBodyBonesTable) { - animator = Model.GetComponent(); - blendShapeProxy = Model.GetComponent(); - OldModel = Model; - Debug.Log("[ExternalReceiver] New model detected"); + //キャッシュされた位置・回転を適用 + if (HumanBodyBonesPositionTable.ContainsKey(bone.Value) && HumanBodyBonesRotationTable.ContainsKey(bone.Value)) + { + BoneSynchronize(bone.Value, HumanBodyBonesPositionTable[bone.Value], HumanBodyBonesRotationTable[bone.Value]); + } } + } - //Humanoidボーンに該当するボーンがあるか調べる - HumanBodyBones bone; - if (HumanBodyBonesTryParse(ref boneName, out bone)) + //ボーン位置同期 + private void BoneSynchronize(HumanBodyBones bone, Vector3 pos, Quaternion rot) + { + //操作可能な状態かチェック + if (animator != null && bone != HumanBodyBones.LastBone) { - //操作可能な状態かチェック - if (animator != null && bone != HumanBodyBones.LastBone) + //ボーンによって操作を分ける + var t = animator.GetBoneTransform(bone); + if (t != null) { - //ボーンによって操作を分ける - var t = animator.GetBoneTransform(bone); - if (t != null) + //指ボーン + if (bone == HumanBodyBones.LeftIndexDistal || + bone == HumanBodyBones.LeftIndexIntermediate || + bone == HumanBodyBones.LeftIndexProximal || + bone == HumanBodyBones.LeftLittleDistal || + bone == HumanBodyBones.LeftLittleIntermediate || + bone == HumanBodyBones.LeftLittleProximal || + bone == HumanBodyBones.LeftMiddleDistal || + bone == HumanBodyBones.LeftMiddleIntermediate || + bone == HumanBodyBones.LeftMiddleProximal || + bone == HumanBodyBones.LeftRingDistal || + bone == HumanBodyBones.LeftRingIntermediate || + bone == HumanBodyBones.LeftRingProximal || + bone == HumanBodyBones.LeftThumbDistal || + bone == HumanBodyBones.LeftThumbIntermediate || + bone == HumanBodyBones.LeftThumbProximal || + + bone == HumanBodyBones.RightIndexDistal || + bone == HumanBodyBones.RightIndexIntermediate || + bone == HumanBodyBones.RightIndexProximal || + bone == HumanBodyBones.RightLittleDistal || + bone == HumanBodyBones.RightLittleIntermediate || + bone == HumanBodyBones.RightLittleProximal || + bone == HumanBodyBones.RightMiddleDistal || + bone == HumanBodyBones.RightMiddleIntermediate || + bone == HumanBodyBones.RightMiddleProximal || + bone == HumanBodyBones.RightRingDistal || + bone == HumanBodyBones.RightRingIntermediate || + bone == HumanBodyBones.RightRingProximal || + bone == HumanBodyBones.RightThumbDistal || + bone == HumanBodyBones.RightThumbIntermediate || + bone == HumanBodyBones.RightThumbProximal) { - //指ボーン - if (bone == HumanBodyBones.LeftIndexDistal || - bone == HumanBodyBones.LeftIndexIntermediate || - bone == HumanBodyBones.LeftIndexProximal || - bone == HumanBodyBones.LeftLittleDistal || - bone == HumanBodyBones.LeftLittleIntermediate || - bone == HumanBodyBones.LeftLittleProximal || - bone == HumanBodyBones.LeftMiddleDistal || - bone == HumanBodyBones.LeftMiddleIntermediate || - bone == HumanBodyBones.LeftMiddleProximal || - bone == HumanBodyBones.LeftRingDistal || - bone == HumanBodyBones.LeftRingIntermediate || - bone == HumanBodyBones.LeftRingProximal || - bone == HumanBodyBones.LeftThumbDistal || - bone == HumanBodyBones.LeftThumbIntermediate || - bone == HumanBodyBones.LeftThumbProximal || - - bone == HumanBodyBones.RightIndexDistal || - bone == HumanBodyBones.RightIndexIntermediate || - bone == HumanBodyBones.RightIndexProximal || - bone == HumanBodyBones.RightLittleDistal || - bone == HumanBodyBones.RightLittleIntermediate || - bone == HumanBodyBones.RightLittleProximal || - bone == HumanBodyBones.RightMiddleDistal || - bone == HumanBodyBones.RightMiddleIntermediate || - bone == HumanBodyBones.RightMiddleProximal || - bone == HumanBodyBones.RightRingDistal || - bone == HumanBodyBones.RightRingIntermediate || - bone == HumanBodyBones.RightRingProximal || - bone == HumanBodyBones.RightThumbDistal || - bone == HumanBodyBones.RightThumbIntermediate || - bone == HumanBodyBones.RightThumbProximal) - { - //指ボーンカットオフが有効でなければ - if (!HandPoseSynchronizeCutoff) - { - //ボーン同期する。ただしフィルタはかけない - BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, false, false); - } - } - //目ボーン - else if (bone == HumanBodyBones.LeftEye || - bone == HumanBodyBones.RightEye) + //指ボーンカットオフが有効でなければ + if (!HandPoseSynchronizeCutoff) { - //目ボーンカットオフが有効でなければ - if (!EyeBoneSynchronizeCutoff) - { - //ボーン同期する。ただしフィルタはかけない - BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, false, false); - } + //ボーン同期する。ただしフィルタはかけない + BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, false, false); } - else + } + //目ボーン + else if (bone == HumanBodyBones.LeftEye || + bone == HumanBodyBones.RightEye) + { + //目ボーンカットオフが有効でなければ + if (!EyeBoneSynchronizeCutoff) { - //ボーン同期する。フィルタは設定依存 - BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, BonePositionFilterEnable, BoneRotationFilterEnable); + //ボーン同期する。ただしフィルタはかけない + BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, false, false); } } + else + { + //ボーン同期する。フィルタは設定依存 + BoneSynchronizeSingle(t, ref bone, ref pos, ref rot, BonePositionFilterEnable, BoneRotationFilterEnable); + } } } } From f58e0a4d520c7c31acef89d2fde12de317077055 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 20:13:01 +0900 Subject: [PATCH 13/22] =?UTF-8?q?=E5=85=A5=E5=8A=9B=E8=BE=9E=E6=9B=B8?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0(=E3=82=B3=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=AF=E7=84=A1=E3=81=97=E3=81=A7=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E3=81=AE=E5=85=A5=E5=8A=9B=E7=8A=B6=E6=85=8B=E3=82=92?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E5=A4=89=E6=95=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/InputReceiver.cs | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/EVMC4U/InputReceiver.cs b/EVMC4U/InputReceiver.cs index 12a7f69..3daf97b 100644 --- a/EVMC4U/InputReceiver.cs +++ b/EVMC4U/InputReceiver.cs @@ -55,6 +55,13 @@ public class InputReceiver : MonoBehaviour, IExternalReceiver [Header("Daisy Chain")] public GameObject[] NextReceivers = new GameObject[1]; + //--- + + //入力辞書(コールバックではなく定値で取得したい場合に使う) + public Dictionary InputDictionary = new Dictionary(); + + //--- + private ExternalReceiverManager externalReceiverManager = null; bool shutdown = false; @@ -133,12 +140,17 @@ private void ProcessMessage(ref uOSC.Message message) { ControllerInputAction.Invoke(con); } - - if (con.IsLeft==1) { - LastInput = "Left: " + con.name + "=" + con.active; - } - else { - LastInput = "Right: " + con.name + "=" + con.active; + if (con.IsAxis == 0) { + if (con.IsLeft == 1) + { + LastInput = "Left-" + con.name + " = " + con.active; + InputDictionary["Left-" + con.name] = (con.active != 0); + } + else + { + LastInput = "Right-" + con.name + " = " + con.active; + InputDictionary["Right-" + con.name] = (con.active != 0); + } } } //キーボード操作情報 v2.1 @@ -158,7 +170,7 @@ private void ProcessMessage(ref uOSC.Message message) KeyInputAction.Invoke(key); } - LastInput = "Key " + key.name + "("+key.keycode+")="+key.active; + LastInput = "Key-" + key.name +" = "+key.active + " (" + key.keycode + ")"; } // v2.2 else if (message.address == "/VMC/Ext/Midi/Note" @@ -179,7 +191,8 @@ private void ProcessMessage(ref uOSC.Message message) MidiNoteInputAction.Invoke(note); } - LastInput = "Note " + note.active + "/" + note.channel + "/" + note.note + "/" + note.velocity; + LastInput = "Note-" + note.note + " = "+note.active + "/" + note.channel + "/" + note.velocity; + InputDictionary["Note-" + note.note] = (note.active != 0); } // v2.2 else if (message.address == "/VMC/Ext/Midi/CC/Val" @@ -196,7 +209,7 @@ private void ProcessMessage(ref uOSC.Message message) MidiCCValueInputAction.Invoke(ccvalue); } - LastInput = "CC Val " + ccvalue.knob + "/" + ccvalue.value; + LastInput = "CC Val " + ccvalue.knob + " = " + ccvalue.value; if (ccvalue.knob >= 0 && ccvalue.knob < 128) { CCValuesMonitor[ccvalue.knob] = ccvalue.value; @@ -216,8 +229,15 @@ private void ProcessMessage(ref uOSC.Message message) { MidiCCButtonInputAction.Invoke(ccbutton); } - LastInput = "CC Bit " + ccbutton.knob + "/" + ccbutton.active; + LastInput = "CC-" + ccbutton.knob + " = " + ccbutton.active; + InputDictionary["CC-" + ccbutton.knob] = (ccbutton.active != 0); + } + } + void Update() { + foreach (var x in InputDictionary) { + Debug.Log(x.Key + " : " + x.Value); } } + } } \ No newline at end of file From 80268e97a593b3e41de64ff8e934179980f52454 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 20:33:30 +0900 Subject: [PATCH 14/22] =?UTF-8?q?UpdateDaisyChain=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0(=E7=B7=A8=E9=9B=86=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E3=83=87=E3=82=A4=E3=82=B8=E3=83=BC=E3=83=81=E3=82=A7=E3=83=BC?= =?UTF-8?q?=E3=83=B3=E3=83=AA=E3=82=B9=E3=83=88=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/CameraReceiver.cs | 6 ++++++ EVMC4U/CommunicationValidator.cs | 6 ++++++ EVMC4U/DeviceReceiver.cs | 6 ++++++ EVMC4U/ExternalReceiver.cs | 6 ++++++ EVMC4U/InputReceiver.cs | 6 ++++++ EVMC4U/Test/DaisyChainTesting.cs | 9 ++++++++- EVMC4U/class/IExternalReceiver.cs | 1 + 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/EVMC4U/CameraReceiver.cs b/EVMC4U/CameraReceiver.cs index 7822544..a96ed62 100644 --- a/EVMC4U/CameraReceiver.cs +++ b/EVMC4U/CameraReceiver.cs @@ -70,6 +70,12 @@ void Start() StatusMessage = "Waiting for Master..."; } + //デイジーチェーンを更新 + public void UpdateDaisyChain() + { + externalReceiverManager.GetIExternalReceiver(NextReceivers); + } + void Update() { //カメラがセットされているならば diff --git a/EVMC4U/CommunicationValidator.cs b/EVMC4U/CommunicationValidator.cs index 648e927..7b664bf 100644 --- a/EVMC4U/CommunicationValidator.cs +++ b/EVMC4U/CommunicationValidator.cs @@ -67,6 +67,12 @@ void Start() StatusMessage = "Waiting for Master..."; } + //デイジーチェーンを更新 + public void UpdateDaisyChain() + { + externalReceiverManager.GetIExternalReceiver(NextReceivers); + } + int GetAvailable() { return Available; diff --git a/EVMC4U/DeviceReceiver.cs b/EVMC4U/DeviceReceiver.cs index c739e53..7252bc1 100644 --- a/EVMC4U/DeviceReceiver.cs +++ b/EVMC4U/DeviceReceiver.cs @@ -88,6 +88,12 @@ void Start() } } + //デイジーチェーンを更新 + public void UpdateDaisyChain() + { + externalReceiverManager.GetIExternalReceiver(NextReceivers); + } + public void MessageDaisyChain(ref uOSC.Message message, int callCount) { //Startされていない場合無視 diff --git a/EVMC4U/ExternalReceiver.cs b/EVMC4U/ExternalReceiver.cs index 65f3a94..9be96c2 100644 --- a/EVMC4U/ExternalReceiver.cs +++ b/EVMC4U/ExternalReceiver.cs @@ -133,6 +133,12 @@ void Start() } } + //デイジーチェーンを更新 + public void UpdateDaisyChain() + { + externalReceiverManager.GetIExternalReceiver(NextReceivers); + } + //外部から通信状態を取得するための公開関数 int GetAvailable() { diff --git a/EVMC4U/InputReceiver.cs b/EVMC4U/InputReceiver.cs index 3daf97b..1642c0c 100644 --- a/EVMC4U/InputReceiver.cs +++ b/EVMC4U/InputReceiver.cs @@ -81,6 +81,12 @@ void Start() CCValuesMonitor = new float[128]; } + //デイジーチェーンを更新 + public void UpdateDaisyChain() + { + externalReceiverManager.GetIExternalReceiver(NextReceivers); + } + public void MessageDaisyChain(ref uOSC.Message message, int callCount) { //Startされていない場合無視 diff --git a/EVMC4U/Test/DaisyChainTesting.cs b/EVMC4U/Test/DaisyChainTesting.cs index c26810c..3ce9e75 100644 --- a/EVMC4U/Test/DaisyChainTesting.cs +++ b/EVMC4U/Test/DaisyChainTesting.cs @@ -24,6 +24,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -31,7 +32,7 @@ namespace EVMC4U { - public class DaisyChainTesting : MonoBehaviour, EVMC4U.IExternalReceiver + public class DaisyChainTesting : MonoBehaviour, IExternalReceiver { //デイジーチェーンテスト public void MessageDaisyChain(ref Message message, int callCount) @@ -43,6 +44,12 @@ public void MessageDaisyChain(ref Message message, int callCount) //メッセージ全部Logに出そうとか考えないこと。Unityが死ぬほど送られてきます。 } + + public void UpdateDaisyChain() + { + throw new NotImplementedException(); + } + } } diff --git a/EVMC4U/class/IExternalReceiver.cs b/EVMC4U/class/IExternalReceiver.cs index 25c2e1a..15255be 100644 --- a/EVMC4U/class/IExternalReceiver.cs +++ b/EVMC4U/class/IExternalReceiver.cs @@ -35,5 +35,6 @@ namespace EVMC4U { public interface IExternalReceiver { void MessageDaisyChain(ref uOSC.Message message, int callCount); + void UpdateDaisyChain(); } } From 6b4ebee219ecdbc2096bad855932190b0b25d2b5 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 22:18:12 +0900 Subject: [PATCH 15/22] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/InputReceiver.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/EVMC4U/InputReceiver.cs b/EVMC4U/InputReceiver.cs index 1642c0c..370cef3 100644 --- a/EVMC4U/InputReceiver.cs +++ b/EVMC4U/InputReceiver.cs @@ -239,11 +239,5 @@ private void ProcessMessage(ref uOSC.Message message) InputDictionary["CC-" + ccbutton.knob] = (ccbutton.active != 0); } } - void Update() { - foreach (var x in InputDictionary) { - Debug.Log(x.Key + " : " + x.Value); - } - } - } } \ No newline at end of file From e47b2c76df54cbb12badcdc0e16d1bfac8d2d350 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 22:56:38 +0900 Subject: [PATCH 16/22] =?UTF-8?q?=E6=8C=81=E3=81=A3=E3=81=A6=E3=82=8B?= =?UTF-8?q?=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AB?= =?UTF-8?q?=E3=82=B7=E3=82=B0=E3=83=8A=E3=83=AB=E9=80=81=E3=82=8B=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=81=E3=82=B7=E3=82=B0?= =?UTF-8?q?=E3=83=8A=E3=83=AB=E5=8F=97=E4=BF=A1=E3=81=A8=E3=81=97=E3=81=A6?= =?UTF-8?q?=E6=AD=A6=E5=99=A8=E8=A3=85=E5=82=99=E3=82=B5=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/SampleScripts/HandCatch/HandCatch.cs | 28 ++++++- .../HandCatch/HandCatch_WeaponHelper.cs | 77 +++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs diff --git a/EVMC4U/SampleScripts/HandCatch/HandCatch.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch.cs index 9c8f79f..a533185 100644 --- a/EVMC4U/SampleScripts/HandCatch/HandCatch.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch.cs @@ -30,7 +30,7 @@ namespace EVMC4U { - [RequireComponent(typeof(EVMC4U.ExternalReceiver))] + [RequireComponent(typeof(ExternalReceiver))] public class HandCatch : MonoBehaviour { //表示オンオフ @@ -51,6 +51,8 @@ public class HandCatch : MonoBehaviour public string RightKey = "X"; public string ControllerButton = "ClickTrigger"; + public bool signaling = true; + public bool StickyMode = false; bool stickyLeft = false; @@ -212,6 +214,12 @@ void CatchLeft(bool s) //フィルタ強く exrcv.BoneFilter = InHoldFilter; + + //オブジェクトにメッセージを送る + if (signaling) + { + leftCatchedObject.SendMessage("OnCatchedLeftHand"); + } } } else @@ -234,6 +242,12 @@ void CatchLeft(bool s) //フィルタ解除 exrcv.BoneFilter = NonHoldFilter; + + //オブジェクトにメッセージを送る + if (signaling) + { + leftCatchedObject.SendMessage("OnReleasedLeftHand"); + } } } } @@ -281,6 +295,12 @@ void CatchRight(bool s) //フィルタ強く exrcv.BoneFilter = InHoldFilter; + + //オブジェクトにメッセージを送る + if (signaling) + { + rightCatchedObject.SendMessage("OnCatchedRightHand"); + } } } else @@ -304,6 +324,12 @@ void CatchRight(bool s) //フィルタ解除 exrcv.BoneFilter = NonHoldFilter; + + //オブジェクトにメッセージを送る + if (signaling) + { + rightCatchedObject.SendMessage("OnReleasedRightHand"); + } } } } diff --git a/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs new file mode 100644 index 0000000..3ecb622 --- /dev/null +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs @@ -0,0 +1,77 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +//掴まれたとき: 手の位置に持つ +//離されたとき: 鞘の位置なら、収まるべき場所に戻る +// そうでないなら、親なしにしてとどまる + +public class HandCatch_WeaponHelper : MonoBehaviour +{ + public Transform LeftHoldPosition; //左手保持位置 + public Transform RightHoldPosition; //右手保持位置 + + //初期位置(鞘に収まっている状態) + Vector3 CasePosition; + Quaternion CaseRotation; + + void Start() + { + CasePosition = transform.localPosition; + CaseRotation = transform.localRotation; + } + + void OnCatchedLeftHand() + { + Debug.Log("C:L"); + transform.localPosition = LeftHoldPosition.localPosition; + transform.localRotation = LeftHoldPosition.localRotation; + } + void OnCatchedRightHand() + { + Debug.Log("C:R"); + transform.localPosition = RightHoldPosition.localPosition; + transform.localRotation = RightHoldPosition.localRotation; + } + + void OnReleasedLeftHand() + { + Debug.Log("R:L"); + transform.localPosition = CasePosition; + transform.localRotation = CaseRotation; + } + + void OnReleasedRightHand() + { + Debug.Log("R:R"); + transform.localPosition = CasePosition; + transform.localRotation = CaseRotation; + } + +} From b6068cb9a4813350c70152ff945b295031cdd61a Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 23:10:38 +0900 Subject: [PATCH 17/22] =?UTF-8?q?=E5=90=8D=E5=89=8D=E7=A9=BA=E9=96=93?= =?UTF-8?q?=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HandCatch/HandCatch_Helper.cs | 1 - .../HandCatch/HandCatch_WeaponHelper.cs | 75 ++++++++++--------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs index 930329c..c7330ca 100644 --- a/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch_Helper.cs @@ -30,7 +30,6 @@ namespace EVMC4U { - public class HandCatch_Helper : MonoBehaviour { public bool Trigger = false; diff --git a/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs index 3ecb622..df15644 100644 --- a/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs @@ -31,47 +31,48 @@ //掴まれたとき: 手の位置に持つ //離されたとき: 鞘の位置なら、収まるべき場所に戻る // そうでないなら、親なしにしてとどまる - -public class HandCatch_WeaponHelper : MonoBehaviour +namespace EVMC4U { - public Transform LeftHoldPosition; //左手保持位置 - public Transform RightHoldPosition; //右手保持位置 + public class HandCatch_WeaponHelper : MonoBehaviour + { + public Transform LeftHoldPosition; //左手保持位置 + public Transform RightHoldPosition; //右手保持位置 - //初期位置(鞘に収まっている状態) - Vector3 CasePosition; - Quaternion CaseRotation; + //初期位置(鞘に収まっている状態) + Vector3 CasePosition; + Quaternion CaseRotation; - void Start() - { - CasePosition = transform.localPosition; - CaseRotation = transform.localRotation; - } + void Start() + { + CasePosition = transform.localPosition; + CaseRotation = transform.localRotation; + } - void OnCatchedLeftHand() - { - Debug.Log("C:L"); - transform.localPosition = LeftHoldPosition.localPosition; - transform.localRotation = LeftHoldPosition.localRotation; - } - void OnCatchedRightHand() - { - Debug.Log("C:R"); - transform.localPosition = RightHoldPosition.localPosition; - transform.localRotation = RightHoldPosition.localRotation; - } + void OnCatchedLeftHand() + { + Debug.Log("C:L"); + transform.localPosition = LeftHoldPosition.localPosition; + transform.localRotation = LeftHoldPosition.localRotation; + } + void OnCatchedRightHand() + { + Debug.Log("C:R"); + transform.localPosition = RightHoldPosition.localPosition; + transform.localRotation = RightHoldPosition.localRotation; + } - void OnReleasedLeftHand() - { - Debug.Log("R:L"); - transform.localPosition = CasePosition; - transform.localRotation = CaseRotation; - } + void OnReleasedLeftHand() + { + Debug.Log("R:L"); + transform.localPosition = CasePosition; + transform.localRotation = CaseRotation; + } - void OnReleasedRightHand() - { - Debug.Log("R:R"); - transform.localPosition = CasePosition; - transform.localRotation = CaseRotation; + void OnReleasedRightHand() + { + Debug.Log("R:R"); + transform.localPosition = CasePosition; + transform.localRotation = CaseRotation; + } } - -} +} \ No newline at end of file From e59932cb300d644fa981ab5673be00059a133b0b Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Mon, 4 Nov 2019 23:43:33 +0900 Subject: [PATCH 18/22] =?UTF-8?q?=E8=B6=B3=E5=9F=BA=E6=BA=96=E3=83=86?= =?UTF-8?q?=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88=E6=A9=9F=E8=83=BD=E3=82=B5?= =?UTF-8?q?=E3=83=B3=E3=83=97=E3=83=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TeleportKit/TeleportManager.cs | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 EVMC4U/SampleScripts/TeleportKit/TeleportManager.cs diff --git a/EVMC4U/SampleScripts/TeleportKit/TeleportManager.cs b/EVMC4U/SampleScripts/TeleportKit/TeleportManager.cs new file mode 100644 index 0000000..a5d8399 --- /dev/null +++ b/EVMC4U/SampleScripts/TeleportKit/TeleportManager.cs @@ -0,0 +1,73 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace EVMC4U +{ + public class TeleportManager : MonoBehaviour + { + public InputReceiver inputReceiver; + public GameObject ParentObject; + public Animator model; + + public string[] TriggerKey = new string[5]; + public Transform[] TeleportTarget = new Transform[5]; + + private Transform footpos; + + void Start() + { + inputReceiver.KeyInputAction.AddListener(OnKey); + + footpos = model.GetBoneTransform(HumanBodyBones.LeftFoot); + } + + void OnKey(KeyInput key) + { + //押されたときのみ + if (key.active != 1) { + return; + } + //該当するキーを探す + for (int i = 0; i < TriggerKey.Length; i++) { + if (TriggerKey[i] == key.name) { + Debug.Log("Key:" + key.name); + //発見したらターゲット有効性をチェックする + if (TeleportTarget.Length > i) { + if (TeleportTarget[i] != null) { + //モデルに反映 + ParentObject.transform.position -= (footpos.position - TeleportTarget[i].position); + ParentObject.transform.rotation = TeleportTarget[i].rotation; + } + } + } + } + } + } +} \ No newline at end of file From 4b17aae74cbfbd8bd26d95e1441049423b1dbbae Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Tue, 5 Nov 2019 22:53:35 +0900 Subject: [PATCH 19/22] =?UTF-8?q?Freeze=E3=81=A7Update=E3=82=82=E6=AD=A2?= =?UTF-8?q?=E3=81=BE=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/ExternalReceiver.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EVMC4U/ExternalReceiver.cs b/EVMC4U/ExternalReceiver.cs index 9be96c2..3100d8a 100644 --- a/EVMC4U/ExternalReceiver.cs +++ b/EVMC4U/ExternalReceiver.cs @@ -156,6 +156,9 @@ void Update() //エラー・無限ループ時は処理をしない if (shutdown) { return; } + //Freeze有効時は動きを一切止める + if (Freeze) { return; } + //5.6.3p1などRunInBackgroundが既定で無効な場合Unityが極めて重くなるため対処 Application.runInBackground = true; From 53e87a1c6b2c771a32e656e6d0b9bedb8e60dc77 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Tue, 5 Nov 2019 23:13:31 +0900 Subject: [PATCH 20/22] =?UTF-8?q?FreezeSwitch=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreezeSwitch/FreezeSwitch.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 EVMC4U/SampleScripts/FreezeSwitch/FreezeSwitch.cs diff --git a/EVMC4U/SampleScripts/FreezeSwitch/FreezeSwitch.cs b/EVMC4U/SampleScripts/FreezeSwitch/FreezeSwitch.cs new file mode 100644 index 0000000..28b5de1 --- /dev/null +++ b/EVMC4U/SampleScripts/FreezeSwitch/FreezeSwitch.cs @@ -0,0 +1,64 @@ +/* + * ExternalReceiver + * https://sabowl.sakura.ne.jp/gpsnmeajp/ + * + * MIT License + * + * Copyright (c) 2019 gpsnmeajp + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace EVMC4U +{ + public class FreezeSwitch : MonoBehaviour + { + public ExternalReceiver externalReceiver; + public InputReceiver inputReceiver; + + public string Key= "スペース"; + public string Button= "ClickMenu"; + void Start() + { + inputReceiver.KeyInputAction.AddListener(OnKey); + inputReceiver.ControllerInputAction.AddListener(OnCon); + } + void OnKey(KeyInput key) + { + if (key.name == Key) { + if (key.active == 1) { + externalReceiver.Freeze = !externalReceiver.Freeze; + } + } + } + void OnCon(ControllerInput con) + { + if (con.name == Button) + { + if (con.active == 1) + { + externalReceiver.Freeze = !externalReceiver.Freeze; + } + } + } + } +} \ No newline at end of file From 49d74b9a5c1d9879439acf9ea847b9fe2c55e7cd Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Wed, 6 Nov 2019 20:25:40 +0900 Subject: [PATCH 21/22] =?UTF-8?q?=E6=AD=A6=E5=99=A8=E3=82=92=E3=82=B9?= =?UTF-8?q?=E3=83=A0=E3=83=BC=E3=82=BA=E3=81=AB=E6=8C=81=E3=81=A6=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=80=81=E5=85=83=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AE=E8=B7=9D=E9=9B=A2=E3=81=A7=E6=A0=BC?= =?UTF-8?q?=E7=B4=8D=E5=8F=AF=E5=90=A6=E3=82=92=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HandCatch/HandCatch_WeaponHelper.cs | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs index df15644..1b37447 100644 --- a/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs +++ b/EVMC4U/SampleScripts/HandCatch/HandCatch_WeaponHelper.cs @@ -35,44 +35,76 @@ namespace EVMC4U { public class HandCatch_WeaponHelper : MonoBehaviour { + public Transform CaseParent; //鞘オブジェクト public Transform LeftHoldPosition; //左手保持位置 public Transform RightHoldPosition; //右手保持位置 + //鞘に戻らない限界距離 + public float Threshold = 0.5f; + + //どれだけふわっと動くか + public float Filter = 0.8f; + //初期位置(鞘に収まっている状態) Vector3 CasePosition; Quaternion CaseRotation; + //初期位置(鞘に収まっている状態) + Vector3 TragetPosition; + Quaternion TargetRotation; + void Start() { CasePosition = transform.localPosition; CaseRotation = transform.localRotation; + + TragetPosition = CasePosition; + TargetRotation = CaseRotation; + } + + void Update() + { + if (transform.parent != null) { + transform.localPosition = Vector3.Lerp(TragetPosition, transform.localPosition, Filter); + transform.localRotation = Quaternion.Lerp(TargetRotation, transform.localRotation, Filter); + } } void OnCatchedLeftHand() { Debug.Log("C:L"); - transform.localPosition = LeftHoldPosition.localPosition; - transform.localRotation = LeftHoldPosition.localRotation; + TragetPosition = LeftHoldPosition.localPosition; + TargetRotation = LeftHoldPosition.localRotation; } void OnCatchedRightHand() { Debug.Log("C:R"); - transform.localPosition = RightHoldPosition.localPosition; - transform.localRotation = RightHoldPosition.localRotation; + TragetPosition = RightHoldPosition.localPosition; + TargetRotation = RightHoldPosition.localRotation; } void OnReleasedLeftHand() { Debug.Log("R:L"); - transform.localPosition = CasePosition; - transform.localRotation = CaseRotation; + OnReleasedRightHand();//同じ処理 } void OnReleasedRightHand() { Debug.Log("R:R"); - transform.localPosition = CasePosition; - transform.localRotation = CaseRotation; + + //計算用に一時的に親にする + transform.parent = CaseParent; + float distance = Vector3.Distance(CasePosition, transform.localPosition); + if (distance < Threshold) + { + transform.parent = CaseParent; + TragetPosition = CasePosition; + TargetRotation = CaseRotation; + } + else { + transform.parent = null; + } } } } \ No newline at end of file From e0c04a5591cbc23466bc56d9a9a61733a325cfb9 Mon Sep 17 00:00:00 2001 From: gpsnmeajp <33391403+gpsnmeajp@users.noreply.github.com> Date: Wed, 6 Nov 2019 21:10:53 +0900 Subject: [PATCH 22/22] =?UTF-8?q?=E5=8F=97=E4=BF=A1=E5=89=8D=E3=81=AB?= =?UTF-8?q?=E3=82=AB=E3=83=A1=E3=83=A9=E3=81=8C=E3=83=90=E3=82=B0=E3=82=8B?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EVMC4U/CameraReceiver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EVMC4U/CameraReceiver.cs b/EVMC4U/CameraReceiver.cs index a96ed62..35fa441 100644 --- a/EVMC4U/CameraReceiver.cs +++ b/EVMC4U/CameraReceiver.cs @@ -79,7 +79,7 @@ public void UpdateDaisyChain() void Update() { //カメラがセットされているならば - if (VMCControlledCamera != null && VMCControlledCamera.transform != null) + if (VMCControlledCamera != null && VMCControlledCamera.transform != null && fov != 0) { //カメラ移動フィルタ if (CameraPositionFilterEnable)