Minor code changes

This commit is contained in:
SDraw 2024-03-29 15:19:00 +03:00
parent 19606527fc
commit 11287e7dc5
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
36 changed files with 329 additions and 273 deletions

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Systems.IK; using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems;
using System; using System;
using System.Collections; using System.Collections;
using System.Reflection; using System.Reflection;
@ -98,7 +97,7 @@ namespace ml_amt
if(m_localTweaker != null) if(m_localTweaker != null)
m_localTweaker.OnAvatarReinitialize(); m_localTweaker.OnAvatarReinitialize();
} }
catch(System.Exception e) catch(Exception e)
{ {
MelonLoader.MelonLogger.Error(e); MelonLoader.MelonLogger.Error(e);
} }

View file

@ -1,5 +1,4 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.Movement; using ABI_RC.Systems.Movement;
using RootMotion.FinalIK; using RootMotion.FinalIK;
@ -125,6 +124,8 @@ namespace ml_amt
internal void OnSetupAvatar() internal void OnSetupAvatar()
{ {
Utils.SetAvatarTPose();
m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>(); m_vrIk = PlayerSetup.Instance._avatar.GetComponent<VRIK>();
m_locomotionLayer = PlayerSetup.Instance._animator.GetLayerIndex("Locomotion/Emotes"); m_locomotionLayer = PlayerSetup.Instance._animator.GetLayerIndex("Locomotion/Emotes");
m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y); m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y);
@ -179,6 +180,8 @@ namespace ml_amt
internal void OnAvatarReinitialize() internal void OnAvatarReinitialize()
{ {
// Old VRIK is destroyed by game // Old VRIK is destroyed by game
Utils.SetAvatarTPose();
m_vrIk = PlayerSetup.Instance._animator.GetComponent<VRIK>(); m_vrIk = PlayerSetup.Instance._animator.GetComponent<VRIK>();
if(m_vrIk != null) if(m_vrIk != null)
{ {
@ -242,25 +245,25 @@ namespace ml_amt
} }
// Settings // Settings
internal void SetCrouchLimit(float p_value) void SetCrouchLimit(float p_value)
{ {
if(m_ikLimits == null) if(m_ikLimits == null)
BetterBetterCharacterController.Instance.avatarCrouchLimit = Mathf.Clamp01(p_value); BetterBetterCharacterController.Instance.avatarCrouchLimit = Mathf.Clamp01(p_value);
} }
internal void SetProneLimit(float p_value) void SetProneLimit(float p_value)
{ {
if(m_ikLimits == null) if(m_ikLimits == null)
BetterBetterCharacterController.Instance.avatarProneLimit = Mathf.Clamp01(p_value); BetterBetterCharacterController.Instance.avatarProneLimit = Mathf.Clamp01(p_value);
} }
internal void SetIKOverrideFly(bool p_state) void SetIKOverrideFly(bool p_state)
{ {
m_ikOverrideFly = p_state; m_ikOverrideFly = p_state;
} }
internal void SetIKOverrideJump(bool p_state) void SetIKOverrideJump(bool p_state)
{ {
m_ikOverrideJump = p_state; m_ikOverrideJump = p_state;
} }
internal void SetDetectEmotes(bool p_state) void SetDetectEmotes(bool p_state)
{ {
m_detectEmotes = p_state; m_detectEmotes = p_state;
} }

View file

@ -26,12 +26,12 @@ namespace ml_amt
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<float> CrouchLimitChange; public static event Action<float> CrouchLimitChange;
static public event Action<float> ProneLimitChange; public static event Action<float> ProneLimitChange;
static public event Action<bool> IKOverrideFlyChange; public static event Action<bool> IKOverrideFlyChange;
static public event Action<bool> IKOverrideJumpChange; public static event Action<bool> IKOverrideJumpChange;
static public event Action<bool> DetectEmotesChange; public static event Action<bool> DetectEmotesChange;
static public event Action<bool> MassCenterChange; public static event Action<bool> MassCenterChange;
internal static void Init() internal static void Init()
{ {

View file

@ -1,6 +1,8 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using ABI_RC.Systems.IK;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@ -30,7 +32,14 @@ namespace ml_amt
return l_result; return l_result;
} }
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
public static void SetAvatarTPose()
{
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
// Engine extensions // Engine extensions
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)

View file

@ -16,7 +16,7 @@ namespace ml_asl
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> EnabledChange; public static event Action<bool> EnabledChange;
internal static void Init() internal static void Init()
{ {

View file

@ -7,6 +7,6 @@ namespace ml_asl
{ {
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
} }
} }

View file

@ -70,9 +70,7 @@ namespace ml_bft
{ {
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose); Utils.SetAvatarTPose();
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
InputHandler.Instance?.Rebind(PlayerSetup.Instance.transform.rotation); InputHandler.Instance?.Rebind(PlayerSetup.Instance.transform.rotation);
m_leftHandOffset.m_source = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); m_leftHandOffset.m_source = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand);
@ -135,8 +133,6 @@ namespace ml_bft
{ {
if(m_ready && MetaPort.Instance.isUsingVr && (p_handler != null) && Settings.SkeletalInput) if(m_ready && MetaPort.Instance.isUsingVr && (p_handler != null) && Settings.SkeletalInput)
{ {
// Virtually allign controllers wrist bone to avatar hands with offset and apply global rotation to avatar finger bones with individial offset
// This is done to apply rotation changes from controller bones to avatar finger bones as in local space
if(CVRInputManager.Instance._leftController != ABI_RC.Systems.InputManagement.XR.eXRControllerType.None) if(CVRInputManager.Instance._leftController != ABI_RC.Systems.InputManagement.XR.eXRControllerType.None)
{ {
Quaternion l_turnBack = (m_leftHandOffset.m_source.rotation * m_leftHandOffset.m_offset) * Quaternion.Inverse(m_leftHandOffset.m_target.rotation); Quaternion l_turnBack = (m_leftHandOffset.m_source.rotation * m_leftHandOffset.m_offset) * Quaternion.Inverse(m_leftHandOffset.m_target.rotation);
@ -151,7 +147,6 @@ namespace ml_bft
l_offset.m_target.rotation = l_turnBack * (l_offset.m_source.rotation * l_offset.m_offset); l_offset.m_target.rotation = l_turnBack * (l_offset.m_source.rotation * l_offset.m_offset);
} }
// No matter if hands are tracked, fill muscles values
p_handler.GetHumanPose(ref m_pose); p_handler.GetHumanPose(ref m_pose);
m_lastValues[0] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched]; m_lastValues[0] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched];
m_lastValues[1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched]; m_lastValues[1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched];

View file

@ -3,14 +3,14 @@ using Valve.VR;
namespace ml_bft namespace ml_bft
{ {
class HandHandlerOVR : HandHandler class HandHandlerVR : HandHandler
{ {
// 31 bones in each hand, get index at Valve.VR.SteamVR_Skeleton_JointIndexes or SteamVR_Skeleton_JointIndexEnum // 31 bones in each hand, get index at Valve.VR.SteamVR_Skeleton_JointIndexes or SteamVR_Skeleton_JointIndexEnum
const int c_fingerBonesCount = (int)SteamVR_Skeleton_JointIndexEnum.pinkyAux + 1; const int c_fingerBonesCount = (int)SteamVR_Skeleton_JointIndexEnum.pinkyAux + 1;
SteamVR_Action_Skeleton m_skeletonAction; SteamVR_Action_Skeleton m_skeletonAction;
public HandHandlerOVR(Transform p_root, bool p_left) : base(p_left) public HandHandlerVR(Transform p_root, bool p_left) : base(p_left)
{ {
for(int i = 0; i < c_fingerBonesCount; i++) for(int i = 0; i < c_fingerBonesCount; i++)
{ {
@ -20,7 +20,7 @@ namespace ml_bft
// Fill finger transforms // Fill finger transforms
m_prefabRoot = AssetsHandler.GetAsset(string.Format("assets/steamvr/models/[openvr] {0}.prefab", m_left ? "left" : "right")).transform; m_prefabRoot = AssetsHandler.GetAsset(string.Format("assets/steamvr/models/[openvr] {0}.prefab", m_left ? "left" : "right")).transform;
m_prefabRoot.name = "[FingersTracking_OVR]"; m_prefabRoot.name = "[FingersTracking_VR]";
m_prefabRoot.parent = p_root; m_prefabRoot.parent = p_root;
m_prefabRoot.localPosition = Vector3.zero; m_prefabRoot.localPosition = Vector3.zero;
m_prefabRoot.localRotation = Quaternion.identity; m_prefabRoot.localRotation = Quaternion.identity;
@ -28,42 +28,43 @@ namespace ml_bft
m_prefabRoot.GetComponentsInChildren(true, m_renderers); m_prefabRoot.GetComponentsInChildren(true, m_renderers);
// Ah yes, the stupid code // Ah yes, the stupid code
char l_side = (m_left ? 'l' : 'r');
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] = m_prefabRoot.Find("Root"); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] = m_prefabRoot.Find("Root");
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.wrist] = m_prefabRoot.Find(string.Format("Root/wrist_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.wrist] = m_prefabRoot.Find(string.Format("Root/wrist_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}/finger_thumb_{0}_end", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_thumb_0_{0}/finger_thumb_1_{0}/finger_thumb_2_{0}/finger_thumb_{0}_end", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}/finger_index_{0}_end", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_index_meta_{0}/finger_index_0_{0}/finger_index_1_{0}/finger_index_2_{0}/finger_index_{0}_end", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}/finger_middle_{0}_end", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_middle_meta_{0}/finger_middle_0_{0}/finger_middle_1_{0}/finger_middle_2_{0}/finger_middle_{0}_end", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}/finger_ring_{0}_end", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_ring_meta_{0}/finger_ring_0_{0}/finger_ring_1_{0}/finger_ring_2_{0}/finger_ring_{0}_end", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMetacarpal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyProximal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyMiddle] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyDistal] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}/finger_pinky_{0}_end", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyTip] = m_prefabRoot.Find(string.Format("Root/wrist_{0}/finger_pinky_meta_{0}/finger_pinky_0_{0}/finger_pinky_1_{0}/finger_pinky_2_{0}/finger_pinky_{0}_end", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbAux] = m_prefabRoot.Find(string.Format("Root/finger_thumb_{0}_aux", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.thumbAux] = m_prefabRoot.Find(string.Format("Root/finger_thumb_{0}_aux", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexAux] = m_prefabRoot.Find(string.Format("Root/finger_index_{0}_aux", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.indexAux] = m_prefabRoot.Find(string.Format("Root/finger_index_{0}_aux", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleAux] = m_prefabRoot.Find(string.Format("Root/finger_middle_{0}_aux", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.middleAux] = m_prefabRoot.Find(string.Format("Root/finger_middle_{0}_aux", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringAux] = m_prefabRoot.Find(string.Format("Root/finger_ring_{0}_aux", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.ringAux] = m_prefabRoot.Find(string.Format("Root/finger_ring_{0}_aux", l_side));
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyAux] = m_prefabRoot.Find(string.Format("Root/finger_pinky_{0}_aux", m_left ? 'l' : 'r')); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.pinkyAux] = m_prefabRoot.Find(string.Format("Root/finger_pinky_{0}_aux", l_side));
// Remember local rotations // Remember local rotations
for(int i = 0; i < c_fingerBonesCount; i++) for(int i = 0; i < c_fingerBonesCount; i++)
@ -75,6 +76,9 @@ namespace ml_bft
m_skeletonAction = SteamVR_Input.GetAction<SteamVR_Action_Skeleton>(p_left ? "SkeletonLeftHand" : "SkeletonRightHand"); m_skeletonAction = SteamVR_Input.GetAction<SteamVR_Action_Skeleton>(p_left ? "SkeletonLeftHand" : "SkeletonRightHand");
base.OnShowHandsChange(Settings.ShowHands); base.OnShowHandsChange(Settings.ShowHands);
OnMotionRangeChange(Settings.MotionRange);
Settings.MotionRangeChange += this.OnMotionRangeChange;
} }
public override void Cleanup() public override void Cleanup()
@ -82,6 +86,8 @@ namespace ml_bft
base.Cleanup(); base.Cleanup();
m_skeletonAction = null; m_skeletonAction = null;
Settings.MotionRangeChange -= this.OnMotionRangeChange;
} }
public override void Update() public override void Update()
@ -234,5 +240,18 @@ namespace ml_bft
if(m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] != null) if(m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root] != null)
m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root].rotation = p_base * (m_left ? Quaternion.Euler(0f, -90f, 0f) : Quaternion.Euler(0f, 90f, 0f)); m_bones[(int)SteamVR_Skeleton_JointIndexEnum.root].rotation = p_base * (m_left ? Quaternion.Euler(0f, -90f, 0f) : Quaternion.Euler(0f, 90f, 0f));
} }
void OnMotionRangeChange(Settings.MotionRangeType p_mode)
{
switch(p_mode)
{
case Settings.MotionRangeType.WithController:
m_skeletonAction?.SetRangeOfMotion(EVRSkeletalMotionRange.WithController);
break;
case Settings.MotionRangeType.WithoutController:
m_skeletonAction?.SetRangeOfMotion(EVRSkeletalMotionRange.WithoutController);
break;
}
}
} }
} }

