mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Consideration of Index controllers
Hud notifications
This commit is contained in:
parent
e87dfee1fe
commit
2a7e796862
5 changed files with 83 additions and 35 deletions
|
@ -13,8 +13,8 @@ namespace ml_lme_cvr
|
|||
Transform m_leftHand = null;
|
||||
Transform m_rightHand = null;
|
||||
|
||||
float m_leftHandWeight = 1f;
|
||||
float m_rightHandWeight = 1f;
|
||||
float m_leftHandWeight = 0f;
|
||||
float m_rightHandWeight = 0f;
|
||||
|
||||
bool m_leftHandVisible = false;
|
||||
bool m_rightHandVisible = false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme_cvr
|
||||
|
@ -19,19 +20,30 @@ namespace ml_lme_cvr
|
|||
Transform m_leftHand = null;
|
||||
Transform m_rightHand = null;
|
||||
|
||||
bool m_knucklesInUse = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_indexIK = this.GetComponent<ABI_RC.Core.Player.IndexIK>();
|
||||
m_indexIK = this.GetComponent<IndexIK>();
|
||||
m_knucklesInUse = PlayerSetup.Instance._trackerManager.trackerNames.Contains("knuckles");
|
||||
|
||||
if((m_indexIK != null) && (m_animator != null))
|
||||
{
|
||||
m_indexIK.avatarAnimator = m_animator;
|
||||
m_indexIK.Recalibrate();
|
||||
|
||||
m_indexIK.activeControl = m_enabled;
|
||||
CVRInputManager.Instance.individualFingerTracking = m_enabled;
|
||||
|
||||
if(!PlayerSetup.Instance._inVr)
|
||||
{
|
||||
// Seems that VR mode always calibrates IndexIK, so let's force it
|
||||
m_indexIK.avatarAnimator = m_animator;
|
||||
m_indexIK.Recalibrate();
|
||||
}
|
||||
m_calibrated = true;
|
||||
|
||||
m_indexIK.activeControl = (m_enabled || m_knucklesInUse);
|
||||
CVRInputManager.Instance.individualFingerTracking = (m_enabled || m_knucklesInUse);
|
||||
|
||||
m_leapIK = m_animator.gameObject.AddComponent<LeapIK>();
|
||||
m_leapIK.SetEnabled(m_enabled);
|
||||
m_leapIK.SetFingersOnly(m_fingersOnly);
|
||||
m_leapIK.SetHands(m_leftHand, m_rightHand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +55,7 @@ namespace ml_lme_cvr
|
|||
if((m_animator != null) && (m_indexIK != null))
|
||||
{
|
||||
m_indexIK.activeControl = true;
|
||||
if(!m_calibrated)
|
||||
if(!m_calibrated && !PlayerSetup.Instance._inVr)
|
||||
{
|
||||
m_indexIK.avatarAnimator = m_animator;
|
||||
m_indexIK.Recalibrate();
|
||||
|
@ -56,8 +68,8 @@ namespace ml_lme_cvr
|
|||
{
|
||||
if((m_indexIK != null) && m_calibrated)
|
||||
{
|
||||
m_indexIK.activeControl = false;
|
||||
CVRInputManager.Instance.individualFingerTracking = false;
|
||||
m_indexIK.activeControl = m_knucklesInUse;
|
||||
CVRInputManager.Instance.individualFingerTracking = m_knucklesInUse;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,15 +77,7 @@ namespace ml_lme_cvr
|
|||
m_leapIK.SetEnabled(m_enabled);
|
||||
}
|
||||
|
||||
public void SetAnimator(Animator p_animator)
|
||||
{
|
||||
m_animator = p_animator;
|
||||
|
||||
m_leapIK = m_animator.gameObject.AddComponent<LeapIK>();
|
||||
m_leapIK.SetEnabled(m_enabled);
|
||||
m_leapIK.SetFingersOnly(m_fingersOnly);
|
||||
m_leapIK.SetHands(m_leftHand, m_rightHand);
|
||||
}
|
||||
public void SetAnimator(Animator p_animator) => m_animator = p_animator;
|
||||
|
||||
public void SetFingersOnly(bool p_state)
|
||||
{
|
||||
|
@ -87,9 +91,6 @@ namespace ml_lme_cvr
|
|||
{
|
||||
m_leftHand = p_left;
|
||||
m_rightHand = p_right;
|
||||
|
||||
if(m_leapIK != null)
|
||||
m_leapIK.SetHands(p_left, p_right);
|
||||
}
|
||||
|
||||
public void UpdateTracking(GestureMatcher.GesturesData p_gesturesData)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_lme_cvr
|
||||
|
@ -35,8 +36,13 @@ namespace ml_lme_cvr
|
|||
Settings.HeadOffsetChange += this.OnSettingsHeadOffsetChange;
|
||||
|
||||
m_leapController = new Leap.Controller();
|
||||
m_gesturesData = new GestureMatcher.GesturesData();
|
||||
m_leapController.Device += this.OnLeapDeviceInitialized;
|
||||
m_leapController.DeviceFailure += this.OnLeapDeviceFailure;
|
||||
m_leapController.DeviceLost += this.OnLeapDeviceLost;
|
||||
m_leapController.Connect += this.OnLeapServiceConnect;
|
||||
m_leapController.Disconnect += this.OnLeapServiceDisconnect;
|
||||
|
||||
m_gesturesData = new GestureMatcher.GesturesData();
|
||||
m_leapHands = new GameObject[GestureMatcher.GesturesData.ms_handsCount];
|
||||
|
||||
// Patches
|
||||
|
@ -113,6 +119,11 @@ namespace ml_lme_cvr
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < GestureMatcher.GesturesData.ms_handsCount; i++)
|
||||
m_gesturesData.m_handsPresenses[i] = false;
|
||||
}
|
||||
|
||||
if(m_leapTracked != null)
|
||||
m_leapTracked.UpdateTracking(m_gesturesData);
|
||||
|
@ -232,13 +243,51 @@ namespace ml_lme_cvr
|
|||
}
|
||||
}
|
||||
|
||||
// Leap events
|
||||
void OnLeapDeviceInitialized(object p_sender, Leap.DeviceEventArgs p_args)
|
||||
{
|
||||
if(Settings.Enabled && (m_leapController != null))
|
||||
{
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_SCREENTOP);
|
||||
if(Settings.HmdMode)
|
||||
m_leapController.SetPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
else
|
||||
m_leapController.ClearPolicy(Leap.Controller.PolicyFlag.POLICY_OPTIMIZE_HMD);
|
||||
}
|
||||
|
||||
if(CohtmlHud.Instance != null)
|
||||
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device initialized");
|
||||
}
|
||||
|
||||
void OnLeapDeviceFailure(object p_sender, Leap.DeviceFailureEventArgs p_args)
|
||||
{
|
||||
if(CohtmlHud.Instance != null)
|
||||
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device failure, code " + p_args.ErrorCode + ": " + p_args.ErrorMessage);
|
||||
}
|
||||
|
||||
void OnLeapDeviceLost(object p_sender, Leap.DeviceEventArgs p_args)
|
||||
{
|
||||
if(CohtmlHud.Instance != null)
|
||||
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Device lost");
|
||||
}
|
||||
|
||||
void OnLeapServiceConnect(object p_sender, Leap.ConnectionEventArgs p_args)
|
||||
{
|
||||
if(CohtmlHud.Instance != null)
|
||||
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Service connected");
|
||||
}
|
||||
|
||||
void OnLeapServiceDisconnect(object p_sender, Leap.ConnectionLostEventArgs p_args)
|
||||
{
|
||||
if(CohtmlHud.Instance != null)
|
||||
CohtmlHud.Instance.ViewDropText("Leap Motion Extension", "Service disconnected");
|
||||
}
|
||||
|
||||
// Patches
|
||||
static void OnAvatarSetup(ref PlayerSetup __instance)
|
||||
{
|
||||
if(__instance != null && __instance == PlayerSetup.Instance)
|
||||
{
|
||||
if((__instance != null) && (__instance == PlayerSetup.Instance))
|
||||
ms_instance?.OnLocalPlayerAvatarSetup(__instance._animator, __instance.GetComponent<IndexIK>());
|
||||
}
|
||||
}
|
||||
void OnLocalPlayerAvatarSetup(Animator p_animator, IndexIK p_indexIK)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("LeapMotionExtension")]
|
||||
[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.1")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.0", "SDraw", "https://github.com/SDraw")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme_cvr.LeapMotionExtension), "LeapMotionExtension", "1.0.1", "SDraw", "https://github.com/SDraw")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace ml_lme_cvr
|
|||
static bool ms_hmdMode = false;
|
||||
static float ms_rootAngle = 0f;
|
||||
static bool ms_headAttach = false;
|
||||
static Vector3 ms_headOffset = new Vector3(0f, 0f, 0f);
|
||||
static Vector3 ms_headOffset = new Vector3(0f, -0.3f, 0.15f);
|
||||
|
||||
static bool ms_initialized = false;
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace ml_lme_cvr
|
|||
|
||||
static void BeforeSettingsLoad(ref CVRSettings __instance)
|
||||
{
|
||||
if(!ms_initialized && __instance != null)
|
||||
if(!ms_initialized && (__instance != null))
|
||||
{
|
||||
var l_settings = HarmonyLib.Traverse.Create(__instance)?.Field("_settings")?.GetValue<System.Collections.Generic.List<ABI_RC.Core.Savior.CVRSettingsValue>>();
|
||||
if(l_settings != null)
|
||||
|
@ -72,8 +72,6 @@ namespace ml_lme_cvr
|
|||
l_settings.Add(new CVRSettingsInt(ms_defaultSettings[11], 0));
|
||||
}
|
||||
|
||||
// Changes events
|
||||
|
||||
// Enable tracking
|
||||
__instance.settingBoolChanged.AddListener((name, value) =>
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue