コード例 #1
0
ファイル: VRPatcher.cs プロジェクト: zhisenyang/HS2VR
 public static void syncPOVXCamera()
 {
     handlePOVXStatus();
     if (povEnabledValue && !POVPaused)
     {
         VRPatcher.SyncToMainTransform(Camera.main.transform, positionOnly: false, adjustHead: true);
     }
 }
コード例 #2
0
ファイル: VRLoader.cs プロジェクト: OrangeSpork/HS2VR
        /// <summary>
        /// VRデバイスのロード。
        /// </summary>
        IEnumerator LoadDevice(string newDevice)
        {
            bool vrMode = newDevice != DeviceNone;

            // 指定されたデバイスの読み込み.
            UnityEngine.XR.XRSettings.LoadDeviceByName(newDevice);
            // 次のフレームまで待つ.
            yield return(null);

            // VRモードを有効にする.
            UnityEngine.XR.XRSettings.enabled = vrMode;
            // 次のフレームまで待つ.
            yield return(null);

            // デバイスの読み込みが完了するまで待つ.
            while (UnityEngine.XR.XRSettings.loadedDeviceName != newDevice || UnityEngine.XR.XRSettings.enabled != vrMode)
            {
                yield return(null);
            }


            //UnityEngine.XR.XRSettings.gameViewRenderMode = UnityEngine.XR.GameViewRenderMode.BothEyes;

            List <UnityEngine.XR.XRNodeState> states = new List <UnityEngine.XR.XRNodeState>();

            UnityEngine.XR.InputTracking.GetNodeStates(states);
            foreach (UnityEngine.XR.XRNodeState state in states)
            {
                string  name    = UnityEngine.XR.InputTracking.GetNodeName(state.uniqueID);
                Vector3 pos     = new Vector3();
                bool    got_pos = state.TryGetPosition(out pos);
                VRLog.Info("XRNode {0}, position available {1} {2}", name, got_pos, pos);
            }

            if (vrMode)
            {
                VRPatcher.Patch();

                // Boot VRManager!
                // Note: Use your own implementation of GameInterpreter to gain access to a few useful operatoins
                // (e.g. characters, camera judging, colliders, etc.)
                VRManager.Create <HS2Interpreter>(CreateContext("VRContext.xml"));
                if (((HS2VRSettings)VR.Settings).DefaultMode.Equals("Seated"))
                {
                    VR.Manager.SetMode <GenericSeatedMode>();
                }
                else
                {
                    VR.Manager.SetMode <GenericStandingMode>();
                }

                if (((HS2VRSettings)VR.Settings).PrivacyMode.Equals(true))
                {
                    PrivacyMode.Enable();
                }
            }
        }
コード例 #3
0
        public static void SpecialTreatmentManagerSetCameraAndCharaPositionPostfix(Camera ___cam, Manager.SpecialTreatmentRoomManager __instance)
        {
            VRLog.Info("Setting VR Camera to game camera (Special TreatmentRoom SetCameraPosition)");

            if (__instance.ConciergeHeroine != null)
            {
                AdjustForFOVDifference(___cam.transform, __instance.ConciergeHeroine.transform, TITLE_FOV, GetVRFOV(), TITLE_DISTANCE_ADJ_RATIO, true);
            }

            VRPatcher.MoveVRCameraToTarget(___cam.transform);
        }
コード例 #4
0
        public static void LobbySceneManagerSetCameraAndCharaPositionPostfix(Camera ___cam, LobbySceneManager __instance)
        {
            VRLog.Info("Setting VR Camera to game camera (Lobby SetCamChar)");

            if (__instance.heroines != null && __instance.heroines[0] != null)
            {
                AdjustForFOVDifference(___cam.transform, __instance.heroines[0].transform, LOBBY_FOV, GetVRFOV(), LOBBY_DISTANCE_ADJ_RATIO, true);
            }

            VRPatcher.MoveVRCameraToTarget(___cam.transform);
        }
コード例 #5
0
 public static void CharaCustomStartPostfix(CustomControl ___customCtrl)
 {
     VRLog.Info("Setting VR Camera to game camera");
     if (VRManager.Instance.Mode.GetType().Equals(typeof(GenericSeatedMode)))
     {
         VRPatcher.MoveVRCameraToTarget(___customCtrl.camCtrl.transform, false);
     }
     else
     {
         VRPatcher.MoveVRCameraToMainCamera(false);
     }
 }
コード例 #6
0
        public static void CameraControlV2(CameraControl_Ver2 __instance)
        {
            if (povEnabledValue)
            {
                return;
            }

            if (VRManager.Instance.Mode.GetType().Equals(typeof(GenericSeatedMode)))
            {
                VRPatcher.SyncToMainTransform(__instance.transform, false);
            }
        }
コード例 #7
0
 public void Update()
 {
     VRPatcher.handlePOVXStatus();
     if (VR_ACTIVATED && Application.productName == "StudioNEOV2" && Studio.Studio.Instance.ociCamera != null)
     {
         VRPatcher.SyncToMainTransform(Studio.Studio.Instance.ociCamera.objectItem.transform, false);
     }
     else if (VR_ACTIVATED && Application.productName == "StudioNEOV2" && VRManager.Instance.Mode.GetType().Equals(typeof(GenericSeatedMode)))
     {
         if (!VRPatcher.povEnabledValue)
         {
             VRPatcher.SyncToMainTransform(Studio.Studio.Instance.cameraCtrl.transform, false);
         }
     }
 }
コード例 #8
0
        public static void ADVSceneSetCameraPostfix(ADVScene __instance, TextScenario ___scenario)
        {
            VRLog.Info("Setting VR Camera to game camera (ADV SET CAM)");

            foreach (ADV.CharaData chara in ___scenario.commandController.Characters.Values)
            {
                if (chara.heroine != null)
                {
                    VRLog.Info($"Adjusting towards: {chara.heroine.chaFile.parameter.fullname}");
                    AdjustForFOVDifference(__instance.advCamera.transform, chara.heroine.transform, TITLE_FOV, GetVRFOV(), LOBBY_DISTANCE_ADJ_RATIO);
                }
            }

            VRPatcher.MoveVRCameraToTarget(__instance.advCamera.transform, false);
        }
コード例 #9
0
        public static void GlobalMethodloadResetCamerayPostfix(CameraControl_Ver2 _ctrl)
        {
            ChaControl heroine = HSceneManager.Instance?.females?[0];

            if (heroine != null)
            {
                VRLog.Info($"Adjusting towards: {heroine.chaFile.parameter.fullname}");
                float moveDistance = AdjustForFOVDifference(_ctrl.transform, heroine.transform, TITLE_FOV, GetVRFOV(), LOBBY_DISTANCE_ADJ_RATIO, true);
                _ctrl.TargetPos = _ctrl.transform.InverseTransformPoint(_ctrl.transform.position);
                _ctrl.CameraDir = Vector3.MoveTowards(_ctrl.CameraDir, _ctrl.TargetPos, moveDistance);
            }

            VRLog.Info("Setting VR Camera to game camera");
            VRPatcher.MoveVRCameraToMainCamera();
        }
コード例 #10
0
ファイル: POVTool.cs プロジェクト: zhisenyang/HS2VR
        protected override void OnUpdate()
        {
            base.OnUpdate();

            /*          foreach(Valve.VR.EVRButtonId eVRButton in Enum.GetValues(typeof(Valve.VR.EVRButtonId)))
             *        {
             *            if (Controller.GetPressDown(eVRButton))
             *            {
             *                VRLog.Info($"Button: {eVRButton.ToString()}");
             *            }
             *        } */
            if (Controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                triggerStartTime = Time.unscaledTime;
            }
            if (Controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_Dashboard_Back))
            {
                VRPatcher.POVEnabledKeypress();
            }
            if (Controller.GetPress(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                if (VRPatcher.povEnabledValue && Time.unscaledTime - triggerStartTime > 1.5f)
                {
                    Owner.StartRumble(new RumbleImpulse(800));
                }
            }
            if (Controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger))
            {
                if (VRPatcher.povEnabledValue && Time.unscaledTime - triggerStartTime > 1.5f)
                {
                    VRPatcher.POVPaused = !VRPatcher.POVPaused;
                    triggerStartTime    = 0f;
                }
                else if (!VRPatcher.povEnabledValue)
                {
                    VRPatcher.POVEnabledKeypress();
                }
                else
                {
                    VRPatcher.CharaCycleKeyPress();
                    triggerStartTime = 0f;
                }
            }
            if (Controller.GetPressUp(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                VRPatcher.LockOnCyclePress();
            }
        }
コード例 #11
0
 public static void syncPOVXCamera()
 {
     if (mPositionChangeResetPov)
     {
         mPositionChangeResetPov = false;
         POVPaused = !POVPaused;
         syncPOVXCamera();
         POVPaused = !POVPaused;
         return;
     }
     handlePOVXStatus();
     if (povEnabledValue && !POVPaused)
     {
         VRPatcher.SyncToMainTransform(Camera.main.transform, positionOnly: false, adjustHead: true);
     }
 }
コード例 #12
0
        public static void TitleSceneSetPositionPostfix(ref Camera ___mainCamera, Heroine ___heroine)
        {
            if (VRManager.Instance.Mode.GetType().Equals(typeof(GenericSeatedMode)))
            {
                ((GenericSeatedMode)VRManager.Instance.Mode).Recenter();
            }
            VRLog.Info("Setting VR Camera to game camera (Title SetPOS)");
            //VRPatcher.MoveVRCameraToMainCamera();

            if (___heroine != null)
            {
                AdjustForFOVDifference(___mainCamera.transform, ___heroine.transform, TITLE_FOV, GetVRFOV(), TITLE_DISTANCE_ADJ_RATIO);
            }

            VRPatcher.MoveVRCameraToTarget(___mainCamera.transform);
        }