View file

@ -1,6 +1,7 @@
using UnityEngine; using UnityEngine;
using UnityEngine.XR.OpenXR; using UnityEngine.XR.OpenXR;
using UnityEngine.XR.Hands; using UnityEngine.XR.Hands;
using UnityEngine.XR;
namespace ml_bft namespace ml_bft
{ {
@ -26,36 +27,37 @@ namespace ml_bft
m_prefabRoot.GetComponentsInChildren(true, m_renderers); m_prefabRoot.GetComponentsInChildren(true, m_renderers);
// Ah yes, the stupid code // Ah yes, the stupid code
m_bones[(int)XRHandJointID.Wrist - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist", m_left ? 'L' : 'R')); char l_side = (m_left ? 'L' : 'R');
m_bones[(int)XRHandJointID.Palm - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_Palm", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.Wrist - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist", l_side));
m_bones[(int)XRHandJointID.Palm - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_Palm", l_side));
m_bones[(int)XRHandJointID.ThumbMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.ThumbMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal", l_side));
m_bones[(int)XRHandJointID.ThumbProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.ThumbProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal", l_side));
m_bones[(int)XRHandJointID.ThumbDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.ThumbDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal", l_side));
m_bones[(int)XRHandJointID.ThumbTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal/{0}_ThumbTip", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.ThumbTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_ThumbMetacarpal/{0}_Wrist/{0}_ThumbProximal/{0}_ThumbDistal/{0}_ThumbTip", l_side));
m_bones[(int)XRHandJointID.IndexMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.IndexMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal", l_side));
m_bones[(int)XRHandJointID.IndexProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.IndexProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal", l_side));
m_bones[(int)XRHandJointID.IndexIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.IndexIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate", l_side));
m_bones[(int)XRHandJointID.IndexDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.IndexDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal", l_side));
m_bones[(int)XRHandJointID.IndexTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal/{0}_IndexTip", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.IndexTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_IndexMetacarpal/{0}_IndexProximal/{0}_IndexIntermediate/{0}_IndexDistal/{0}_IndexTip", l_side));
m_bones[(int)XRHandJointID.MiddleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.MiddleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal", l_side));
m_bones[(int)XRHandJointID.MiddleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.MiddleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal", l_side));
m_bones[(int)XRHandJointID.MiddleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.MiddleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate", l_side));
m_bones[(int)XRHandJointID.MiddleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.MiddleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal", l_side));
m_bones[(int)XRHandJointID.MiddleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal/{0}_MiddleTip", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.MiddleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_MiddleMetacarpal/{0}_MiddleProximal/{0}_MiddleIntermediate/{0}_MiddleDistal/{0}_MiddleTip", l_side));
m_bones[(int)XRHandJointID.RingMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.RingMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal", l_side));
m_bones[(int)XRHandJointID.RingProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.RingProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal", l_side));
m_bones[(int)XRHandJointID.RingIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.RingIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate", l_side));
m_bones[(int)XRHandJointID.RingDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.RingDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal", l_side));
m_bones[(int)XRHandJointID.RingTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal/{0}_RingTip", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.RingTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_RingMetacarpal/{0}_RingProximal/{0}_RingIntermediate/{0}_RingDistal/{0}_RingTip", l_side));
m_bones[(int)XRHandJointID.LittleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.LittleMetacarpal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal", l_side));
m_bones[(int)XRHandJointID.LittleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.LittleProximal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal", l_side));
m_bones[(int)XRHandJointID.LittleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.LittleIntermediate - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate", l_side));
m_bones[(int)XRHandJointID.LittleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.LittleDistal - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal", l_side));
m_bones[(int)XRHandJointID.LittleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal/{0}_LittleTip", m_left ? 'L' : 'R')); m_bones[(int)XRHandJointID.LittleTip - 1] = m_prefabRoot.Find(string.Format("{0}_Wrist/{0}_LittleMetacarpal/{0}_LittleProximal/{0}_LittleIntermediate/{0}_LittleDistal/{0}_LittleTip", l_side));
for(int i = 0; i < c_fingerBonesCount; i++) for(int i = 0; i < c_fingerBonesCount; i++)
{ {
@ -191,21 +193,23 @@ namespace ml_bft
public override void Update() public override void Update()
{ {
var l_tracking = OpenXRSettings.Instance.GetFeature<HandTrackingFeature>(); var l_tracking = OpenXRSettings.Instance.GetFeature<HandTrackingFeature>();
if(l_tracking != null) var l_device = InputDevices.GetDeviceAtXRNode(m_left ? XRNode.LeftHand : XRNode.RightHand);
if((l_device != null) && l_device.TryGetFeatureValue(CommonUsages.deviceRotation, out Quaternion l_deviceRot) && (l_tracking != null))
{ {
// Bones from API are in playspace, not local in comparison with OpenVR Quaternion l_handInv = Quaternion.Inverse(l_deviceRot);
l_tracking.GetHandJoints(m_left ? HandTrackingFeature.Hand_Index.L : HandTrackingFeature.Hand_Index.R, out var l_positions, out var l_rotations, out var l_radius); l_tracking.GetHandJoints(m_left ? HandTrackingFeature.Hand_Index.L : HandTrackingFeature.Hand_Index.R, out var l_positions, out var l_rotations, out _);
if(l_positions.Length >= c_fingerBonesCount) if(l_positions.Length >= c_fingerBonesCount)
{ {
// This stuff rotates debug hands in a weird way, but it doesn't matter because of funny math in new FingerSystem // Joints rotations are in global space, locations are in local space ... wth is wrong with OpenXR?
Quaternion l_rot = m_prefabRoot.rotation; Quaternion l_prefabRot = m_prefabRoot.rotation;
m_prefabRoot.rotation = Quaternion.identity;
for(int i = 0; i < c_fingerBonesCount; i++) for(int i = 0; i < c_fingerBonesCount; i++)
{ {
if(m_bones[i] != null) if(m_bones[i] != null)
m_bones[i].rotation = l_rotations[i]; {
m_bones[i].localPosition = l_positions[i];
m_bones[i].rotation = l_prefabRot * (l_handInv * l_rotations[i]);
}
} }
m_prefabRoot.rotation = l_rot;
} }
} }
} }

View file

@ -42,10 +42,15 @@ namespace ml_bft
{ {
if(!CheckVR.Instance.forceOpenXr) if(!CheckVR.Instance.forceOpenXr)
{ {
m_leftHandHandler = new HandHandlerOVR(CVRInputManager.Instance.leftHandTransform, true); m_leftHandHandler = new HandHandlerVR(CVRInputManager.Instance.leftHandTransform, true);
m_rightHandHandler = new HandHandlerOVR(CVRInputManager.Instance.rightHandTransform, false); m_rightHandHandler = new HandHandlerVR(CVRInputManager.Instance.rightHandTransform, false);
m_active = true;
} }
else
{
m_leftHandHandler = new HandHandlerXR(CVRInputManager.Instance.leftHandTransform, true);
m_rightHandHandler = new HandHandlerXR(CVRInputManager.Instance.rightHandTransform, false);
}
m_active = true;
} }
void RemoveHandlers() void RemoveHandlers()
{ {

View file

@ -6,20 +6,28 @@ namespace ml_bft
{ {
static class Settings static class Settings
{ {
public enum MotionRangeType
{
WithController = 0,
WithoutController
}
enum ModSetting enum ModSetting
{ {
SkeletalInput = 0, SkeletalInput = 0,
MotionRange,
ShowHands ShowHands
} }
public static bool SkeletalInput { get; private set; } = false; public static bool SkeletalInput { get; private set; } = false;
public static MotionRangeType MotionRange { get; private set; } = MotionRangeType.WithController;
public static bool ShowHands { get; private set; } = false; public static bool ShowHands { get; private set; } = false;
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> SkeletalInputChange; public static event Action<bool> SkeletalInputChange;
static public event Action<bool> ShowHandsChange; public static event Action<MotionRangeType> MotionRangeChange;
public static event Action<bool> ShowHandsChange;
internal static void Init() internal static void Init()
{ {
@ -28,10 +36,12 @@ namespace ml_bft
ms_entries = new List<MelonLoader.MelonPreferences_Entry>() ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
{ {
ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput), ms_category.CreateEntry(ModSetting.SkeletalInput.ToString(), SkeletalInput),
ms_category.CreateEntry(ModSetting.MotionRange.ToString(), (int)MotionRange),
ms_category.CreateEntry(ModSetting.ShowHands.ToString(), ShowHands) ms_category.CreateEntry(ModSetting.ShowHands.ToString(), ShowHands)
}; };
SkeletalInput = (bool)ms_entries[(int)ModSetting.SkeletalInput].BoxedValue; SkeletalInput = (bool)ms_entries[(int)ModSetting.SkeletalInput].BoxedValue;
MotionRange = (MotionRangeType)(int)ms_entries[(int)ModSetting.MotionRange].BoxedValue;
ShowHands = (bool)ms_entries[(int)ModSetting.ShowHands].BoxedValue; ShowHands = (bool)ms_entries[(int)ModSetting.ShowHands].BoxedValue;
MelonLoader.MelonCoroutines.Start(WaitMainMenuUi()); MelonLoader.MelonCoroutines.Start(WaitMainMenuUi());
@ -49,6 +59,7 @@ namespace ml_bft
ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () => ViewManager.Instance.gameMenuView.Listener.ReadyForBindings += () =>
{ {
ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action<string, string>(OnToggleUpdate)); ViewManager.Instance.gameMenuView.View.BindCall("OnToggleUpdate_" + ms_category.Identifier, new Action<string, string>(OnToggleUpdate));
ViewManager.Instance.gameMenuView.View.BindCall("OnDropdownUpdate_" + ms_category.Identifier, new Action<string, string>(OnDropdownUpdate));
}; };
ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) => ViewManager.Instance.gameMenuView.Listener.FinishLoad += (_) =>
{ {
@ -71,7 +82,7 @@ namespace ml_bft
SkeletalInputChange?.Invoke(SkeletalInput); SkeletalInputChange?.Invoke(SkeletalInput);
} }
break; break;
case ModSetting.ShowHands: case ModSetting.ShowHands:
{ {
ShowHands = bool.Parse(p_value); ShowHands = bool.Parse(p_value);
@ -83,5 +94,23 @@ namespace ml_bft
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value); ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
} }
} }
static void OnDropdownUpdate(string p_name, string p_value)
{
if(Enum.TryParse(p_name, out ModSetting l_setting))
{
switch(l_setting)
{
case ModSetting.MotionRange:
{
MotionRange = (MotionRangeType)int.Parse(p_value);
MotionRangeChange?.Invoke(MotionRange);
}
break;
}
ms_entries[(int)l_setting].BoxedValue = int.Parse(p_value);
}
}
} }
} }

View file

@ -1,6 +1,9 @@
using ABI_RC.Core.UI; using ABI_RC.Core.Player;
using ABI_RC.Core.UI;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
using System.Reflection; using System.Reflection;
using UnityEngine;
namespace ml_bft namespace ml_bft
{ {
@ -8,8 +11,15 @@ namespace ml_bft
{ {
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
public static bool AreKnucklesInUse() => ((CVRInputManager.Instance._leftController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index) || (CVRInputManager.Instance._rightController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index)); public static bool AreKnucklesInUse() => ((CVRInputManager.Instance._leftController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index) || (CVRInputManager.Instance._rightController == ABI_RC.Systems.InputManagement.XR.eXRControllerType.Index));
public static void SetAvatarTPose()
{
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
} }
} }

View file

@ -60,6 +60,11 @@
<SpecificVersion>false</SpecificVersion> <SpecificVersion>false</SpecificVersion>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Unity.XR.OpenVR">
<HintPath>D:\games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.XR.OpenVR.dll</HintPath>
<SpecificVersion>false</SpecificVersion>
<Private>false</Private>
</Reference>
<Reference Include="Unity.XR.OpenXR"> <Reference Include="Unity.XR.OpenXR">
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.XR.OpenXR.dll</HintPath> <HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Unity.XR.OpenXR.dll</HintPath>
<SpecificVersion>false</SpecificVersion> <SpecificVersion>false</SpecificVersion>

View file

@ -7,11 +7,18 @@
</div> </div>
<div class ="row-wrapper"> <div class ="row-wrapper">
<div class ="option-caption">Force SteamVR skeletal input: </div> <div class ="option-caption">Force SteamVR/OpenXR skeletal input: </div>
<div class ="option-input"> <div class ="option-input">
<div id="SkeletalInput" class ="inp_toggle no-scroll" data-current="false"></div> <div id="SkeletalInput" class ="inp_toggle no-scroll" data-current="false"></div>
</div> </div>
</div> </div>
<div class ="row-wrapper">
<div class ="option-caption">Motion range (SteamVR only): </div>
<div class ="option-input">
<div id="MotionRange" class ="inp_dropdown no-scroll" data-options="0:With controller,1:Without controller" data-current="0"></div>
</div>
</div>
<div class ="row-wrapper"> <div class ="row-wrapper">
<div class ="option-caption">Show hands model: </div> <div class ="option-caption">Show hands model: </div>
@ -25,4 +32,8 @@
// Toggles // Toggles
for (let l_toggle of l_block.querySelectorAll('.inp_toggle')) for (let l_toggle of l_block.querySelectorAll('.inp_toggle'))
modsExtension.addSetting('BFT', l_toggle.id, modsExtension.createToggle(l_toggle, 'OnToggleUpdate_BFT')); modsExtension.addSetting('BFT', l_toggle.id, modsExtension.createToggle(l_toggle, 'OnToggleUpdate_BFT'));
// Dropdowns
for (let l_dropdown of l_block.querySelectorAll('.inp_dropdown'))
modsExtension.addSetting('BFT', l_dropdown.id, modsExtension.createDropdown(l_dropdown, 'OnDropdownUpdate_BFT'));
} }

View file

@ -2,7 +2,6 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Player.EyeMovement; using ABI_RC.Core.Player.EyeMovement;
using ABI_RC.Systems.FaceTracking; using ABI_RC.Systems.FaceTracking;
using ABI_RC.Systems.VRModeSwitch;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using System; using System;
using System.Reflection; using System.Reflection;
@ -99,13 +98,15 @@ namespace ml_dht
// Game events // Game events
internal void OnSetupAvatar() internal void OnSetupAvatar()
{ {
Utils.SetAvatarTPose();
m_camera = PlayerSetup.Instance.GetActiveCamera().transform; m_camera = PlayerSetup.Instance.GetActiveCamera().transform;
m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent<CVRAvatar>(); m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent<CVRAvatar>();
m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head); m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head);
m_lookIK = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>(); m_lookIK = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
if(m_headBone != null) if(m_headBone != null)
m_bindRotation = (m_avatarDescriptor.transform.GetMatrix().inverse * m_headBone.GetMatrix()).rotation; m_bindRotation = Quaternion.Inverse(m_avatarDescriptor.transform.rotation) * m_headBone.rotation;
if(m_lookIK != null) if(m_lookIK != null)
m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate); m_lookIK.onPostSolverUpdate.AddListener(this.OnLookIKPostUpdate);

View file

@ -28,14 +28,13 @@ namespace ml_dht
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> EnabledChange; public static event Action<bool> EnabledChange;
static public event Action<bool> HeadTrackingChange; public static event Action<bool> HeadTrackingChange;
static public event Action<bool> EyeTrackingChange; public static event Action<bool> EyeTrackingChange;
static public event Action<bool> FaceTrackingChange; public static event Action<bool> FaceTrackingChange;
static public event Action<bool> BlinkingChange; public static event Action<bool> BlinkingChange;
static public event Action<bool> MirroredChange; public static event Action<bool> MirroredChange;
static public event Action<float> SmoothingChange; public static event Action<float> SmoothingChange;
internal static void Init() internal static void Init()
{ {

View file

@ -17,7 +17,7 @@ struct TrackingData
public float m_mouthShape; // Range - [-1;1], -1 - wide, 1 - narrow public float m_mouthShape; // Range - [-1;1], -1 - wide, 1 - narrow
public float m_brows; // Range - [-1;1], -1 - up, 1 - down; not used yet public float m_brows; // Range - [-1;1], -1 - up, 1 - down; not used yet
static public byte[] ToBytes(TrackingData p_faceData) public static byte[] ToBytes(TrackingData p_faceData)
{ {
int l_size = Marshal.SizeOf(p_faceData); int l_size = Marshal.SizeOf(p_faceData);
byte[] l_arr = new byte[l_size]; byte[] l_arr = new byte[l_size];
@ -29,7 +29,7 @@ struct TrackingData
return l_arr; return l_arr;
} }
static public TrackingData ToObject(byte[] p_buffer) public static TrackingData ToObject(byte[] p_buffer)
{ {
TrackingData l_faceData = new TrackingData(); TrackingData l_faceData = new TrackingData();

View file

@ -1,5 +1,7 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.Player;
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using ABI_RC.Systems.IK;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@ -11,13 +13,15 @@ namespace ml_dht
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly MethodInfo ms_updateShapesLocal = typeof(CVRFaceTracking).GetMethod("UpdateShapesLocal", BindingFlags.NonPublic | BindingFlags.Instance); static readonly MethodInfo ms_updateShapesLocal = typeof(CVRFaceTracking).GetMethod("UpdateShapesLocal", BindingFlags.NonPublic | BindingFlags.Instance);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
static public void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray); public static void UpdateShapesLocal_Private(this CVRFaceTracking p_instance) => ms_updateShapesLocal?.Invoke(p_instance, ms_emptyArray);
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) public static void SetAvatarTPose()
{ {
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one); IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
} }
} }
} }

View file

@ -91,7 +91,7 @@ namespace ml_lme
{ {
if(m_fingersBones[i] != null) if(m_fingersBones[i] != null)
{ {
//m_fingers[i].position = p_data.m_fingerPosition[i]; //m_fingersBones[i].position = p_data.m_fingerPosition[i];
m_fingersBones[i].rotation = p_data.m_fingerRotation[i]; m_fingersBones[i].rotation = p_data.m_fingerRotation[i];
} }
} }

View file

@ -1,7 +1,6 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Systems.IK; using ABI_RC.Systems.IK;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -195,22 +194,17 @@ namespace ml_lme
} }
m_poseHandler.GetHumanPose(ref m_pose); m_poseHandler.GetHumanPose(ref m_pose);
if(l_data.m_leftHand.m_present) if(l_data.m_leftHand.m_present || l_data.m_rightHand.m_present)
{ {
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
int l_offset = i * 4; int l_offset = i * 4;
ms_lastLeftFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched + l_offset]; ms_lastLeftFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.LeftThumb1Stretched + l_offset];
ms_lastLeftFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched + l_offset]; ms_lastLeftFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.LeftThumb2Stretched + l_offset];
ms_lastLeftFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.LeftThumb3Stretched + l_offset]; ms_lastLeftFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.LeftThumb3Stretched + l_offset];
ms_lastLeftFingerBones[l_offset + 3] = m_pose.muscles[(int)MuscleIndex.LeftThumbSpread + l_offset]; ms_lastLeftFingerBones[l_offset + 3] = m_pose.muscles[(int)MuscleIndex.LeftThumbSpread + l_offset];
}
}
if(l_data.m_rightHand.m_present)
{
for(int i = 0; i < 5; i++)
{
int l_offset = i * 4;
ms_lastRightFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.RightThumb1Stretched + l_offset]; ms_lastRightFingerBones[l_offset] = m_pose.muscles[(int)MuscleIndex.RightThumb1Stretched + l_offset];
ms_lastRightFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.RightThumb2Stretched + l_offset]; ms_lastRightFingerBones[l_offset + 1] = m_pose.muscles[(int)MuscleIndex.RightThumb2Stretched + l_offset];
ms_lastRightFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.RightThumb3Stretched + l_offset]; ms_lastRightFingerBones[l_offset + 2] = m_pose.muscles[(int)MuscleIndex.RightThumb3Stretched + l_offset];
@ -249,21 +243,14 @@ namespace ml_lme
internal void OnAvatarSetup() internal void OnAvatarSetup()
{ {
m_inVR = Utils.IsInVR(); m_inVR = Utils.IsInVR();
m_vrIK = PlayerSetup.Instance._animator.GetComponent<VRIK>();
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
Utils.SetAvatarTPose();
m_poseHandler = new HumanPoseHandler(PlayerSetup.Instance._animator.avatar, PlayerSetup.Instance._animator.transform); m_poseHandler = new HumanPoseHandler(PlayerSetup.Instance._animator.avatar, PlayerSetup.Instance._animator.transform);
m_poseHandler.GetHumanPose(ref m_pose); m_poseHandler.GetHumanPose(ref m_pose);
if(m_inVR)
{
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
else
PoseHelper.ForceTPose(PlayerSetup.Instance._animator);
m_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); m_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand);
m_leftHandTarget.localRotation = ms_offsetLeft * (Quaternion.Inverse(PlayerSetup.Instance._avatar.transform.rotation) * m_leftHand.rotation); m_leftHandTarget.localRotation = ms_offsetLeft * (Quaternion.Inverse(PlayerSetup.Instance._avatar.transform.rotation) * m_leftHand.rotation);
@ -272,6 +259,7 @@ namespace ml_lme
ParseFingersBones(); ParseFingersBones();
m_vrIK = PlayerSetup.Instance._animator.GetComponent<VRIK>();
if(m_vrIK != null) if(m_vrIK != null)
{ {
m_vrIK.onPreSolverUpdate.AddListener(this.OnIKPreUpdate); m_vrIK.onPreSolverUpdate.AddListener(this.OnIKPreUpdate);
@ -298,7 +286,7 @@ namespace ml_lme
} }
else else
{ {
PoseHelper.ForceTPose(PlayerSetup.Instance._animator); Utils.SetAvatarTPose();
SetupArmIK(); SetupArmIK();
} }
} }

View file

@ -1,26 +0,0 @@
using UnityEngine;
using ABI_RC.Systems.IK;
namespace ml_lme
{
static class PoseHelper
{
public static void ForceTPose(Animator p_animator)
{
if(p_animator.isHuman)
{
HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform);
HumanPose l_pose = new HumanPose();
l_handler.GetHumanPose(ref l_pose);
for(int i=0, j = Mathf.Min(l_pose.muscles.Length,MusclePoses.TPoseMuscles.Length); i < j; i++)
l_pose.muscles[i] = MusclePoses.TPoseMuscles[i];
l_pose.bodyPosition = Vector3.up;
l_pose.bodyRotation = Quaternion.identity;
l_handler.SetHumanPose(ref l_pose);
l_handler.Dispose();
}
}
}
}

View file

@ -56,20 +56,20 @@ namespace ml_lme
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> EnabledChange; public static event Action<bool> EnabledChange;
static public event Action<Vector3> DesktopOffsetChange; public static event Action<Vector3> DesktopOffsetChange;
static public event Action<bool> FingersOnlyChange; public static event Action<bool> FingersOnlyChange;
static public event Action<bool> ModelVisibilityChange; public static event Action<bool> ModelVisibilityChange;
static public event Action<LeapTrackingMode> TrackingModeChange; public static event Action<LeapTrackingMode> TrackingModeChange;
static public event Action<Vector3> RootAngleChange; public static event Action<Vector3> RootAngleChange;
static public event Action<bool> HeadAttachChange; public static event Action<bool> HeadAttachChange;
static public event Action<Vector3> HeadOffsetChange; public static event Action<Vector3> HeadOffsetChange;
static public event Action<bool> TrackElbowsChange; public static event Action<bool> TrackElbowsChange;
static public event Action<bool> InteractionChange; public static event Action<bool> InteractionChange;
static public event Action<bool> GesturesChange; public static event Action<bool> GesturesChange;
static public event Action<float> InteractThreadholdChange; public static event Action<float> InteractThreadholdChange;
static public event Action<float> GripThreadholdChange; public static event Action<float> GripThreadholdChange;
static public event Action<bool> VisualHandsChange; public static event Action<bool> VisualHandsChange;
internal static void Init() internal static void Init()
{ {

View file

@ -1,6 +1,8 @@
using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -49,7 +51,14 @@ namespace ml_lme
} }
} }
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
public static void SetAvatarTPose()
{
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
public static void Swap<T>(ref T lhs, ref T rhs) public static void Swap<T>(ref T lhs, ref T rhs)
{ {

View file

@ -332,8 +332,7 @@ namespace ml_pam
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
if(!m_inVR) Utils.SetAvatarTPose();
PoseHelper.ForceTPose(PlayerSetup.Instance._animator);
Transform l_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand); Transform l_leftHand = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftHand);
if(l_leftHand != null) if(l_leftHand != null)

View file

@ -1,26 +0,0 @@
using UnityEngine;
using ABI_RC.Systems.IK;
namespace ml_pam
{
static class PoseHelper
{
public static void ForceTPose(Animator p_animator)
{
if(p_animator.isHuman)
{
HumanPoseHandler l_handler = new HumanPoseHandler(p_animator.avatar, p_animator.transform);
HumanPose l_pose = new HumanPose();
l_handler.GetHumanPose(ref l_pose);
for(int i = 0, j = Mathf.Min(l_pose.muscles.Length, MusclePoses.TPoseMuscles.Length); i < j; i++)
l_pose.muscles[i] = MusclePoses.TPoseMuscles[i];
l_pose.bodyPosition = Vector3.up;
l_pose.bodyRotation = Quaternion.identity;
l_handler.SetHumanPose(ref l_pose);
l_handler.Dispose();
}
}
}
}

View file

@ -28,10 +28,10 @@ namespace ml_pam
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> EnabledChange; public static event Action<bool> EnabledChange;
static public event Action<float> GrabOffsetChange; public static event Action<float> GrabOffsetChange;
static public event Action<LeadHand> LeadingHandChange; public static event Action<LeadHand> LeadingHandChange;
static public event Action<bool> HandsExtensionChange; public static event Action<bool> HandsExtensionChange;
internal static void Init() internal static void Init()
{ {

View file

@ -1,5 +1,7 @@
using ABI_RC.Core.Savior; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using ABI_RC.Systems.IK;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
@ -11,7 +13,14 @@ namespace ml_pam
public static bool IsInVR() => ((MetaPort.Instance != null) && MetaPort.Instance.isUsingVr); public static bool IsInVR() => ((MetaPort.Instance != null) && MetaPort.Instance.isUsingVr);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
public static void SetAvatarTPose()
{
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
// Extensions // Extensions
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false) public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)

View file

@ -33,12 +33,12 @@ namespace ml_pin
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<NotificationType> NotifyTypeChange; public static event Action<NotificationType> NotifyTypeChange;
static public event Action<float> VolumeChange; public static event Action<float> VolumeChange;
static public event Action<bool> NotifyInPublicChange; public static event Action<bool> NotifyInPublicChange;
static public event Action<bool> NotifyInFriendsChange; public static event Action<bool> NotifyInFriendsChange;
static public event Action<bool> NotifyInPrivateChange; public static event Action<bool> NotifyInPrivateChange;
static public event Action<bool> FriendsAlwaysChange; public static event Action<bool> FriendsAlwaysChange;
internal static void Init() internal static void Init()
{ {

View file

@ -7,6 +7,6 @@ namespace ml_pin
{ {
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
} }
} }

View file

@ -3,7 +3,6 @@ using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
using ABI_RC.Systems.Movement; using ABI_RC.Systems.Movement;
using ABI_RC.Systems.VRModeSwitch;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using UnityEngine; using UnityEngine;
@ -14,8 +13,8 @@ namespace ml_pmc
{ {
static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f); static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f);
static public PoseCopycat Instance { get; private set; } = null; public static PoseCopycat Instance { get; private set; } = null;
static internal System.Action<bool> OnActivityChange; internal static System.Action<bool> OnActivityChange;
Animator m_animator = null; Animator m_animator = null;
VRIK m_vrIk = null; VRIK m_vrIk = null;
@ -372,29 +371,29 @@ namespace ml_pmc
if(!CVRInputManager.Instance.individualFingerTracking) if(!CVRInputManager.Instance.individualFingerTracking)
{ {
// Left hand // Left hand
CVRInputManager.Instance.finger1StretchedLeftThumb = -0.5f; CVRInputManager.Instance.finger1StretchedLeftThumb = -0f;
CVRInputManager.Instance.finger2StretchedLeftThumb = 0.7f; CVRInputManager.Instance.finger2StretchedLeftThumb = 0f;
CVRInputManager.Instance.finger3StretchedLeftThumb = 0.7f; CVRInputManager.Instance.finger3StretchedLeftThumb = 0f;
CVRInputManager.Instance.fingerSpreadLeftThumb = 0f; CVRInputManager.Instance.fingerSpreadLeftThumb = 0f;
CVRInputManager.Instance.finger1StretchedLeftIndex = 0.5f; CVRInputManager.Instance.finger1StretchedLeftIndex = 0f;
CVRInputManager.Instance.finger2StretchedLeftIndex = 0.7f; CVRInputManager.Instance.finger2StretchedLeftIndex = 0f;
CVRInputManager.Instance.finger3StretchedLeftIndex = 0.7f; CVRInputManager.Instance.finger3StretchedLeftIndex = 0f;
CVRInputManager.Instance.fingerSpreadLeftIndex = 0f; CVRInputManager.Instance.fingerSpreadLeftIndex = 0f;
CVRInputManager.Instance.finger1StretchedLeftMiddle = 0.5f; CVRInputManager.Instance.finger1StretchedLeftMiddle = 0;
CVRInputManager.Instance.finger2StretchedLeftMiddle = 0.7f; CVRInputManager.Instance.finger2StretchedLeftMiddle = 0f;
CVRInputManager.Instance.finger3StretchedLeftMiddle = 0.7f; CVRInputManager.Instance.finger3StretchedLeftMiddle = 0f;
CVRInputManager.Instance.fingerSpreadLeftMiddle = 0f; CVRInputManager.Instance.fingerSpreadLeftMiddle = 0f;
CVRInputManager.Instance.finger1StretchedLeftRing = 0.5f; CVRInputManager.Instance.finger1StretchedLeftRing = 0f;
CVRInputManager.Instance.finger2StretchedLeftRing = 0.7f; CVRInputManager.Instance.finger2StretchedLeftRing = 0f;
CVRInputManager.Instance.finger3StretchedLeftRing = 0.7f; CVRInputManager.Instance.finger3StretchedLeftRing = 0f;
CVRInputManager.Instance.fingerSpreadLeftRing = 0f; CVRInputManager.Instance.fingerSpreadLeftRing = 0f;
CVRInputManager.Instance.finger1StretchedLeftPinky = 0.5f; CVRInputManager.Instance.finger1StretchedLeftPinky = 0f;
CVRInputManager.Instance.finger2StretchedLeftPinky = 0.7f; CVRInputManager.Instance.finger2StretchedLeftPinky = 0f;
CVRInputManager.Instance.finger3StretchedLeftPinky = 0.7f; CVRInputManager.Instance.finger3StretchedLeftPinky = 0f;
CVRInputManager.Instance.fingerSpreadLeftPinky = 0f; CVRInputManager.Instance.fingerSpreadLeftPinky = 0f;
CVRInputManager.Instance.fingerFullCurlNormalizedLeftThumb = 0f; CVRInputManager.Instance.fingerFullCurlNormalizedLeftThumb = 0f;
@ -404,29 +403,29 @@ namespace ml_pmc
CVRInputManager.Instance.fingerFullCurlNormalizedLeftPinky = 0f; CVRInputManager.Instance.fingerFullCurlNormalizedLeftPinky = 0f;
// Right hand // Right hand
CVRInputManager.Instance.finger1StretchedRightThumb = -0.5f; CVRInputManager.Instance.finger1StretchedRightThumb = 0f;
CVRInputManager.Instance.finger2StretchedRightThumb = 0.7f; CVRInputManager.Instance.finger2StretchedRightThumb = 0f;
CVRInputManager.Instance.finger3StretchedRightThumb = 0.7f; CVRInputManager.Instance.finger3StretchedRightThumb = 0f;
CVRInputManager.Instance.fingerSpreadRightThumb = 0f; CVRInputManager.Instance.fingerSpreadRightThumb = 0f;
CVRInputManager.Instance.finger1StretchedRightIndex = 0.5f; CVRInputManager.Instance.finger1StretchedRightIndex = 0f;
CVRInputManager.Instance.finger2StretchedRightIndex = 0.7f; CVRInputManager.Instance.finger2StretchedRightIndex = 0f;
CVRInputManager.Instance.finger3StretchedRightIndex = 0.7f; CVRInputManager.Instance.finger3StretchedRightIndex = 0f;
CVRInputManager.Instance.fingerSpreadRightIndex = 0f; CVRInputManager.Instance.fingerSpreadRightIndex = 0f;
CVRInputManager.Instance.finger1StretchedRightMiddle = 0.5f; CVRInputManager.Instance.finger1StretchedRightMiddle = 0f;
CVRInputManager.Instance.finger2StretchedRightMiddle = 0.7f; CVRInputManager.Instance.finger2StretchedRightMiddle = 0f;
CVRInputManager.Instance.finger3StretchedRightMiddle = 0.7f; CVRInputManager.Instance.finger3StretchedRightMiddle = 0f;
CVRInputManager.Instance.fingerSpreadRightMiddle = 0f; CVRInputManager.Instance.fingerSpreadRightMiddle = 0f;
CVRInputManager.Instance.finger1StretchedRightRing = 0.5f; CVRInputManager.Instance.finger1StretchedRightRing = 0f;
CVRInputManager.Instance.finger2StretchedRightRing = 0.7f; CVRInputManager.Instance.finger2StretchedRightRing = 0f;
CVRInputManager.Instance.finger3StretchedRightRing = 0.7f; CVRInputManager.Instance.finger3StretchedRightRing = 0f;
CVRInputManager.Instance.fingerSpreadRightRing = 0f; CVRInputManager.Instance.fingerSpreadRightRing = 0f;
CVRInputManager.Instance.finger1StretchedRightPinky = 0.5f; CVRInputManager.Instance.finger1StretchedRightPinky = 0f;
CVRInputManager.Instance.finger2StretchedRightPinky = 0.7f; CVRInputManager.Instance.finger2StretchedRightPinky = 0f;
CVRInputManager.Instance.finger3StretchedRightPinky = 0.7f; CVRInputManager.Instance.finger3StretchedRightPinky = 0f;
CVRInputManager.Instance.fingerSpreadRightPinky = 0f; CVRInputManager.Instance.fingerSpreadRightPinky = 0f;
CVRInputManager.Instance.fingerFullCurlNormalizedRightThumb = 0f; CVRInputManager.Instance.fingerFullCurlNormalizedRightThumb = 0f;

View file

@ -29,7 +29,7 @@ namespace ml_prm
FallLimit FallLimit
} }
static public event Action SwitchChange; public static event Action SwitchChange;
static List<object> ms_uiElements = null; static List<object> ms_uiElements = null;

View file

@ -288,6 +288,8 @@ namespace ml_prm
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
Utils.SetAvatarTPose();
BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator); BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator);
m_puppet = new GameObject("Root").transform; m_puppet = new GameObject("Root").transform;

View file

@ -47,24 +47,24 @@ namespace ml_prm
public static bool FallDamage { get; private set; } = true; public static bool FallDamage { get; private set; } = true;
public static float FallLimit { get; private set; } = 5f; public static float FallLimit { get; private set; } = 5f;
static public event Action<bool> HotkeyChange; public static event Action<bool> HotkeyChange;
static public event Action<KeyCode> HotkeyKeyChange; public static event Action<KeyCode> HotkeyKeyChange;
static public event Action<float> VelocityMultiplierChange; public static event Action<float> VelocityMultiplierChange;
static public event Action<float> MovementDragChange; public static event Action<float> MovementDragChange;
static public event Action<float> AngularDragChange; public static event Action<float> AngularDragChange;
static public event Action<bool> GravityChange; public static event Action<bool> GravityChange;
static public event Action<bool> PointersReactionChange; public static event Action<bool> PointersReactionChange;
static public event Action<bool> IgnoreLocalChange; public static event Action<bool> IgnoreLocalChange;
static public event Action<bool> CombatReactionChange; public static event Action<bool> CombatReactionChange;
static public event Action<bool> AutoRecoverChange; public static event Action<bool> AutoRecoverChange;
static public event Action<float> RecoverDelayChange; public static event Action<float> RecoverDelayChange;
static public event Action<bool> SlipperinessChange; public static event Action<bool> SlipperinessChange;
static public event Action<bool> BouncinessChange; public static event Action<bool> BouncinessChange;
static public event Action<bool> ViewVelocityChange; public static event Action<bool> ViewVelocityChange;
static public event Action<bool> JumpRecoverChange; public static event Action<bool> JumpRecoverChange;
static public event Action<bool> BuoyancyChange; public static event Action<bool> BuoyancyChange;
static public event Action<bool> FallDamageChange; public static event Action<bool> FallDamageChange;
static public event Action<float> FallLimitChange; public static event Action<float> FallLimitChange;
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;

View file

@ -1,5 +1,7 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.Movement; using ABI_RC.Systems.Movement;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -46,5 +48,12 @@ namespace ml_prm
(ms_influencerTouchingVolumes.GetValue(p_instance) as List<FluidVolume>)?.Clear(); (ms_influencerTouchingVolumes.GetValue(p_instance) as List<FluidVolume>)?.Clear();
(ms_influencerSubmergedColliders.GetValue(p_instance) as Dictionary<FluidVolume, int>)?.Clear(); (ms_influencerSubmergedColliders.GetValue(p_instance) as Dictionary<FluidVolume, int>)?.Clear();
} }
public static void SetAvatarTPose()
{
IKSystem.Instance.SetAvatarPose(IKSystem.AvatarPose.TPose);
PlayerSetup.Instance._avatar.transform.localPosition = Vector3.zero;
PlayerSetup.Instance._avatar.transform.localRotation = Quaternion.identity;
}
} }
} }

View file

@ -26,9 +26,9 @@ namespace ml_vei
static MelonLoader.MelonPreferences_Category ms_category = null; static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null; static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
static public event Action<bool> GesturesChange; public static event Action<bool> GesturesChange;
static public event Action<bool> GripTriggerChange; public static event Action<bool> GripTriggerChange;
static public event Action<PriorityAxis> AxisPriorityChange; public static event Action<PriorityAxis> AxisPriorityChange;
internal static void Init() internal static void Init()
{ {

View file

@ -7,6 +7,6 @@ namespace ml_vei
{ {
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance); static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script); public static void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);
} }
} }