mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
Added PlantFeet & EnforceViewPosition Settings.
This commit is contained in:
parent
55a3009f96
commit
65896d5f14
3 changed files with 48 additions and 3 deletions
|
@ -15,20 +15,35 @@ public class DesktopVRIK : MonoBehaviour
|
||||||
|
|
||||||
public bool Setting_Enabled;
|
public bool Setting_Enabled;
|
||||||
public bool Setting_EmulateVRChatHipMovement;
|
public bool Setting_EmulateVRChatHipMovement;
|
||||||
|
public bool Setting_EnforceViewPosition;
|
||||||
public bool Setting_EmoteVRIK;
|
public bool Setting_EmoteVRIK;
|
||||||
public bool Setting_EmoteLookAtIK;
|
public bool Setting_EmoteLookAtIK;
|
||||||
|
public bool Setting_PlantFeet;
|
||||||
|
|
||||||
|
public Transform viewpoint;
|
||||||
|
public Vector3 initialCamPos;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeViewpointHandling(bool enabled)
|
||||||
|
{
|
||||||
|
Setting_EnforceViewPosition = enabled;
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
PlayerSetup.Instance.desktopCamera.transform.localPosition = Vector3.zero;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PlayerSetup.Instance.desktopCamera.transform.localPosition = initialCamPos;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnPreSolverUpdate()
|
public void OnPreSolverUpdate()
|
||||||
{
|
{
|
||||||
//Reset avatar offset (VRIK will literally make you walk away from root otherwise)
|
//Reset avatar offset (VRIK will literally make you walk away from root otherwise)
|
||||||
IKSystem.vrik.transform.localPosition = Vector3.zero;
|
IKSystem.vrik.transform.localPosition = Vector3.zero;
|
||||||
IKSystem.vrik.transform.localRotation = Quaternion.identity;
|
IKSystem.vrik.transform.localRotation = Quaternion.identity;
|
||||||
|
|
||||||
//VRChat hip movement emulation
|
//VRChat hip movement emulation
|
||||||
if (Setting_EmulateVRChatHipMovement)
|
if (Setting_EmulateVRChatHipMovement)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +53,7 @@ public class DesktopVRIK : MonoBehaviour
|
||||||
Quaternion rotation = Quaternion.AngleAxis(angle * weight, IKSystem.Instance.avatar.transform.right);
|
Quaternion rotation = Quaternion.AngleAxis(angle * weight, IKSystem.Instance.avatar.transform.right);
|
||||||
IKSystem.vrik.solver.AddRotationOffset(IKSolverVR.RotationOffset.Head, rotation);
|
IKSystem.vrik.solver.AddRotationOffset(IKSolverVR.RotationOffset.Head, rotation);
|
||||||
}
|
}
|
||||||
|
IKSystem.vrik.solver.plantFeet = Setting_PlantFeet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CalibrateDesktopVRIK(CVRAvatar avatar)
|
public void CalibrateDesktopVRIK(CVRAvatar avatar)
|
||||||
|
@ -63,8 +79,14 @@ public class DesktopVRIK : MonoBehaviour
|
||||||
|
|
||||||
//ChilloutVR specific stuff
|
//ChilloutVR specific stuff
|
||||||
|
|
||||||
|
//Find eyeoffset
|
||||||
|
initialCamPos = PlayerSetup.Instance.desktopCamera.transform.localPosition;
|
||||||
|
Transform headTransform = IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Head);
|
||||||
|
viewpoint = headTransform.Find("LocalHeadPoint");
|
||||||
|
ChangeViewpointHandling(Setting_EnforceViewPosition);
|
||||||
|
|
||||||
//centerEyeAnchor now is head bone
|
//centerEyeAnchor now is head bone
|
||||||
Transform headAnchor = FindIKTarget(IKSystem.Instance.animator.GetBoneTransform(HumanBodyBones.Head));
|
Transform headAnchor = FindIKTarget(headTransform);
|
||||||
IKSystem.Instance.headAnchorPositionOffset = Vector3.zero;
|
IKSystem.Instance.headAnchorPositionOffset = Vector3.zero;
|
||||||
IKSystem.Instance.headAnchorRotationOffset = Vector3.zero;
|
IKSystem.Instance.headAnchorRotationOffset = Vector3.zero;
|
||||||
IKSystem.Instance.ApplyAvatarScaleToIk(avatar.viewPosition.y);
|
IKSystem.Instance.ApplyAvatarScaleToIk(avatar.viewPosition.y);
|
||||||
|
|
|
@ -3,6 +3,8 @@ using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Core.Savior;
|
using ABI_RC.Core.Savior;
|
||||||
using ABI_RC.Systems.IK;
|
using ABI_RC.Systems.IK;
|
||||||
using ABI_RC.Systems.IK.SubSystems;
|
using ABI_RC.Systems.IK.SubSystems;
|
||||||
|
using ABI_RC.Systems.MovementSystem;
|
||||||
|
using ABI_RC.Core.Player.AvatarTracking.Local;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using RootMotion.FinalIK;
|
using RootMotion.FinalIK;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -88,4 +90,21 @@ internal class HarmonyPatches
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(PlayerSetup), "HandleDesktopCameraPosition")]
|
||||||
|
private static void Postfix_PlayerSetup_HandleDesktopCameraPosition(bool ignore, ref PlayerSetup __instance, ref MovementSystem ____movementSystem, ref int ___headBobbingLevel)
|
||||||
|
{
|
||||||
|
if (DesktopVRIK.Instance.Setting_EnforceViewPosition)
|
||||||
|
{
|
||||||
|
if (!____movementSystem.disableCameraControl || ignore)
|
||||||
|
{
|
||||||
|
if (___headBobbingLevel == 2 && DesktopVRIK.Instance.viewpoint != null)
|
||||||
|
{
|
||||||
|
__instance.desktopCamera.transform.localPosition = Vector3.zero;
|
||||||
|
__instance.desktopCameraRig.transform.position = DesktopVRIK.Instance.viewpoint.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -7,14 +7,16 @@ public class DesktopVRIKMod : MelonMod
|
||||||
{
|
{
|
||||||
internal const string SettingsCategory = "DesktopVRIK";
|
internal const string SettingsCategory = "DesktopVRIK";
|
||||||
private static MelonPreferences_Category m_categoryDesktopVRIK;
|
private static MelonPreferences_Category m_categoryDesktopVRIK;
|
||||||
private static MelonPreferences_Entry<bool> m_entryEnabled, m_entryEmulateHipMovement, m_entryEmoteVRIK, m_entryEmoteLookAtIK;
|
private static MelonPreferences_Entry<bool> m_entryEnabled, m_entryEmulateHipMovement, m_entryEnforceViewPosition, m_entryEmoteVRIK, m_entryEmoteLookAtIK, m_entryPlantFeet;
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory);
|
m_categoryDesktopVRIK = MelonPreferences.CreateCategory(SettingsCategory);
|
||||||
m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Attempt to give Desktop VRIK on avatar load.");
|
m_entryEnabled = m_categoryDesktopVRIK.CreateEntry<bool>("Enabled", true, description: "Attempt to give Desktop VRIK on avatar load.");
|
||||||
m_entryEmulateHipMovement = m_categoryDesktopVRIK.CreateEntry<bool>("Emulate Hip Movement", true, description: "Emulates VRChat-like hip movement when moving head up/down on desktop.");
|
m_entryEmulateHipMovement = m_categoryDesktopVRIK.CreateEntry<bool>("Emulate Hip Movement", true, description: "Emulates VRChat-like hip movement when moving head up/down on desktop.");
|
||||||
|
m_entryEnforceViewPosition = m_categoryDesktopVRIK.CreateEntry<bool>("Enforce View Position", false, description: "Corrects view position to use VRIK offsets.");
|
||||||
m_entryEmoteVRIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote VRIK", true, description: "Disable VRIK while emoting. Only disable if you are ok with looking dumb.");
|
m_entryEmoteVRIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote VRIK", true, description: "Disable VRIK while emoting. Only disable if you are ok with looking dumb.");
|
||||||
m_entryEmoteLookAtIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote LookAtIK", true, description: "Disable LookAtIK while emoting. This setting doesn't really matter, as LookAtIK isn't networked while doing an emote.");
|
m_entryEmoteLookAtIK = m_categoryDesktopVRIK.CreateEntry<bool>("Disable Emote LookAtIK", true, description: "Disable LookAtIK while emoting. This setting doesn't really matter, as LookAtIK isn't networked while doing an emote.");
|
||||||
|
m_entryPlantFeet = m_categoryDesktopVRIK.CreateEntry<bool>("Plant Feet", true, description: "Enables Plant Feet for VRIK while in Desktop. Keeps avatar on ground when entering Idle instead of hovering.");
|
||||||
|
|
||||||
foreach (var setting in m_categoryDesktopVRIK.Entries)
|
foreach (var setting in m_categoryDesktopVRIK.Entries)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +43,8 @@ public class DesktopVRIKMod : MelonMod
|
||||||
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value;
|
DesktopVRIK.Instance.Setting_EmulateVRChatHipMovement = m_entryEmulateHipMovement.Value;
|
||||||
DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
|
DesktopVRIK.Instance.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
|
||||||
DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
|
DesktopVRIK.Instance.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
|
||||||
|
DesktopVRIK.Instance.Setting_PlantFeet = m_entryPlantFeet.Value;
|
||||||
|
DesktopVRIK.Instance.ChangeViewpointHandling(m_entryEnforceViewPosition.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
|
private void OnUpdateSettings(object arg1, object arg2) => UpdateAllSettings();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue