mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Wrist as target position
This commit is contained in:
parent
d11bf46f1a
commit
3b998827f5
5 changed files with 18 additions and 30 deletions
|
@ -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 |
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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<T>(ref T lhs, ref T rhs)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue