mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Merge branch 'master' into experimental
This commit is contained in:
commit
3c33452379
30 changed files with 271 additions and 547 deletions
|
@ -54,6 +54,7 @@ namespace ml_lme
|
|||
m_handRayRight.isInteractionRay = true;
|
||||
m_handRayRight.triggerGazeEvents = false;
|
||||
m_handRayRight.holderRoot = m_handRayRight.gameObject;
|
||||
m_handRayLeft.attachmentDistance = 0f;
|
||||
|
||||
m_lineLeft = m_handRayLeft.gameObject.AddComponent<LineRenderer>();
|
||||
m_lineLeft.endWidth = 1f;
|
||||
|
@ -66,6 +67,7 @@ namespace ml_lme
|
|||
m_lineLeft.enabled = false;
|
||||
m_lineLeft.receiveShadows = false;
|
||||
m_handRayLeft.lineRenderer = m_lineLeft;
|
||||
m_handRayRight.attachmentDistance = 0f;
|
||||
|
||||
m_lineRight = m_handRayRight.gameObject.AddComponent<LineRenderer>();
|
||||
m_lineRight.endWidth = 1f;
|
||||
|
@ -81,9 +83,11 @@ namespace ml_lme
|
|||
|
||||
Settings.EnabledChange += this.OnEnableChange;
|
||||
Settings.InputChange += this.OnInputChange;
|
||||
Settings.GesturesChange += this.OnGesturesChange;
|
||||
|
||||
OnEnableChange(Settings.Enabled);
|
||||
OnInputChange(Settings.Input);
|
||||
OnGesturesChange(Settings.Gestures);
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForSettings());
|
||||
MelonLoader.MelonCoroutines.Start(WaitForMaterial());
|
||||
|
@ -132,6 +136,8 @@ namespace ml_lme
|
|||
{
|
||||
ResetFingers(true);
|
||||
m_handVisibleLeft = false;
|
||||
if(Settings.Gestures)
|
||||
ResetGestures(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,6 +152,8 @@ namespace ml_lme
|
|||
{
|
||||
ResetFingers(false);
|
||||
m_handVisibleRight = false;
|
||||
if(Settings.Gestures)
|
||||
ResetGestures(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,10 +178,10 @@ namespace ml_lme
|
|||
|
||||
public override void Update_Interaction()
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if(Settings.Input)
|
||||
{
|
||||
GestureMatcher.LeapData l_data = LeapManager.Instance.GetLatestData();
|
||||
|
||||
if(l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly))
|
||||
{
|
||||
float l_strength = l_data.m_leftHand.m_grabStrength;
|
||||
|
@ -230,6 +238,99 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Settings.Gestures)
|
||||
{
|
||||
// Left hand gestures
|
||||
if(l_data.m_leftHand.m_present)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = 0f;
|
||||
|
||||
// Finger Point & Finger Gun
|
||||
if(_inputManager.fingerCurlLeftIndex < 0.2f && _inputManager.fingerCurlLeftMiddle > 0.75f &&
|
||||
_inputManager.fingerCurlLeftRing > 0.75f && _inputManager.fingerCurlLeftPinky > 0.75f)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = _inputManager.fingerCurlLeftThumb >= 0.5f ? 4f : 3f;
|
||||
}
|
||||
|
||||
// Peace Sign
|
||||
if(_inputManager.fingerCurlLeftIndex < 0.2f && _inputManager.fingerCurlLeftMiddle < 0.2f &&
|
||||
_inputManager.fingerCurlLeftRing > 0.75f && _inputManager.fingerCurlLeftPinky > 0.75f)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = 5f;
|
||||
}
|
||||
|
||||
// Rock and Roll
|
||||
if(_inputManager.fingerCurlLeftIndex < 0.2f && _inputManager.fingerCurlLeftMiddle > 0.75f &&
|
||||
_inputManager.fingerCurlLeftRing > 0.75f && _inputManager.fingerCurlLeftPinky < 0.5f)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = 6f;
|
||||
}
|
||||
|
||||
// Fist & Thumbs Up
|
||||
if(_inputManager.fingerCurlLeftIndex > 0.5f && _inputManager.fingerCurlLeftMiddle > 0.5f &&
|
||||
_inputManager.fingerCurlLeftRing > 0.5f && _inputManager.fingerCurlLeftPinky > 0.5f)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = _inputManager.fingerCurlLeftThumb >= 0.5f
|
||||
? (l_data.m_rightHand.m_grabStrength - 0.5f) * 2f
|
||||
: 2f;
|
||||
}
|
||||
|
||||
// Open Hand
|
||||
if(_inputManager.fingerCurlLeftIndex < 0.2f && _inputManager.fingerCurlLeftMiddle < 0.2f &&
|
||||
_inputManager.fingerCurlLeftRing < 0.2f && _inputManager.fingerCurlLeftPinky < 0.2f)
|
||||
{
|
||||
_inputManager.gestureLeftRaw = -1f;
|
||||
}
|
||||
|
||||
_inputManager.gestureLeft = _inputManager.gestureLeftRaw;
|
||||
}
|
||||
|
||||
// Right hand gestures
|
||||
if(l_data.m_rightHand.m_present)
|
||||
{
|
||||
_inputManager.gestureRightRaw = 0f;
|
||||
|
||||
// Finger Point & Finger Gun
|
||||
if(_inputManager.fingerCurlRightIndex < 0.2f && _inputManager.fingerCurlRightMiddle > 0.75f &&
|
||||
_inputManager.fingerCurlRightRing > 0.75f && _inputManager.fingerCurlRightPinky > 0.75f)
|
||||
{
|
||||
_inputManager.gestureRightRaw = _inputManager.fingerCurlRightThumb >= 0.5f ? 4f : 3f;
|
||||
}
|
||||
|
||||
// Peace Sign
|
||||
if(_inputManager.fingerCurlRightIndex < 0.2f && _inputManager.fingerCurlRightMiddle < 0.2f &&
|
||||
_inputManager.fingerCurlRightRing > 0.75f && _inputManager.fingerCurlRightPinky > 0.75f)
|
||||
{
|
||||
_inputManager.gestureRightRaw = 5f;
|
||||
}
|
||||
|
||||
// Rock and Roll
|
||||
if(_inputManager.fingerCurlRightIndex < 0.2f && _inputManager.fingerCurlRightMiddle > 0.75f &&
|
||||
_inputManager.fingerCurlRightRing > 0.75f && _inputManager.fingerCurlRightPinky < 0.5f)
|
||||
{
|
||||
_inputManager.gestureRightRaw = 6f;
|
||||
}
|
||||
|
||||
// Fist & Thumbs Up
|
||||
if(_inputManager.fingerCurlRightIndex > 0.5f && _inputManager.fingerCurlRightMiddle > 0.5f &&
|
||||
_inputManager.fingerCurlRightRing > 0.5f && _inputManager.fingerCurlRightPinky > 0.5f)
|
||||
{
|
||||
_inputManager.gestureRightRaw = _inputManager.fingerCurlRightThumb >= 0.5f
|
||||
? (l_data.m_rightHand.m_grabStrength - 0.5f) * 2f
|
||||
: 2f;
|
||||
}
|
||||
|
||||
// Open Hand
|
||||
if(_inputManager.fingerCurlRightIndex < 0.2f && _inputManager.fingerCurlRightMiddle < 0.2f &&
|
||||
_inputManager.fingerCurlRightRing < 0.2f && _inputManager.fingerCurlRightPinky < 0.2f)
|
||||
{
|
||||
_inputManager.gestureRightRaw = -1f;
|
||||
}
|
||||
|
||||
_inputManager.gestureRight = _inputManager.gestureRightRaw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings changes
|
||||
|
@ -265,6 +366,14 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
void OnGesturesChange(bool p_state)
|
||||
{
|
||||
_inputManager.gestureLeft = 0f;
|
||||
_inputManager.gestureLeftRaw = 0f;
|
||||
_inputManager.gestureRight = 0f;
|
||||
_inputManager.gestureRightRaw = 0f;
|
||||
}
|
||||
|
||||
// Game events
|
||||
internal void OnAvatarSetup()
|
||||
{
|
||||
|
@ -351,6 +460,20 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
void ResetGestures(bool p_left)
|
||||
{
|
||||
if(p_left)
|
||||
{
|
||||
_inputManager.gestureLeft = 0f;
|
||||
_inputManager.gestureLeftRaw = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_inputManager.gestureRight = 0f;
|
||||
_inputManager.gestureRightRaw = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Game settings
|
||||
void OnGameSettingBoolChange(string p_name, bool p_state)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.3.7", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_lme.LeapMotionExtension), "LeapMotionExtension", "1.4.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonOptionalDependencies("ml_pmc")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
|
|
|
@ -22,5 +22,6 @@ Available mod's settings in `Settings - Implementation - Leap Motion Tracking`:
|
|||
* **Fingers tracking only:** applies only fingers tracking, disabled by default.
|
||||
* **Model visibility:** shows Leap Motion controller model, useful for tracking visualizing, disabled by default.
|
||||
* **Interaction input:** enables in-game interactions (props, menu and etc.); `true` by default.
|
||||
* **Recognize gestures:** sets avatar gestures (fist, gun, rock'n'roll and etc.) based on current fingers pose; `false` by default.
|
||||
* **Interact gesture threadhold:** activation limit for interaction based on hand gesture; 80 by default.
|
||||
* **Grip gesture threadhold:** activation limit for grip based on hand gesture; 40 by default.
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace ml_lme
|
|||
HeadZ,
|
||||
TrackElbows,
|
||||
Input,
|
||||
Gestures,
|
||||
InteractThreadhold,
|
||||
GripThreadhold,
|
||||
VisualHands
|
||||
|
@ -48,6 +49,7 @@ namespace ml_lme
|
|||
public static Vector3 HeadOffset { get; private set; } = new Vector3(0f, -0.3f, 0.15f);
|
||||
public static bool TrackElbows { get; private set; } = true;
|
||||
public static bool Input { get; private set; } = true;
|
||||
public static bool Gestures { get; private set; } = false;
|
||||
public static float InteractThreadhold { get; private set; } = 0.8f;
|
||||
public static float GripThreadhold { get; private set; } = 0.4f;
|
||||
public static bool VisualHands { get; private set; } = false;
|
||||
|
@ -65,6 +67,7 @@ namespace ml_lme
|
|||
static public event Action<Vector3> HeadOffsetChange;
|
||||
static public event Action<bool> TrackElbowsChange;
|
||||
static public event Action<bool> InputChange;
|
||||
static public event Action<bool> GesturesChange;
|
||||
static public event Action<float> InteractThreadholdChange;
|
||||
static public event Action<float> GripThreadholdChange;
|
||||
static public event Action<bool> VisualHandsChange;
|
||||
|
@ -91,6 +94,7 @@ namespace ml_lme
|
|||
ms_category.CreateEntry(ModSetting.HeadZ.ToString(), (int)(HeadOffset.z * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.TrackElbows.ToString(), TrackElbows),
|
||||
ms_category.CreateEntry(ModSetting.Input.ToString(), Input),
|
||||
ms_category.CreateEntry(ModSetting.Gestures.ToString(), Gestures),
|
||||
ms_category.CreateEntry(ModSetting.InteractThreadhold.ToString(), (int)(InteractThreadhold * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.GripThreadhold.ToString(), (int)(GripThreadhold * 100f)),
|
||||
ms_category.CreateEntry(ModSetting.VisualHands.ToString(), VisualHands)
|
||||
|
@ -148,6 +152,7 @@ namespace ml_lme
|
|||
) * 0.01f;
|
||||
TrackElbows = (bool)ms_entries[(int)ModSetting.TrackElbows].BoxedValue;
|
||||
Input = (bool)ms_entries[(int)ModSetting.Input].BoxedValue;
|
||||
Gestures = (bool)ms_entries[(int)ModSetting.Gestures].BoxedValue;
|
||||
InteractThreadhold = (int)ms_entries[(int)ModSetting.InteractThreadhold].BoxedValue * 0.01f;
|
||||
GripThreadhold = (int)ms_entries[(int)ModSetting.GripThreadhold].BoxedValue * 0.01f;
|
||||
VisualHands = (bool)ms_entries[(int)ModSetting.VisualHands].BoxedValue;
|
||||
|
@ -201,6 +206,13 @@ namespace ml_lme
|
|||
}
|
||||
break;
|
||||
|
||||
case ModSetting.Gestures:
|
||||
{
|
||||
Gestures = bool.Parse(p_value);
|
||||
GesturesChange?.Invoke(Gestures);
|
||||
}
|
||||
break;
|
||||
|
||||
case ModSetting.VisualHands:
|
||||
{
|
||||
VisualHands = bool.Parse(p_value);
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace ml_lme
|
|||
{
|
||||
static class Utils
|
||||
{
|
||||
static FieldInfo ms_cohtmlView = typeof(CohtmlControlledViewDisposable).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded);
|
||||
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 IsLeftHandTracked() => (CVRInputManager.Instance._leftController != ABI_RC.Systems.InputManagement.XR.EXRControllerType.None);
|
||||
|
@ -33,8 +31,6 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
public static void ExecuteScript(this CohtmlControlledViewDisposable p_instance, string p_script) => ((cohtml.Net.View)ms_cohtmlView.GetValue(p_instance))?.ExecuteScript(p_script);
|
||||
|
||||
public static void Swap<T>(ref T lhs, ref T rhs)
|
||||
{
|
||||
T temp = lhs;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<PackageId>LeapMotionExtension</PackageId>
|
||||
<Version>1.3.8</Version>
|
||||
<Version>1.4.0</Version>
|
||||
<Authors>SDraw</Authors>
|
||||
<Company>None</Company>
|
||||
<Product>LeapMotionExtension</Product>
|
||||
|
|
|
@ -399,6 +399,13 @@ function inp_dropdown_mod_lme(_obj, _callbackName) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Recognize Gestures: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Gestures" class ="inp_toggle no-scroll" data-current="false"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Interact gesture threadhold: </div>
|
||||
<div class ="option-input">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue