// Update is called once per frame void Update() { vrTracker tracker = null; vrKeyboard keyb = null; if (MiddleVR.VRDeviceMgr != null) { tracker = MiddleVR.VRDeviceMgr.GetTracker(Tracker); keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_SPACE)) { if (tracker != null) { float yaw = tracker.GetYaw(); vrQuat neutralOr = new vrQuat(0, 0, 0, 1); neutralOr.SetEuler(-yaw, 0, 0); vrQuat nq = neutralOr.GetInverse(); tracker.SetNeutralOrientation(nq); } } }
protected void Update() { vrTracker tracker = null; vrKeyboard keyboard = null; var deviceMgr = MiddleVR.VRDeviceMgr; if (deviceMgr != null) { tracker = deviceMgr.GetTracker(Tracker); keyboard = deviceMgr.GetKeyboard(); } if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_SPACE)) { if (tracker != null) { float yaw = tracker.GetYaw(); vrQuat neutralQ = new vrQuat(); neutralQ.SetEuler(-yaw, 0.0f, 0.0f); vrQuat invNeutralQ = neutralQ.GetInverse(); tracker.SetNeutralOrientation(invNeutralQ); } } }
///<summary> ///Allows the user to move his avatar forward, backward, left and right. ///</summary> void moving(vrKeyboard keyb) { //forward will be modified in case we push the up/down key of the keyboard float forward = 0.0f; //speed will be a modified value of forward, depending of a given sensibility float strafe = 0.0f; //Get MiddleVR's keyboard inputs if (keyb.IsKeyPressed(MiddleVR.VRK_UP) || keyb.IsKeyPressed(MiddleVR.VRK_W)) { forward = 1.0f; } if (keyb.IsKeyPressed(MiddleVR.VRK_DOWN) || keyb.IsKeyPressed(MiddleVR.VRK_S)) { forward = -1.0f; } //Get MiddleVR's keyboard inputs if (keyb.IsKeyPressed(MiddleVR.VRK_RIGHT) || keyb.IsKeyPressed(MiddleVR.VRK_D)) { strafe = 1.0f; } if (keyb.IsKeyPressed(MiddleVR.VRK_LEFT) || keyb.IsKeyPressed(MiddleVR.VRK_A)) { strafe = -1.0f; } Vector3 directionVector = new Vector3(strafe, 0, forward) * Sensibility; charController.SimpleMove(m_RefNode.transform.TransformDirection(directionVector)); }
private VRFPSInputController controller = null; //a script that allows, among other things, to block inputs from the user void Start() { menu = GameObject.Find("KeyBindingMenu"); menu.SetActive(false); //at the begining of the simulation, the menu is hidden headNode = GameObject.Find("HeadNode"); keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); controller = GetComponent <VRFPSInputController>(); //menu.transform.parent = headNode.transform; }
// Update is called once per frame void Update() { //MiddleVRTools.Log("VRManagerUpdate"); if (m_isInit) { MiddleVRTools.Log(4, "[>] Unity Update - Start"); if (kernel.GetFrame() >= 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { displayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } kernel.Update(); UpdateInput(); if (ShowFPS) { guiText.text = kernel.GetFPS().ToString("f2"); } MiddleVRTools.UpdateNodes(); if (m_displayLog) { string txt = kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_F) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowFPS = !ShowFPS; guiText.enabled = ShowFPS; } if (keyb != null && (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } DeltaTime = kernel.GetDeltaTime(); MiddleVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } }
void Start() { source = GetComponent <AudioSource>(); source.loop = true; keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb == null) { Debug.Log("Clavier non reconnu dans DomophoneRinging.cs"); } }
void Update() { //Affect keyb to the MiddleVR Keyboard if (keyb == null) { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } lookingUpDown(); lookingLeftRight(); moving(keyb); }
void Start() { print ("Start"); if (MiddleVR.VRDeviceMgr == null) return; _keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); _spaceNavAxis = MiddleVR.VRDeviceMgr.GetAxis("SpaceNavAxes.Axis"); _spaceNavButtons = MiddleVR.VRDeviceMgr.GetButtons("SpaceNavButtons.Buttons"); _flystickAxis = MiddleVR.VRDeviceMgr.GetAxis("FlystickAxes.Axis"); _flystickButtons = MiddleVR.VRDeviceMgr.GetButtons("FlystickButtons.Buttons"); print("SpaceNavAxes: "+ _spaceNavAxis); }
// Use this for initialization void Start() { m_keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); m_headNode = GameObject.Find("HeadNode"); //m_menu = GameObject.Find ("VRMenu"); //m_menuManager = m_menu.GetComponent<VRMenuManager> (); m_controller = GameObject.Find("Utilisateur").GetComponent <VRFPSInputController>(); m_wController = GameObject.Find("Utilisateur").GetComponent <WandOnlyController>(); m_wand = GameObject.Find("VRWand"); Cursor.visible = false; }
private IEnumerator PostFrameUpdate() { yield return(new WaitForEndOfFrame()); VRManagerScript mgr = GetComponent <VRManagerScript>(); if (mgr != null && MiddleVR.VRKernel == null) { Debug.LogWarning("[ ] If you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); mgr.GetComponent <GUIText>().text = "[ ] Check the console window to check if you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."; } MVRTools.Log(4, "[>] Unity: Start of VR PostFrameUpdate."); if (kernel == null || deviceMgr == null || clusterMgr == null) { InitManagers(); } if (deviceMgr != null) { vrKeyboard keyboard = deviceMgr.GetKeyboard(); if (keyboard != null) { if (mgr != null && mgr.QuitOnEsc && keyboard.IsKeyPressed((uint)MiddleVR.VRK_ESCAPE)) { mgr.QuitApplication(); } } else { if (!LoggedNoKeyboard) { MVRTools.Log("[X] No VR keyboard."); LoggedNoKeyboard = true; } } } if (kernel != null) { kernel.PostFrameUpdate(); } MVRTools.Log(4, "[<] Unity: End of VR PostFrameUpdate."); if (kernel != null && kernel.GetFrame() == 2 && !Application.isEditor) { MVRTools.Log(2, "[ ] If the application is stuck here and you're using Quad-buffer active stereoscopy, make sure that in the Player Settings of Unity, the option 'Run in Background' is checked."); } }
void Start() { print("Start"); if (MiddleVR.VRDeviceMgr == null) { return; } _keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); _spaceNavAxis = MiddleVR.VRDeviceMgr.GetAxis("SpaceNavAxes.Axis"); _spaceNavButtons = MiddleVR.VRDeviceMgr.GetButtons("SpaceNavButtons.Buttons"); _flystickAxis = MiddleVR.VRDeviceMgr.GetAxis("FlystickAxes.Axis"); _flystickButtons = MiddleVR.VRDeviceMgr.GetButtons("FlystickButtons.Buttons"); print("SpaceNavAxes: " + _spaceNavAxis); }
void Update() { vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); // Reload Simulation (level 0) if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_R) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) && (keyb.IsKeyPressed(MiddleVR.VRK_LCONTROL) || keyb.IsKeyPressed(MiddleVR.VRK_RCONTROL))) { Application.LoadLevel(0); } // Reload last loaded level else if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_R) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { Application.LoadLevel(Application.loadedLevel); } }
// Use this for initialization void Start() { if (MiddleVR.VRDeviceMgr.GetKeyboard() != null) { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } inputController = utilisateur.GetComponent <VRFPSInputController> (); headNode = GameObject.Find("HeadNode"); wand = GameObject.Find("VRWand"); gliding = false; frozen = false; reversing = false; HideRenderer(); }
// Update is called once per frame void Update() { vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (!GetComponent <Animation>().isPlaying&& keyb.IsKeyPressed(MiddleVR.VRK_S)) { GetComponent <Animation>().Play(); } if (keyb.IsKeyPressed(MiddleVR.VRK_R)) { //Application.LoadLevel(0); GetComponent <Animation>().Stop(); transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * 1.005f, transform.localScale.z); GetComponent <Animation>().Play(); } if (keyb.IsKeyPressed(MiddleVR.VRK_F)) { //Application.LoadLevel(0); GetComponent <Animation>().Stop(); transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * 0.995f, transform.localScale.z); GetComponent <Animation>().Play(); } if (keyb.IsKeyPressed(MiddleVR.VRK_T)) { //Application.LoadLevel(0); GetComponent <Animation>().Stop(); transform.localScale = new Vector3(transform.localScale.x * 1.005f, transform.localScale.y, transform.localScale.z * 1.005f); GetComponent <Animation>().Play(); } if (keyb.IsKeyPressed(MiddleVR.VRK_G)) { //Application.LoadLevel(0); GetComponent <Animation>().Stop(); transform.localScale = new Vector3(transform.localScale.x * 0.995f, transform.localScale.y, transform.localScale.z * 0.995f); GetComponent <Animation>().Play(); } if (Input.GetKey(KeyCode.Return)) { Application.LoadLevel(0); } }
// Update is called once per frame void Update() { vrTracker tracker = null; vrKeyboard keyb = null; if (MiddleVR.VRDeviceMgr != null) { tracker = MiddleVR.VRDeviceMgr.GetTracker(Tracker); keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_SPACE)) { if (tracker != null) { tracker.SetNeutralOrientation(tracker.GetOrientation()); } } }
protected void Update() { vrKeyboard keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_R) && (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyboard.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { if ((keyboard.IsKeyPressed(MiddleVR.VRK_LCONTROL) || keyboard.IsKeyPressed(MiddleVR.VRK_RCONTROL))) { // Reload Simulation (level 0). Application.LoadLevel(0); } else { // Reload last loaded level. Application.LoadLevel(Application.loadedLevel); } } }
// Update is called once per frame void Update() { //Affect keyb to the MiddleVR Keyboard if (keyb == null) { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } if (keyb.IsKeyToggled(MiddleVR.VRK_R)) { invertBlockInput(); } //if BlockInputs == true, we don't want the user to be able to move the camera by himself //if(!BlockInputs){ lookingUpDown(); lookingLeftRight(); //} moving(keyb); }
// Use this for initialization void Start() { if (MiddleVR.VRDeviceMgr.GetKeyboard() != null) { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } inputController = utilisateur.GetComponent <VRFPSInputController> (); gliding = false; frozen = false; reversing = false; cameraAssisteeScript = GameObject.Find("mode_assiste").GetComponent <CameraAssistee> (); Vector3 obj = destination.transform.position; float height = GameObject.Find("HeadNode").transform.localPosition.y; obj.y -= height; destination.transform.position = obj; }
void Update() { vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); // Invert eye if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_I) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { // For each vrCameraStereo, invert inter eye distance uint camNb = MiddleVR.VRDisplayMgr.GetCamerasNb(); for (uint i = 0; i < camNb; ++i) { vrCamera cam = MiddleVR.VRDisplayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = MiddleVR.VRDisplayMgr.GetCameraStereo(cam.GetName()); stereoCam.SetInterEyeDistance(-stereoCam.GetInterEyeDistance()); } } } }
protected void Update() { vrKeyboard keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_R) && (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyboard.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { if ((keyboard.IsKeyPressed(MiddleVR.VRK_LCONTROL) || keyboard.IsKeyPressed(MiddleVR.VRK_RCONTROL))) { // Reload Simulation (level 0). SceneManager.LoadScene(0); } else { // Reload last loaded level. Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name); } } }
void moving(vrKeyboard keyb) { //forward will be modified in case we push the up/down key of the keyboard float forward = 0.0f; //speed will be a modified value of forward, depending of a given sensibility float strafe = 0.0f; //forward = (float)MiddleVR.VRKernel.GetDeltaTime() * MiddleVR.VRDeviceMgr.GetWandVerticalAxisValue() * Speed; //Get MiddleVR's keyboard inputs if (keyb.IsKeyPressed(MiddleVR.VRK_UP) || keyb.IsKeyPressed(MiddleVR.VRK_W)) { forward = 1.0f; //unLockCamera(); } if (keyb.IsKeyPressed(MiddleVR.VRK_DOWN) || keyb.IsKeyPressed(MiddleVR.VRK_S)) { forward = -1.0f; //unLockCamera(); } //Get MiddleVR's keyboard inputs if (keyb.IsKeyPressed(MiddleVR.VRK_RIGHT) || keyb.IsKeyPressed(MiddleVR.VRK_D)) { strafe = 1.0f; //unLockCamera(); } if (keyb.IsKeyPressed(MiddleVR.VRK_LEFT) || keyb.IsKeyPressed(MiddleVR.VRK_A)) { strafe = -1.0f; //unLockCamera(); } Vector3 directionVector = new Vector3(strafe, 0, forward) * Sensibility; controller.SimpleMove(m_RefNode.transform.TransformDirection(directionVector)); }
protected void Update() { vrKeyboard keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); // Invert eyes. if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_I) && (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyboard.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { var displayMgr = MiddleVR.VRDisplayMgr; // For each vrCameraStereo, invert inter eye distance. for (uint i = 0, iEnd = displayMgr.GetCamerasNb(); i < iEnd; ++i) { vrCamera cam = displayMgr.GetCameraByIndex(i); if (cam.IsA("CameraStereo")) { vrCameraStereo stereoCam = displayMgr.GetCameraStereoById(cam.GetId()); stereoCam.SetInterEyeDistance(-stereoCam.GetInterEyeDistance()); } } } }
// Use this for initialization void Start() { CurrentMode = Mode.Assisted; ScenarioData = EmptyScenar; ScenarioState = 0; keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb == null) { Debug.Log("Clavier MiddleVR non trouvé"); } foreach (ScenarioItem a in Scenar1) { a.inst(); } foreach (ScenarioItem a in Scenar2) { a.inst(); } foreach (ScenarioItem a in Scenar3) { a.inst(); } }
// Update is called once per frame void Update() { //MVRTools.Log("VRManagerUpdate"); // Initialize interactions if (!m_InteractionsInitialized) { _SetNavigation(Navigation); _SetManipulation(Manipulation); _SetVirtualHandMapping(VirtualHandMapping); m_InteractionsInitialized = true; } MVRNodesMapper nodesMapper = MVRNodesMapper.Instance; nodesMapper.UpdateNodesUnityToMiddleVR(); if (m_isInit) { MVRTools.Log(4, "[>] Unity Update - Start"); if (m_Kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { m_DisplayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } if (m_Kernel.GetFrame() == 0) { // Set the random seed in kernel for dispatching only during start-up. // With clustering, a client will be set by a call to kernel.Update(). if (!m_ClusterMgr.IsCluster() || (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsServer())) { // The cast is safe because the seed is always positive. uint seed = (uint)UnityEngine.Random.seed; m_Kernel._SetRandomSeed(seed); } } m_Kernel.Update(); if (m_Kernel.GetFrame() == 0) { // Set the random seed in a client only during start-up. if (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsClient()) { // The cast is safe because the seed comes from // a previous value of Unity. int seed = (int)m_Kernel.GetRandomSeed(); UnityEngine.Random.seed = seed; } } UpdateInput(); if (ShowFPS) { this.GetComponent <GUIText>().text = m_Kernel.GetFPS().ToString("f2"); } nodesMapper.UpdateNodesMiddleVRToUnity(false); MVRTools.UpdateCameraProperties(); if (m_displayLog) { string txt = m_Kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = m_DeviceMgr.GetKeyboard(); if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) { if (keyb.IsKeyToggled(MiddleVR.VRK_D)) { ShowFPS = !ShowFPS; } if (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb.IsKeyToggled(MiddleVR.VRK_F)) { Fly = !Fly; } // Navigation mode switch if (keyb.IsKeyToggled(MiddleVR.VRK_N)) { vrInteraction navigation = _GetNextInteraction("ContinuousNavigation"); if (navigation != null) { MiddleVR.VRInteractionMgr.Activate(navigation); } } } } DeltaTime = m_Kernel.GetDeltaTime(); MVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MVRTools.VRReset(); MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }
void Start() { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); gameManager = GameObject.Find("GameManager").GetComponent <Modelisation.GameManager>(); vrfps = GameObject.Find("Utilisateur").GetComponent <VRFPSInputController> (); }
// Use this for initialization /*void Start() * { * * GameObject Wand = GameObject.Find("VRWand"); * * if (Wand != null) * { * Wand.GetComponent<VRWandNavigation>().enabled = false; * MiddleVRTools.Log("[ ] VRFPSInputController deactivated VRWandNavigation. Make sure you set the VR Root Node to the First Person Controller."); * } * }*/ void FixedUpdate() { CharacterMotor motor = GetComponent <CharacterMotor>(); vrKeyboard keyb = null; if (MiddleVR.VRDeviceMgr.GetKeyboard() != null) { keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } GameObject refNode = GameObject.Find(ReferenceNode); float speed = 0.0f; float speedR = 0.0f; float forward = 0.0f; // Choosing active vertical axis, later ones will overwrite previous ones // First test Unity's inputs if (Math.Abs(Input.GetAxis("Vertical")) > 0) { forward = Input.GetAxis("Vertical"); } // Then test MiddleVR's keyboard //If MiddleVR is correctly tracking the keyboard, ie keyb != null, this will overwrite forward if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_UP) || keyb.IsKeyPressed(MiddleVR.VRK_Z)) { forward = 1.0f; } if (keyb.IsKeyPressed(MiddleVR.VRK_DOWN) || keyb.IsKeyPressed(MiddleVR.VRK_S)) { forward = -1.0f; } } // Computing speed if (Math.Abs(forward) > 0.1) { speed = forward * Time.deltaTime * 30; } //print("Speed: " + speed); // Choosing active horizontal axis float rotation = 0.0f; // First test Unity's inputs if (Math.Abs(Input.GetAxis("Horizontal")) > 0) { rotation = Input.GetAxis("Horizontal"); } // Then test MiddleVR's keyboard if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LEFT) || keyb.IsKeyPressed(MiddleVR.VRK_Q)) { rotation = -1.0f; } if (keyb.IsKeyPressed(MiddleVR.VRK_RIGHT) || keyb.IsKeyPressed(MiddleVR.VRK_D)) { rotation = 1.0f; } } if (Math.Abs(rotation) > 0.1) { speedR = rotation * Time.deltaTime * 50; } Vector3 directionVector = new Vector3(speedR, 0, speed); if (refNode == null) { if (m_SearchedRefNode == false) { MiddleVRTools.Log("[ ] Didn't find reference node " + ReferenceNode); m_SearchedRefNode = true; } motor.inputMoveDirection = directionVector; } else { motor.inputMoveDirection = refNode.transform.TransformDirection(directionVector); //print(motor.inputMoveDirection); } bool jump = false; if (Input.GetButton("Jump") == true) { jump = true; } if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_SPACE)) { jump = true; } } if (MiddleVR.VRDeviceMgr.IsWandButtonToggled(1) == true) { jump = true; } motor.inputJump = jump; }
// Update is called once per frame protected void Update() { // Initialize interactions if (!m_InteractionsInitialized) { _SetNavigation(Navigation); _SetManipulation(Manipulation); _SetVirtualHandMapping(VirtualHandMapping); m_InteractionsInitialized = true; } MVRNodesMapper nodesMapper = MVRNodesMapper.Instance; nodesMapper.UpdateNodesUnityToMiddleVR(); if (m_isInit) { MVRTools.Log(4, "[>] Unity Update - Start"); if (m_Kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { m_DisplayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } // Set the random seed in kernel for dispatching only during start-up. if (m_Kernel.GetFrame() == 0) { // Disable obsolescence warning for Random.seed as we only use it to initalize // the MiddleVR random seed. // Using Random.seed was deprecated because it is a single integer and does not // contain the full state of the random number generator and thus could not be // used for restoring or synchronizing the state. #pragma warning disable 618 // The cast is safe because the seed is always positive. m_Kernel._SetRandomSeed((uint)UnityEngine.Random.seed); #pragma warning restore 618 // With clustering, a client will be set by a call to kernel.Update(). if (m_ClusterMgr.IsCluster()) { if (m_shareRandomStateCommand == null) { m_shareRandomStateCommand = new vrCommand("MVR_ShareRandomState", (vrValue val) => { UnityEngine.Random.state = JsonUtility.FromJson <UnityEngine.Random.State>(val.GetString()); return(new vrValue()); }); } if (m_ClusterMgr.IsServer()) { m_shareRandomStateCommand.Do(new vrValue(JsonUtility.ToJson(UnityEngine.Random.state))); } } } m_Kernel.Update(); UpdateInput(); if (ShowFPS) { m_FPSText.text = m_Kernel.GetFPS().ToString("f2"); } nodesMapper.UpdateNodesMiddleVRToUnity(false); MVRTools.UpdateCameraProperties(m_Kernel, m_DisplayMgr, nodesMapper); vrKeyboard keyb = m_DeviceMgr.GetKeyboard(); if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) { if (keyb.IsKeyToggled(MiddleVR.VRK_D)) { ShowFPS = !ShowFPS; } if (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb.IsKeyToggled(MiddleVR.VRK_F)) { Fly = !Fly; } // Navigation mode switch if (keyb.IsKeyToggled(MiddleVR.VRK_N)) { vrInteraction navigation = _GetNextInteraction("ContinuousNavigation"); if (navigation != null) { MiddleVR.VRInteractionMgr.Activate(navigation); } } } } DeltaTime = m_Kernel.GetDeltaTime(); MVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } }
// Update is called once per frame void Update() { //MiddleVRTools.Log("VRManagerUpdate"); if (m_isInit) { MiddleVRTools.Log(4, "[>] Unity Update - Start"); if (kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { displayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } kernel.Update(); UpdateInput(); if (ShowFPS) { guiText.text = kernel.GetFPS().ToString("f2"); } MiddleVRTools.UpdateNodes(); if (m_displayLog) { string txt = kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_F) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowFPS = !ShowFPS; guiText.enabled = ShowFPS; } if (keyb != null && (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } DeltaTime = kernel.GetDeltaTime(); MiddleVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MiddleVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MiddleVRTools.VRReset(); MiddleVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }
IEnumerator EndOfFrame() { yield return(new WaitForEndOfFrame()); VRManagerScript mgr = GetComponent <VRManagerScript>(); if (mgr != null && MiddleVR.VRKernel == null) { Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); mgr.guiText.text = "[ ] Check the console window to check if you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."; } MiddleVRTools.Log(4, "[>] VR End of Frame."); if (kernel == null) { kernel = MiddleVR.VRKernel; } if (dmgr == null) { dmgr = MiddleVR.VRDeviceMgr; } if (dmgr != null) { vrKeyboard keyb = dmgr.GetKeyboard(); if (keyb != null) { VRManagerScript vrmgr = GetComponent <VRManagerScript>(); if (vrmgr != null && vrmgr.QuitOnEsc && keyb.IsKeyPressed((uint)MiddleVR.VRK_ESCAPE)) { if (Application.isEditor) { MiddleVRTools.Log("[ ] If we were in player mode, MiddleVR would exit."); } else { MiddleVRTools.Log("[ ] Unity says we're quitting."); MiddleVR.VRKernel.SetQuitting(); Application.Quit(); } } } else { if (!LoggedNoKeyboard) { MiddleVRTools.Log("[X] No VR keyboard"); LoggedNoKeyboard = true; } } } if (kernel != null) { /* * MiddleVRTools.Log("SavingRT"); ; * SaveRT(); */ kernel.PostFrameUpdate(); } MiddleVRTools.Log(4, "[<] End of VR End of Frame."); if (kernel != null && kernel.GetFrame() == 2 && !Application.isEditor) { MiddleVRTools.Log(2, "[ ] If the application is stuck here and you're using Quad-buffer active stereoscopy, make sure that in the Player Settings of Unity, the option 'Run in Background' is checked."); } }
// Update is called once per frame void Update() { //MiddleVRTools.Log("VRManagerUpdate"); if (m_isInit) { MiddleVRTools.Log(4, "[>] Unity Update - Start"); if (kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { displayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } kernel.Update(); UpdateInput(); if (ShowFPS) { guiText.text = kernel.GetFPS().ToString("f2"); } MiddleVRTools.UpdateNodes(); if (m_displayLog) { string txt = kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_D) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowFPS = !ShowFPS; guiText.enabled = ShowFPS; } if (keyb != null && (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_F) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { vrInteractionManager interMan = vrInteractionManager.GetInstance(); uint interactionNb = interMan.GetInteractionsNb(); for (uint i = 0; i < interactionNb; ++i) { vrProperty flyProp = interMan.GetInteractionByIndex(i).GetProperty("Fly"); if (flyProp != null) { flyProp.SetBool(!flyProp.GetBool()); } } } // Navigation mode switch if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_N) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { // Disable current nav MonoBehaviour currentNavigation = (MonoBehaviour)m_Wand.GetComponent((string)m_NavigationScipts[m_CurrentNavigationNb]); if (currentNavigation != null) { currentNavigation.enabled = false; } // Enable next nav m_CurrentNavigationNb = (m_CurrentNavigationNb + 1) % m_NavigationScipts.Count; currentNavigation = (MonoBehaviour)m_Wand.GetComponent((string)m_NavigationScipts[m_CurrentNavigationNb]); if (currentNavigation != null) { currentNavigation.enabled = true; } } DeltaTime = kernel.GetDeltaTime(); MiddleVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MiddleVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MiddleVRTools.VRReset(); MiddleVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }
void Update() { if (!begin) { return; } vrKeyboard keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); // Apply new transform if (keyboard != null) { // Hold down W to activate x, y move if (keyboard.IsKeyPressed(MiddleVR.VRK_W)) { if (keyboard.IsKeyPressed(MiddleVR.VRK_RIGHT)) { xDist += increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_LEFT)) { xDist -= increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_UP)) { yDist += increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_DOWN)) { yDist -= increment; } } // Hold down E to activate y, z rotation if (keyboard.IsKeyPressed(MiddleVR.VRK_E)) { if (keyboard.IsKeyPressed(MiddleVR.VRK_RIGHT)) { roll += increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_LEFT)) { roll -= increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_UP)) { yaw += increment; } if (keyboard.IsKeyPressed(MiddleVR.VRK_DOWN)) { yaw -= increment; } } // Press R to reset if (keyboard.IsKeyToggled(MiddleVR.VRK_R)) { if (wantToReset) { reset(); } else { wantToReset = true; } } // Press + to increase movement amount if (keyboard.IsKeyToggled(MiddleVR.VRK_EQUALS)) { int magnitude = 1; if (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT)) { magnitude = 10; } increment += (incrementFidelity * magnitude); }// Press - to increase movement amount if (keyboard.IsKeyToggled(MiddleVR.VRK_MINUS)) { int magnitude = 1; if (keyboard.IsKeyPressed(MiddleVR.VRK_LSHIFT)) { magnitude = 10; } increment -= (incrementFidelity * magnitude); if (increment < 0) { increment = 0; } } } // Display the values string text = "<size=20>Pos:(" + xDist + ", " + yDist + ", 0)</size>\nRot:(0, " + roll + ", " + yaw + ")\n<size=10>Adjustment: " + increment + "</size>"; GetComponent <TextMesh>().text = text; print(text); applyOffset(); }