From 06dc5cec08198e5d9f810ad1d2f4885c0bf11e9b Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Sat, 14 Jan 2023 01:30:29 -0600 Subject: [PATCH] quickly add custom IKPose animation support --- .../BTKUI_Integration/BTKUI_Integration.cs | 4 +- DesktopVRIK/DesktopVRIK.cs | 41 +++++++++---------- DesktopVRIK/HarmonyPatches.cs | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/DesktopVRIK/BTKUI_Integration/BTKUI_Integration.cs b/DesktopVRIK/BTKUI_Integration/BTKUI_Integration.cs index c0b9b1c..a752328 100644 --- a/DesktopVRIK/BTKUI_Integration/BTKUI_Integration.cs +++ b/DesktopVRIK/BTKUI_Integration/BTKUI_Integration.cs @@ -1,6 +1,6 @@ -using System.Runtime.CompilerServices; -using BTKUILib; +using BTKUILib; using BTKUILib.UIObjects; +using System.Runtime.CompilerServices; namespace NAK.Melons.DesktopVRIK.BTKUI_Integration; diff --git a/DesktopVRIK/DesktopVRIK.cs b/DesktopVRIK/DesktopVRIK.cs index f00ad95..9af0386 100644 --- a/DesktopVRIK/DesktopVRIK.cs +++ b/DesktopVRIK/DesktopVRIK.cs @@ -31,7 +31,7 @@ public class DesktopVRIK : MonoBehaviour // create the shared Head IK Target headIKTarget = new GameObject("[DesktopVRIK] Head IK Target").transform; headIKTarget.parent = PlayerSetup.Instance.transform; - headIKTarget.localPosition = new Vector3(0f,1.8f,0f); + headIKTarget.localPosition = new Vector3(0f, 1.8f, 0f); headIKTarget.localRotation = Quaternion.identity; } @@ -88,18 +88,17 @@ public class DesktopVRIK : MonoBehaviour //avatar.transform.rotation = Quaternion.identity; //ikpose layer (specified by avatar author) - //int? ikposeLayerIndex = PlayerSetup.Instance.animatorManager.GetAnimatorLayerIndex("IKPose"); - //int? locoLayerIndex = PlayerSetup.Instance.animatorManager.GetAnimatorLayerIndex("Locomotion/Emotes"); - - //if (ikposeLayerIndex != -1) - //{ - // PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 1f); - // if (locoLayerIndex != -1) - // { - // PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 0f); - // } - // IKSystem.Instance.animator.Update(0f); - //} + int ikposeLayerIndex = animator.GetLayerIndex("IKPose"); + int locoLayerIndex = animator.GetLayerIndex("Locomotion/Emotes"); + if (ikposeLayerIndex != -1) + { + animator.SetLayerWeight(ikposeLayerIndex, 1f); + if (locoLayerIndex != -1) + { + animator.SetLayerWeight(locoLayerIndex, 0f); + } + animator.Update(0f); + } //Generic VRIK calibration shit VRIK vrik = avatar.gameObject.AddComponent(); @@ -149,14 +148,14 @@ public class DesktopVRIK : MonoBehaviour vrik.solver.SetToReferences(vrik.references); vrik.solver.Initiate(vrik.transform); - //if (ikposeLayerIndex != -1) - //{ - // PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 0f); - // if (locoLayerIndex != -1) - // { - // PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 1f); - // } - //} + if (ikposeLayerIndex != -1) + { + animator.SetLayerWeight(ikposeLayerIndex, 0f); + if (locoLayerIndex != -1) + { + animator.SetLayerWeight(locoLayerIndex, 1f); + } + } //Find eyeoffset initialCamPos = PlayerSetup.Instance.desktopCamera.transform.localPosition; diff --git a/DesktopVRIK/HarmonyPatches.cs b/DesktopVRIK/HarmonyPatches.cs index 9d8c7b2..9a00ec2 100644 --- a/DesktopVRIK/HarmonyPatches.cs +++ b/DesktopVRIK/HarmonyPatches.cs @@ -117,7 +117,7 @@ class IKSystemPatches IKSystem.Instance.ApplyMuscleValue((MuscleIndex)i, IKPoseMuscles[i], ref ___humanPose.muscles); } ____poseHandler.SetHumanPose(ref ___humanPose); - + ____vrik = DesktopVRIK.Instance.AlternativeCalibration(avatar); IKSystem.Instance.ApplyAvatarScaleToIk(avatar.viewPosition.y); }