Exemple #1
0
        public override void OnApplicationStart()
        {
            DependenciesHandler.ExtractDependencies();
            // DependenciesHandler.LoadDependencies(); // DllImport above load them fine somehow

            MelonLoader.MelonPreferences.CreateCategory("LME", "Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "Enabled", false, "Enable Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "VR", false, "Enable HMD mode for Leap Motion");
            MelonLoader.MelonPreferences.CreateEntry("LME", "SDK3", false, "Send SDK3 parameters");
            MelonLoader.MelonPreferences.CreateEntry("LME", "HeadRoot", false, "Use head as root point");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetY", c_defaultRootOffsetY, "Avatar root point offset for Y axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetZ", c_defaultRootOffsetZ, "Avatar root point offset for Z axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "FingersOnly", false, "Fingers tracking only");

            ms_inVrMode = VRCTrackingManager.Method_Public_Static_Boolean_5();

            m_fingersBends    = new float[10];
            m_fingersBendsPtr = GCHandle.Alloc(m_fingersBends, GCHandleType.Pinned);

            m_fingersSpreads    = new float[10];
            m_fingersSpreadsPtr = GCHandle.Alloc(m_fingersSpreads, GCHandleType.Pinned);

            m_handsPresent    = new bool[2];
            m_handsPresentPtr = GCHandle.Alloc(m_handsPresent, GCHandleType.Pinned);

            m_handPositions    = new float[6];
            m_handPositionsPtr = GCHandle.Alloc(m_handPositions, GCHandleType.Pinned);

            m_handRotations    = new float[8];
            m_handRotationsPtr = GCHandle.Alloc(m_handRotations, GCHandleType.Pinned);

            // Patches
            var l_patchMethod = new Harmony.HarmonyMethod(typeof(LeapMotionExtention), "VRCIM_ControllersType");

            typeof(VRCInputManager).GetMethods().Where(x =>
                                                       x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_")
                                                       ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod));

            OnPreferencesSaved();
        }
Exemple #2
0
        public override void OnApplicationStart()
        {
            DependenciesHandler.ExtractDependencies();

            MelonLoader.MelonPreferences.CreateCategory("LME", "Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "Enabled", false, "Enable Leap Motion extension");
            MelonLoader.MelonPreferences.CreateEntry("LME", "VR", false, "Enable HMD mode for Leap Motion");
            MelonLoader.MelonPreferences.CreateEntry("LME", "SDK3", false, "Send SDK3 parameters");
            MelonLoader.MelonPreferences.CreateEntry("LME", "HeadRoot", false, "Use head as root point");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetY", c_defaultRootOffsetY, "Avatar root point offset for Y axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetZ", c_defaultRootOffsetZ, "Avatar root point offset for Z axis");
            MelonLoader.MelonPreferences.CreateEntry("LME", "FingersOnly", false, "Fingers tracking only");

            m_leapController = new Leap.Controller();
            m_gesturesData   = new GestureMatcher.GesturesData();

            // Methods search
            m_heightMethod = MethodsResolver.GetHeightMethod();
            if (m_heightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_heightMethod.Name + " -> VRCTrackingManager.GetPlayerHeight");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve height method, fallback to zero float");
                m_heightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_eyeHeightMethod = MethodsResolver.GetEyeHeightMethod();
            if (m_eyeHeightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_eyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (Desktop)");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve eye height method for desktop, fallback to zero float");
                m_eyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_vrEyeHeightMethod = MethodsResolver.GetVREyeHeightMethod();
            if (m_vrEyeHeightMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrEyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (VR)");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve eye height method for VR, fallback to zero float");
                m_vrEyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat));
            }

            m_vrCheckMethod = MethodsResolver.GetVRCheckMethod();
            if (m_vrCheckMethod != null)
            {
                MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrCheckMethod.Name + " -> VRCTrackingManager.IsInVRMode");
            }
            else
            {
                MelonLoader.MelonLogger.Warning("Can't resolve vr check method, fallback to false boolean");
                m_vrCheckMethod = typeof(LeapMotionExtention).GetMethod(nameof(FalseBoolean));
            }

            // Patches
            var l_patchMethod = new Harmony.HarmonyMethod(typeof(LeapMotionExtention), nameof(VRCIM_ControllersType));

            typeof(VRCInputManager).GetMethods().Where(x =>
                                                       x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_")
                                                       ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod));

            OnPreferencesSaved();
        }
Exemple #3
0
        public override void OnApplicationStart()
        {
            m_fingersBends   = new float[10];
            m_fingersSpreads = new float[10];

            // Patches
            var l_patchMethod = new Harmony.HarmonyMethod(typeof(MainClass), "VRCIM_ControllersType");

            typeof(VRCInputManager).GetMethods().Where(x =>
                                                       x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_")
                                                       ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod));


            iconsAssetBundle            = AssetBundle.LoadFromMemory_Internal(VRCBonesController.Properties.Resources.customicons, 0);
            iconsAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;


            radialIcon             = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Icons/sound-full.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
            radialIcon.hideFlags  |= HideFlags.DontUnloadUnusedAsset;
            toggleIcon             = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Icons/zero.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
            toggleIcon.hideFlags  |= HideFlags.DontUnloadUnusedAsset;
            subMenuIcon            = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Icons/file-transfer.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
            subMenuIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            buttonIcon             = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Icons/cloud-data-download.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
            buttonIcon.hideFlags  |= HideFlags.DontUnloadUnusedAsset;

            try
            {
                AMUtils.AddToModsFolder(
                    "BonesController",
                    delegate
                {
                    /*CustomSubMenu.AddButton("ShowBones", delegate ()
                     * {
                     *  foreach(var plr in UnityEngine.Object.FindObjectsOfType<VRCPlayer>())
                     *  {
                     *      var obj = plr.gameObject.GetComponent<ShowBones>();
                     *      if (obj != null)
                     *          UnityEngine.Object.Destroy(obj);
                     *      else
                     *          plr.gameObject.AddComponent<ShowBones>().InitForPlayer(plr);
                     *  }
                     * });*/
                    CustomSubMenu.AddSubMenu("Hands", delegate()
                    {
                        CustomSubMenu.AddSubMenu("Right", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeRightHandPos, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control forward/backwards", ChangeRightHandFB, radialIcon, false, "Forward", "", "Backwards", "");
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                rightHandPosition = new Vector3(-120f, 390f, 65.6f);
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Both", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeBothHandsPos, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control forward/backwards", ChangeBothHandsFB, radialIcon, false, "Forward", "", "Backwards", "");
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                leftHandPosition  = new Vector3(120f, 390f, 65.6f);
                                rightHandPosition = new Vector3(-120f, 390f, 65.6f);
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Left", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeLeftHandPos, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control forward/backwards", ChangeLeftHandFB, radialIcon, false, "Forward", "", "Backwards", "");
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                leftHandPosition = new Vector3(120f, 390f, 65.6f);
                            });
                        }, radialIcon);
                    }, radialIcon);
                    CustomSubMenu.AddSubMenu("Legs", delegate()
                    {
                        CustomSubMenu.AddSubMenu("Right", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control bends", ChangeRightLegBends, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeRightLegPos, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                l_solver.rightLeg.IKPosition = l_solver.headPosition;
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Both", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control bends", ChangeBothLegsBends, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeBothLegsPos, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                l_solver.rightLeg.IKPosition = l_solver.headPosition;
                                l_solver.leftLeg.IKPosition  = l_solver.headPosition;
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Left", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control bends", ChangeLeftLegBends, radialIcon);
                            CustomSubMenu.AddFourAxisPuppet("Control pos", ChangeLeftLegPos, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                l_solver.rightLeg.IKPosition = l_solver.headPosition;
                            });
                        }, radialIcon);
                    }, radialIcon);
                    CustomSubMenu.AddSubMenu("Fingers", delegate()
                    {
                        CustomSubMenu.AddSubMenu("Right", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control", ChangeFingersRight, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                ResetFingers();
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Both", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control", ChangeFingersBoth, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                ResetFingers();
                            });
                        }, radialIcon);
                        CustomSubMenu.AddSubMenu("Left", delegate()
                        {
                            CustomSubMenu.AddFourAxisPuppet("Control", ChangeFingersLeft, radialIcon);
                            CustomSubMenu.AddButton("Reset", delegate()
                            {
                                ResetFingers();
                            });
                        }, radialIcon);
                    }, radialIcon);
                    AMAPI.AddTogglePedalToSubMenu("Enable control", false, ChangeControlState, radialIcon);
                    //CustomSubMenu.AddFourAxisPuppet("Head", ChangeHeadRot, radialIcon);
                },
                    subMenuIcon
                    );
            }catch (Exception)
            {
                MelonLogger.Msg("Failed to load ActionMenuAPI, not installed.");
            }



            OnPreferencesSaved();
        }