Пример #1
0
        void UpdateStateRight(SteamVR_Utils.RigidTransform pose, SteamVR_Controller.Device state)
        {
            if (state.GetPress(EVRButtonId.k_EButton_SteamVR_Touchpad))
            {
                Vector2 touchAxis = state.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad);

                Vector3 fwdDirection = Scene.HmdRotation * Vector3.forward;
                fwdDirection.y = 0f; // allow only planar movement
                Vector3 fwdDisplacement = fwdDirection.normalized * (movementVelocity * touchAxis.y) * Time.deltaTime;

                Vector3 rightDirection = Scene.HmdRotation * Vector3.right;
                rightDirection.y = 0f; // allow only planar movement
                Vector3 rightDisplacement = rightDirection.normalized * (movementVelocity * touchAxis.x) * Time.deltaTime;

                Scene.CurrentPosition += fwdDisplacement + rightDisplacement;
            }

            if (state.GetPressDown(EVRButtonId.k_EButton_ApplicationMenu))
            {
                KerbalVR.ResetInitialHmdPosition();
            }
        }
Пример #2
0
        private void GenerateGUI(int windowId)
        {
            string   buttonStringToggleVr = BUTTON_STRING_ENABLE_VR;
            string   labelStringVrActive  = LABEL_STRING_VR_INACTIVE;
            GUIStyle labelStyleVrActive   = new GUIStyle(HighLogic.Skin.label);

            labelStyleVrActive.normal.textColor = Color.red;

            if (KerbalVR.HmdIsRunning)
            {
                buttonStringToggleVr = BUTTON_STRING_DISABLE_VR;
                labelStringVrActive  = LABEL_STRING_VR_ACTIVE;
                labelStyleVrActive.normal.textColor = Color.green;
            }

            GUILayout.BeginVertical();

            // VR toggle button
            UnityEngine.GUI.enabled = Scene.SceneAllowsVR();
            if (GUILayout.Button(buttonStringToggleVr, HighLogic.Skin.button))
            {
                if (KerbalVR.HmdIsEnabled)
                {
                    KerbalVR.HmdIsEnabled = false;
                }
                else
                {
                    KerbalVR.HmdIsEnabled = true;
                }
            }

            if (KerbalVR.CanResetSeatedPose())
            {
                if (GUILayout.Button("Reset Headset Position", HighLogic.Skin.button))
                {
                    KerbalVR.ResetInitialHmdPosition();
                }
            }

            string sc = "";

            switch (KerbalVR.qualityLevel)
            {
            case 0:
                sc = "1.5x";
                break;

            case 1:
                sc = "1x";
                break;

            case 2:
                sc = ".75x";
                break;

            case 3:
                sc = ".5x";
                break;

            case 4:
                sc = ".25x";
                break;
            }


            if (GUILayout.Button("Render Scale (" + sc + ")", HighLogic.Skin.button))
            {
                KerbalVR.qualityLevel += 1;
                if (KerbalVR.qualityLevel > 4)
                {
                    KerbalVR.qualityLevel = 0;
                }
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                if (GUILayout.Button("VAB/SPH World Scale (" + (int)1 / Scene.editorScale + ")", HighLogic.Skin.button))
                {
                    Scene.editorScale /= 2;
                    if (Scene.editorScale < 0.05)
                    {
                        Scene.editorScale = 1;
                    }
                }
            }

            UnityEngine.GUI.enabled = true;

            // VR status
            GUILayout.BeginHorizontal();
            GUILayout.Label("VR Status:", HighLogic.Skin.label);
            GUILayout.Label(labelStringVrActive, labelStyleVrActive);
            GUILayout.EndHorizontal();

#if DEBUG
            // settings
            GUIStyle labelStyleHeader = new GUIStyle(HighLogic.Skin.label);
            labelStyleHeader.fontStyle = FontStyle.Bold;
            GUILayout.Label("Options", labelStyleHeader);
#endif

            GUILayout.EndVertical();

            // allow dragging the window
            UnityEngine.GUI.DragWindow();
        }