mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Separated eyes tracking and blinking
This commit is contained in:
parent
15a750c036
commit
39c65774df
7 changed files with 82 additions and 13 deletions
|
@ -5,7 +5,7 @@ Merged set of MelonLoader mods for ChilloutVR.
|
|||
|-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------|
|
||||
| Avatar Change Info | ml_aci | 1.0.3 | Yes | Working |
|
||||
| Avatar Motion Tweaker | ml_amt | 1.1.8 | Yes, pending update | Working |
|
||||
| Desktop Head Tracking | ml_dht | 1.0.7 | Yes | Working |
|
||||
| Desktop Head Tracking | ml_dht | 1.0.9 | Yes, pending update | Working |
|
||||
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
|
||||
| Four Point Tracking | ml_fpt | 1.0.9 | Yes | Working |
|
||||
| Leap Motion Extension | ml_lme | 1.2.6 | Yes, pending update | Working |
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using RootMotion.FinalIK;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using ViveSR.anipal.Lip;
|
||||
|
@ -12,12 +13,14 @@ namespace ml_dht
|
|||
static FieldInfo ms_emotePlaying = typeof(PlayerSetup).GetField("_emotePlaying", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
bool m_enabled = false;
|
||||
bool m_blinking = true;
|
||||
bool m_eyeTracking = true;
|
||||
float m_smoothing = 0.5f;
|
||||
bool m_mirrored = false;
|
||||
bool m_faceOverride = true;
|
||||
|
||||
CVRAvatar m_avatarDescriptor = null;
|
||||
RootMotion.FinalIK.LookAtIK m_lookIK = null;
|
||||
LookAtIK m_lookIK = null;
|
||||
Transform m_camera = null;
|
||||
Transform m_headBone = null;
|
||||
|
||||
|
@ -36,6 +39,8 @@ namespace ml_dht
|
|||
m_camera = PlayerSetup.Instance.desktopCamera.transform;
|
||||
|
||||
Settings.EnabledChange += this.SetEnabled;
|
||||
Settings.EyeTrackingChange += this.SetEyeTracking;
|
||||
Settings.BlinkingChange += this.SetBlinking;
|
||||
Settings.SmoothingChange += this.SetSmoothing;
|
||||
Settings.MirroredChange += this.SetMirrored;
|
||||
Settings.FaceOverrideChange += this.SetFaceOverride;
|
||||
|
@ -44,6 +49,8 @@ namespace ml_dht
|
|||
void OnDestroy()
|
||||
{
|
||||
Settings.EnabledChange -= this.SetEnabled;
|
||||
Settings.EyeTrackingChange -= this.SetEyeTracking;
|
||||
Settings.BlinkingChange -= this.SetBlinking;
|
||||
Settings.SmoothingChange -= this.SetSmoothing;
|
||||
Settings.MirroredChange -= this.SetMirrored;
|
||||
Settings.FaceOverrideChange -= this.SetFaceOverride;
|
||||
|
@ -75,12 +82,18 @@ namespace ml_dht
|
|||
if(m_enabled)
|
||||
{
|
||||
// Gaze
|
||||
p_component.manualViewTarget = true;
|
||||
p_component.targetViewPosition = m_camera.position + m_camera.rotation * new Vector3((m_gazeDirection.x - 0.5f) * -2f, (m_gazeDirection.y - 0.5f) * 2f, 1f);
|
||||
if(m_eyeTracking)
|
||||
{
|
||||
p_component.manualViewTarget = true;
|
||||
p_component.targetViewPosition = m_camera.position + m_camera.rotation * new Vector3((m_gazeDirection.x - 0.5f) * -2f, (m_gazeDirection.y - 0.5f) * 2f, 1f);
|
||||
}
|
||||
|
||||
// Blink
|
||||
p_component.manualBlinking = true;
|
||||
p_component.blinkProgress = m_blinkProgress;
|
||||
if(m_blinking)
|
||||
{
|
||||
p_component.manualBlinking = true;
|
||||
p_component.blinkProgress = m_blinkProgress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +119,7 @@ namespace ml_dht
|
|||
{
|
||||
m_avatarDescriptor = PlayerSetup.Instance._avatar.GetComponent<CVRAvatar>();
|
||||
m_headBone = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.Head);
|
||||
m_lookIK = PlayerSetup.Instance._avatar.GetComponent<RootMotion.FinalIK.LookAtIK>();
|
||||
m_lookIK = PlayerSetup.Instance._avatar.GetComponent<LookAtIK>();
|
||||
|
||||
if(m_headBone != null)
|
||||
m_bindRotation = (m_avatarDescriptor.transform.GetMatrix().inverse * m_headBone.GetMatrix()).rotation;
|
||||
|
@ -133,6 +146,14 @@ namespace ml_dht
|
|||
m_lastHeadRotation = ((m_headBone != null) ? m_headBone.rotation : m_bindRotation);
|
||||
}
|
||||
}
|
||||
public void SetEyeTracking(bool p_state)
|
||||
{
|
||||
m_eyeTracking = p_state;
|
||||
}
|
||||
public void SetBlinking(bool p_state)
|
||||
{
|
||||
m_blinking = p_state;
|
||||
}
|
||||
public void SetSmoothing(float p_value)
|
||||
{
|
||||
m_smoothing = 1f - Mathf.Clamp(p_value, 0f, 0.99f);
|
||||
|
|
|
@ -58,6 +58,8 @@ namespace ml_dht
|
|||
|
||||
m_localTracked = PlayerSetup.Instance.gameObject.AddComponent<HeadTracked>();
|
||||
m_localTracked.SetEnabled(Settings.Enabled);
|
||||
m_localTracked.SetEyeTracking(Settings.EyeTracking);
|
||||
m_localTracked.SetBlinking(Settings.Blinking);
|
||||
m_localTracked.SetMirrored(Settings.Mirrored);
|
||||
m_localTracked.SetSmoothing(Settings.Smoothing);
|
||||
m_localTracked.SetFaceOverride(Settings.FaceOverride);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("DesktopHeadTracking")]
|
||||
[assembly: AssemblyVersion("1.0.7")]
|
||||
[assembly: AssemblyFileVersion("1.0.7")]
|
||||
[assembly: AssemblyVersion("1.0.9")]
|
||||
[assembly: AssemblyFileVersion("1.0.9")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_dht.DesktopHeadTracking), "DesktopHeadTracking", "1.0.7", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_dht.DesktopHeadTracking), "DesktopHeadTracking", "1.0.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
|
@ -18,9 +18,11 @@ Refer to `TrackingData.cs` for reference in case of implementing own software.
|
|||
# Usage
|
||||
Available mod's settings in `Settings - Implementation - Desktop Head Tracking`:
|
||||
* **Enabled:** enabled head tracking; default value - `false`.
|
||||
* **Use eyes tracking:** uses eyes tracking from data; default value - `true`.
|
||||
* **Use blinking:** uses blinking from data; default value - `true`.
|
||||
* **Mirrored movement:** mirrors movement and gaze along 0YZ plane; default value - `false`.
|
||||
* **Movement smoothing:** smoothing factor between new and old movement data; default value - `50`.
|
||||
* **Override face tracking:** Overrides and activates avatar's `VRC Face Tracking` components. List of used shapes: `Jaw_Open`, `Mouth_Pout`, `Mouth_Smile_Left`, `Mouth_Smile_Right`; default value - `true`.
|
||||
* **Override face tracking:** overrides and activates avatar's `VRC Face Tracking` components. List of used shapes: `Jaw_Open`, `Mouth_Pout`, `Mouth_Smile_Left`, `Mouth_Smile_Right`; default value - `true`.
|
||||
|
||||
# Known compatible tracking software
|
||||
* [VSeeFace](https://www.vseeface.icu) with [Tracking Data Parser mod](https://github.com/SDraw/ml_mods_vsf)
|
||||
|
|
|
@ -10,12 +10,16 @@ namespace ml_dht
|
|||
enum ModSetting
|
||||
{
|
||||
Enabled = 0,
|
||||
EyeTracking,
|
||||
Blinking,
|
||||
Mirrored,
|
||||
Smoothing,
|
||||
FaceOverride
|
||||
}
|
||||
|
||||
static bool ms_enabled = false;
|
||||
static bool ms_eyeTracking = true;
|
||||
static bool ms_blinking = true;
|
||||
static bool ms_mirrored = false;
|
||||
static float ms_smoothing = 0.5f;
|
||||
static bool ms_faceOverride = true;
|
||||
|
@ -24,6 +28,8 @@ namespace ml_dht
|
|||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
||||
static public event Action<bool> EnabledChange;
|
||||
static public event Action<bool> EyeTrackingChange;
|
||||
static public event Action<bool> BlinkingChange;
|
||||
static public event Action<bool> MirroredChange;
|
||||
static public event Action<float> SmoothingChange;
|
||||
static public event Action<bool> FaceOverrideChange;
|
||||
|
@ -34,6 +40,8 @@ namespace ml_dht
|
|||
|
||||
ms_entries = new List<MelonLoader.MelonPreferences_Entry>();
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Enabled.ToString(), false));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.EyeTracking.ToString(), true));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Blinking.ToString(), true));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Mirrored.ToString(), false));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.Smoothing.ToString(), 50));
|
||||
ms_entries.Add(ms_category.CreateEntry(ModSetting.FaceOverride.ToString(), true));
|
||||
|
@ -68,6 +76,8 @@ namespace ml_dht
|
|||
static void Load()
|
||||
{
|
||||
ms_enabled = (bool)ms_entries[(int)ModSetting.Enabled].BoxedValue;
|
||||
ms_eyeTracking = (bool)ms_entries[(int)ModSetting.EyeTracking].BoxedValue;
|
||||
ms_blinking = (bool)ms_entries[(int)ModSetting.Blinking].BoxedValue;
|
||||
ms_mirrored = (bool)ms_entries[(int)ModSetting.Mirrored].BoxedValue;
|
||||
ms_smoothing = ((int)ms_entries[(int)ModSetting.Smoothing].BoxedValue) * 0.01f;
|
||||
ms_faceOverride = (bool)ms_entries[(int)ModSetting.FaceOverride].BoxedValue;
|
||||
|
@ -104,6 +114,18 @@ namespace ml_dht
|
|||
}
|
||||
break;
|
||||
|
||||
case ModSetting.EyeTracking:
|
||||
{
|
||||
ms_eyeTracking = bool.Parse(p_value);
|
||||
EyeTrackingChange?.Invoke(ms_eyeTracking);
|
||||
} break;
|
||||
|
||||
case ModSetting.Blinking:
|
||||
{
|
||||
ms_blinking = bool.Parse(p_value);
|
||||
BlinkingChange?.Invoke(ms_blinking);
|
||||
} break;
|
||||
|
||||
case ModSetting.Mirrored:
|
||||
{
|
||||
ms_mirrored = bool.Parse(p_value);
|
||||
|
@ -126,6 +148,14 @@ namespace ml_dht
|
|||
{
|
||||
get => ms_enabled;
|
||||
}
|
||||
public static bool EyeTracking
|
||||
{
|
||||
get => ms_eyeTracking;
|
||||
}
|
||||
public static bool Blinking
|
||||
{
|
||||
get => ms_blinking;
|
||||
}
|
||||
public static bool Mirrored
|
||||
{
|
||||
get => ms_mirrored;
|
||||
|
|
|
@ -187,6 +187,20 @@ function inp_toggle_mod_dht(_obj, _callbackName) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Use eyes tracking: </div>
|
||||
<div class ="option-input">
|
||||
<div id="EyeTracking" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Use blinking: </div>
|
||||
<div class ="option-input">
|
||||
<div id="Blinking" class ="inp_toggle no-scroll" data-current="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class ="row-wrapper">
|
||||
<div class ="option-caption">Mirrored movement: </div>
|
||||
<div class ="option-input">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue