diff --git a/README.md b/README.md index 6950548..fc6c747 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Merged set of MelonLoader mods for ChilloutVR. | Desktop Head Tracking | ml_dht | 1.0.3 | On review | Working | | Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working | | Four Point Tracking | ml_fpt | 1.0.7 | On review | Working | -| Leap Motion Extension | ml_lme | 1.1.9 | On review | Working | +| Leap Motion Extension | ml_lme | 1.2.0 | On review | Working | | Server Connection Info | ml_sci | 1.0.1 | Yes | Working | diff --git a/ml_lme/GestureMatcher.cs b/ml_lme/GestureMatcher.cs index 3777ff7..4f4c872 100644 --- a/ml_lme/GestureMatcher.cs +++ b/ml_lme/GestureMatcher.cs @@ -82,9 +82,10 @@ namespace ml_lme static void FillHandPosition(Leap.Hand p_hand, ref Vector3 p_pos) { - p_pos.x = p_hand.PalmPosition.x; - p_pos.y = p_hand.PalmPosition.y; - p_pos.z = p_hand.PalmPosition.z; + // Unity's IK and FinalIK move hand bones to target, therefore - wrist + p_pos.x = p_hand.WristPosition.x; + p_pos.y = p_hand.WristPosition.y; + p_pos.z = p_hand.WristPosition.z; } static void FillHandRotation(Leap.Hand p_hand, ref Quaternion p_rot) @@ -127,7 +128,6 @@ namespace ml_lme static void FilFingerSpreads(Leap.Hand p_hand, ref float[] p_spreads) { - foreach(Leap.Finger l_finger in p_hand.Fingers) { float l_angle = 0f; diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index c1f5205..82aaf78 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -180,36 +180,18 @@ namespace ml_lme if((m_vrIK != null) && PlayerSetup.Instance._animator.isHuman) { // Here we fokin' go! - m_leftHand.position = Vector3.zero; - m_leftHand.rotation = Quaternion.identity; - Transform l_lowerArm = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftLowerArm); Transform l_hand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); - if((l_lowerArm != null) && (l_hand != null)) + if(l_hand != null) { - m_leftHandTarget.SetParent(l_lowerArm); - m_leftHandTarget.localPosition = l_hand.localPosition; - m_leftHandTarget.localRotation = l_hand.localRotation; - m_leftHandTarget.SetParent(m_leftHand, true); m_leftHandTarget.localPosition = Vector3.zero; - - Quaternion l_rot = m_leftHandTarget.localRotation; - m_leftHandTarget.localRotation = ms_offsetLeft * l_rot; + m_leftHandTarget.localRotation = ms_offsetLeft * (PlayerSetup.Instance._avatar.transform.GetMatrix().inverse * l_hand.GetMatrix()).rotation; } - m_rightHand.position = Vector3.zero; - m_rightHand.rotation = Quaternion.identity; - l_lowerArm = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.RightLowerArm); l_hand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.RightHand); - if((l_lowerArm != null) && (l_hand != null)) + if(l_hand != null) { - m_rightHandTarget.SetParent(l_lowerArm); - m_rightHandTarget.localPosition = l_hand.localPosition; - m_rightHandTarget.localRotation = l_hand.localRotation; - m_rightHandTarget.SetParent(m_rightHand, true); m_rightHandTarget.localPosition = Vector3.zero; - - Quaternion l_rot = m_rightHandTarget.localRotation; - m_rightHandTarget.localRotation = ms_offsetRight * l_rot; + m_rightHandTarget.localRotation = ms_offsetRight * (PlayerSetup.Instance._avatar.transform.GetMatrix().inverse * l_hand.GetMatrix()).rotation; } } } diff --git a/ml_lme/Properties/AssemblyInfo.cs b/ml_lme/Properties/AssemblyInfo.cs index 9fa4e00..5c23d94 100644 --- a/ml_lme/Properties/AssemblyInfo.cs +++ b/ml_lme/Properties/AssemblyInfo.cs @@ -1,10 +1,10 @@ using System.Reflection; [assembly: AssemblyTitle("LeapMotionExtension")] -[assembly: AssemblyVersion("1.1.9")] -[assembly: AssemblyFileVersion("1.1.9")] +[assembly: AssemblyVersion("1.2.0")] +[assembly: AssemblyFileVersion("1.2.0")] -[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.1.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] +[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.2.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")] [assembly: MelonLoader.MelonGame(null, "ChilloutVR")] [assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)] diff --git a/ml_lme/Utils.cs b/ml_lme/Utils.cs index 0a6cd14..60897e0 100644 --- a/ml_lme/Utils.cs +++ b/ml_lme/Utils.cs @@ -1,11 +1,17 @@ using ABI_RC.Core.Player; using System.Linq; +using UnityEngine; namespace ml_lme { static class Utils { public static bool AreKnucklesInUse() => PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles"); + + public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) + { + return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); + } public static void Swap(ref T lhs, ref T rhs) {