コード例 #13
0
        public static void TextScenarioRequestNextLine(TextScenario __instance, int ___currentLine)
        {
            Command command = __instance.CommandPacks[___currentLine].Command;

            VRLog.Info($"Executing Command Line: (CommandList Add - {command} {string.Join(",", __instance.CommandPacks[___currentLine].Args)} {__instance.advScene.advCamera.transform.position}");

            if (command == Command.NullSet)
            {
                if (__instance.CommandPacks[___currentLine].Args[1].Equals("Camera"))
                {
                    string     camEventName = __instance.CommandPacks[___currentLine].Args[0];
                    GameObject camGO        = GameObject.Find(camEventName);
                    Transform  camTransform = camGO == null ? __instance.advScene.advCamera.transform : camGO.transform;
                    VRLog.Info($"Looking for GO {camEventName} Found: {camGO}");

                    foreach (ADV.CharaData chara in __instance.commandController.Characters.Values)
                    {
                        if (chara.heroine != null)
                        {
                            VRLog.Info($"Adjusting towards: {chara.heroine.chaFile.parameter.fullname}");
                            AdjustForFOVDifference(camTransform, chara.heroine.transform, TITLE_FOV, GetVRFOV(), TITLE_DISTANCE_ADJ_RATIO);
                        }
                    }
                    VRLog.Info($"Setting VR Camera to game camera (CommandList Add) {camTransform}");
                    VRPatcher.MoveVRCameraToTarget(camTransform, false);
                }
            }
            else if (command == Command.CameraPositionSet)
            {
                foreach (ADV.CharaData chara in __instance.commandController.Characters.Values)
                {
                    if (chara.heroine != null)
                    {
                        VRLog.Info($"Adjusting towards: {chara.heroine.chaFile.parameter.fullname}");
                        AdjustForFOVDifference(__instance.advScene.advCamera.transform, chara.heroine.transform, TITLE_FOV, GetVRFOV(), TITLE_DISTANCE_ADJ_RATIO);
                    }
                }
                VRLog.Info($"Setting VR Camera to game camera (CommandList Add) {__instance.advScene.advCamera.transform.position}");
                VRPatcher.MoveVRCameraToTarget(__instance.advScene.advCamera.transform, false);
            }
        }
コード例 #14
0
 public static bool EyeLookControllerLateUpdate(EyeLookController __instance)
 {
     VRPatcher.MoveMainCameraToVRCamera(__instance.target);
     return(true);
 }
コード例 #15
0
 public static void TitleSceneSetPositionPostfix(ref Camera ___mainCamera)
 {
     VRLog.Info("Setting VR Camera to game camera");
     VRPatcher.MoveVRCameraToMainCamera(true);
     //VRPatcher.MoveVRCameraToTarget(___mainCamera.transform);
 }
コード例 #16
0
 public static void ImportCameraData(Studio.CameraControl __instance)
 {
     __instance.InternalUpdateCameraState(Vector3.zero, 0);
     VRPatcher.MoveVRCameraToTarget(__instance.transform, false);
 }
コード例 #17
0
 public static void LobbySceneManagerSetCameraAndCharaPositionPostfix()
 {
     VRLog.Info("Setting VR Camera to game camera");
     VRPatcher.MoveVRCameraToMainCamera();
 }
コード例 #18
0
 public static void GlobalMethodloadResetCamerayPostfix()
 {
     VRLog.Info("Setting VR Camera to game camera");
     VRPatcher.MoveVRCameraToMainCamera();
 }
コード例 #19
0
 public static void BaseCameraControl_Ver2ResetPostfix()
 {
     VRLog.Info("Setting VR Camera to game camera");
     VRPatcher.MoveVRCameraToMainCamera();
 }
コード例 #20
0
 public static void HomeSceneManagerSetCameraPositionPostfix()
 {
     VRLog.Info("Setting VR Camera to game camera (Home SetPOS)");
     VRPatcher.MoveVRCameraToMainCamera();
 }
コード例 #21
0
 public static bool TitleSceneLateUpdate(EyeLookController __instance)
 {
     VRLog.Info("Setting VR Camera to game camera");
     VRPatcher.MoveVRCameraToMainCamera();
     return(true);
 }
コード例 #22
0
 public static bool NeckLookControllerVer2LateUpdate(NeckLookControllerVer2 __instance)
 {
     VRPatcher.MoveMainCameraToVRCamera(__instance.target);
     return(true);
 }