mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
a
This commit is contained in:
parent
997d1d8d41
commit
6433dd7c78
7 changed files with 25 additions and 145 deletions
|
@ -1,95 +0,0 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
/*
|
||||
|
||||
Kindly stolen from SDraw's leap motion mod. (MIT)
|
||||
https://github.com/SDraw/ml_mods_cvr/blob/master/ml_lme/AssetsHandler.cs
|
||||
|
||||
*thank u sdraw, i wont be murderer now*
|
||||
|
||||
*/
|
||||
|
||||
namespace NAK.Melons.DesktopVRIK;
|
||||
|
||||
static class AssetsHandler
|
||||
{
|
||||
static readonly List<string> ms_assets = new List<string>()
|
||||
{
|
||||
"IKPose.assetbundle"
|
||||
};
|
||||
|
||||
static Dictionary<string, AssetBundle> ms_loadedAssets = new Dictionary<string, AssetBundle>();
|
||||
static Dictionary<string, Object> ms_loadedObjects = new Dictionary<string, Object>();
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
Assembly l_assembly = Assembly.GetExecutingAssembly();
|
||||
string l_assemblyName = l_assembly.GetName().Name;
|
||||
|
||||
foreach (string l_assetName in ms_assets)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stream l_assetStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + l_assetName);
|
||||
if (l_assetStream != null)
|
||||
{
|
||||
MemoryStream l_memorySteam = new MemoryStream((int)l_assetStream.Length);
|
||||
l_assetStream.CopyTo(l_memorySteam);
|
||||
AssetBundle l_assetBundle = AssetBundle.LoadFromMemory(l_memorySteam.ToArray(), 0);
|
||||
if (l_assetBundle != null)
|
||||
{
|
||||
l_assetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
ms_loadedAssets.Add(l_assetName, l_assetBundle);
|
||||
}
|
||||
else
|
||||
MelonLoader.MelonLogger.Warning("Unable to load bundled '" + l_assetName + "' asset");
|
||||
}
|
||||
else
|
||||
MelonLoader.MelonLogger.Warning("Unable to get bundled '" + l_assetName + "' asset stream");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Warning("Unable to load bundled '" + l_assetName + "' asset, reason: " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object GetAsset(string p_name)
|
||||
{
|
||||
Object l_result = null;
|
||||
if (ms_loadedObjects.ContainsKey(p_name))
|
||||
{
|
||||
l_result = UnityEngine.Object.Instantiate(ms_loadedObjects[p_name]);
|
||||
//l_result.SetActive(true);
|
||||
l_result.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var l_pair in ms_loadedAssets)
|
||||
{
|
||||
if (l_pair.Value.Contains(p_name))
|
||||
{
|
||||
Object l_bundledObject = (Object)l_pair.Value.LoadAsset(p_name, typeof(Object));
|
||||
if (l_bundledObject != null)
|
||||
{
|
||||
ms_loadedObjects.Add(p_name, l_bundledObject);
|
||||
l_result = UnityEngine.Object.Instantiate(l_bundledObject);
|
||||
//l_result.SetActive(true);
|
||||
l_result.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return l_result;
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
foreach (var l_pair in ms_loadedAssets)
|
||||
UnityEngine.Object.Destroy(l_pair.Value);
|
||||
ms_loadedAssets.Clear();
|
||||
}
|
||||
}
|
|
@ -16,9 +16,7 @@ public class DesktopVRIK : MonoBehaviour
|
|||
public static bool Setting_Enabled,
|
||||
Setting_EnforceViewPosition,
|
||||
Setting_EmoteVRIK,
|
||||
Setting_EmoteLookAtIK,
|
||||
Setting_AllowRootSlipping,
|
||||
Setting_TestIKPoseController;
|
||||
Setting_EmoteLookAtIK;
|
||||
public static float Setting_EmulateVRChatHipMovementWeight;
|
||||
|
||||
public Transform viewpoint;
|
||||
|
@ -27,12 +25,9 @@ public class DesktopVRIK : MonoBehaviour
|
|||
Transform headIKTarget;
|
||||
Transform avatarHeadBone;
|
||||
|
||||
RuntimeAnimatorController ikposeController;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Instance = this;
|
||||
ikposeController = (RuntimeAnimatorController)AssetsHandler.GetAsset("Assets/BundledAssets/IKPose/IKPose.controller");
|
||||
// create the shared Head IK Target
|
||||
headIKTarget = new GameObject("[DesktopVRIK] Head IK Target").transform;
|
||||
headIKTarget.parent = PlayerSetup.Instance.transform;
|
||||
|
@ -61,12 +56,9 @@ public class DesktopVRIK : MonoBehaviour
|
|||
headIKTarget.position = new Vector3(headIKTarget.position.x, avatarHeadBone.position.y, headIKTarget.position.z);
|
||||
}
|
||||
|
||||
if (!Setting_AllowRootSlipping)
|
||||
{
|
||||
//Reset avatar offset (VRIK will literally make you walk away from root otherwise)
|
||||
IKSystem.vrik.transform.localPosition = Vector3.zero;
|
||||
IKSystem.vrik.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
//Reset avatar offset (VRIK will literally make you walk away from root otherwise)
|
||||
IKSystem.vrik.transform.localPosition = Vector3.zero;
|
||||
IKSystem.vrik.transform.localRotation = Quaternion.identity;
|
||||
|
||||
//VRChat hip movement emulation
|
||||
if (Setting_EmulateVRChatHipMovementWeight != 0)
|
||||
|
@ -96,18 +88,18 @@ 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");
|
||||
//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);
|
||||
}
|
||||
//if (ikposeLayerIndex != -1)
|
||||
//{
|
||||
// PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 1f);
|
||||
// if (locoLayerIndex != -1)
|
||||
// {
|
||||
// PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 0f);
|
||||
// }
|
||||
// IKSystem.Instance.animator.Update(0f);
|
||||
//}
|
||||
|
||||
//Generic VRIK calibration shit
|
||||
VRIK vrik = avatar.gameObject.AddComponent<VRIK>();
|
||||
|
@ -157,20 +149,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 (Setting_TestIKPoseController)
|
||||
{
|
||||
animator.enabled = false;
|
||||
return vrik;
|
||||
}
|
||||
//if (ikposeLayerIndex != -1)
|
||||
//{
|
||||
// PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("IKPose", 0f);
|
||||
// if (locoLayerIndex != -1)
|
||||
// {
|
||||
// PlayerSetup.Instance.animatorManager.SetAnimatorLayerWeight("Locomotion/Emotes", 1f);
|
||||
// }
|
||||
//}
|
||||
|
||||
//Find eyeoffset
|
||||
initialCamPos = PlayerSetup.Instance.desktopCamera.transform.localPosition;
|
||||
|
|
|
@ -8,14 +8,6 @@
|
|||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="resources\IKPose.assetbundle" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="resources\IKPose.assetbundle" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ public class DesktopVRIKMod : MelonMod
|
|||
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_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_entryAllowRootSlipping = m_categoryDesktopVRIK.CreateEntry<bool>("Allow Root Slipping", false, description: "Allows avatar root to slip out from under itself, to emulate more wacky VRChat behavior.");
|
||||
|
||||
foreach (var setting in m_categoryDesktopVRIK.Entries)
|
||||
{
|
||||
|
@ -45,7 +44,6 @@ public class DesktopVRIKMod : MelonMod
|
|||
|
||||
System.Collections.IEnumerator WaitForLocalPlayer()
|
||||
{
|
||||
AssetsHandler.Load();
|
||||
while (PlayerSetup.Instance == null)
|
||||
yield return null;
|
||||
PlayerSetup.Instance.gameObject.AddComponent<DesktopVRIK>();
|
||||
|
@ -61,7 +59,6 @@ public class DesktopVRIKMod : MelonMod
|
|||
DesktopVRIK.Setting_EmulateVRChatHipMovementWeight = Mathf.Clamp01(m_entryEmulateVRChatHipMovementWeight.Value);
|
||||
DesktopVRIK.Setting_EmoteVRIK = m_entryEmoteVRIK.Value;
|
||||
DesktopVRIK.Setting_EmoteLookAtIK = m_entryEmoteLookAtIK.Value;
|
||||
DesktopVRIK.Setting_AllowRootSlipping = m_entryAllowRootSlipping.Value;
|
||||
DesktopVRIK.Instance.ChangeViewpointHandling(m_entryEnforceViewPosition.Value);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/DesktopVRIK/releases/download/v2.0.0/DesktopVRIK.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/DesktopVRIK/",
|
||||
"changelog": "- Simplified VRIK calibration to avoid low heel issue.\n- Removed rushed compatibility mode.\n- Added checks for valid Humanoid rigs.\n- Added PlantFeet & EnforceViewPosition Settings.\n- Added Weight option for the VRChat-like hip movement.\n- Simplified config, added BTKUILib support.\n- Reworked calibration to support almost every avatar.\n- Added custom avatar-defined IKPose support.",
|
||||
"changelog": "- Simplified VRIK calibration to avoid low heel issue.\n- Added checks for valid Humanoid rigs.\n- Added PlantFeet & EnforceViewPosition Settings.\n- Added Weight option for the VRChat-like hip movement.\n- Simplified config, added BTKUILib support.\n- Reworked calibration to support almost every avatar.",
|
||||
"embedcolor": "9b59b6"
|
||||
}
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue