// 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.");
        }
    }
Exemple #2
0
    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);
        }
    }
    // 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);
            }
        }
    }
Exemple #5
0
 // Update is called once per frame
 void Update()
 {
     // L'appui sur RETURN recharge la scène
     if (keyb.IsKeyToggled(MiddleVR.VRK_RETURN))
     {
         Application.LoadLevel("Kerpape");
     }
 }
Exemple #6
0
        void Update()
        {
            if (_keyboard != null && _keyboard.IsKeyToggled(MiddleVR.VRK_SPACE))
            {
                print("Space!");
            }
            for (uint i = 0; i < 6; ++i)
            {
                if (_spaceNavAxis != null && Mathf.Approximately(_spaceNavAxis.GetValue(i), 0))
                {
                    print("SpaceNavAxis " + i + " : " + _spaceNavAxis.GetValue(i));
                }
            }

            if (_spaceNavButtons != null)
            {
                for (uint i = 0; i < 2; ++i)
                {
                    if (_spaceNavButtons.IsToggled(i))
                    {
                        print("SpaceNavButton " + i + " pressed.");
                    }
                    if (_spaceNavButtons.IsToggled(i, false))
                    {
                        print("SpaceNavButton " + i + " released.");
                    }
                }
            }

            if (_flystickAxis != null && Mathf.Approximately(_flystickAxis.GetValue(0), 0))
            {
                print("FlystickAxis Horizontal: " + _flystickAxis.GetValue(0));
            }
            if (_flystickAxis != null && Mathf.Approximately(_flystickAxis.GetValue(1), 0))
            {
                print("FlystickAxis Vertical: " + _flystickAxis.GetValue(1));
            }

            if (_flystickButtons == null)
            {
                return;
            }
            for (uint i = 0; i < 6; ++i)
            {
                if (_flystickButtons.IsToggled(i))
                {
                    print("FlystickButton " + i + " pressed.");
                }
                if (_flystickButtons.IsToggled(i, false))
                {
                    print("FlystickButton " + i + " released.");
                }
            }
        }
    // 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());
            }
        }
    }
Exemple #8
0
    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);
            }
        }
    }
Exemple #9
0
    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());
                }
            }
        }
    }
    // 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);
    }
    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);
            }
        }
    }
    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());
                }
            }
        }
    }
Exemple #13
0
    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();
    }
Exemple #14
0
    // 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;
            }
        }
    }
Exemple #15
0
    // Update is called once per frame
    void Update()
    {
        if (keyb.IsKeyToggled(reloadScene))
        {
            Application.LoadLevel(Application.loadedLevel);
        }

        if (keyb.IsKeyToggled(quitScene))
        {
            Application.Quit();
        }

        if (keyb.IsKeyToggled(modeAssiste))
        {
            gameManager.CurrentMode = Modelisation.Mode.Assisted;
        }


        if (keyb.IsKeyToggled(modeAutonome))
        {
            gameManager.CurrentMode = Modelisation.Mode.Auto;
        }

        if (keyb.IsKeyToggled(scenarioAppelSimple))
        {
            Debug.Log("Scenario appel d'un ami");
            gameManager.loadScenario("appel");
        }

        if (keyb.IsKeyToggled(scenarioAppelInfirmier))
        {
            Debug.Log("Scenario appel d'un infirmier");
            gameManager.loadScenario("infirmier");
        }

        if (keyb.IsKeyToggled(scenarioVisiteInconnu))
        {
            Debug.Log("Scenario appel d'un inconnu");
            gameManager.loadScenario("inconnu");
        }

        if (keyb.IsKeyToggled(noScenario))
        {
            gameManager.loadScenario("aucun");
        }

        if ((keyb.IsKeyToggled(sensibilityUp) && keyb.IsKeyPressed(sensibilityDown)) ||
            (keyb.IsKeyToggled(sensibilityDown) && keyb.IsKeyPressed(sensibilityUp)))
        {
            vrfps.Sensibility = 3.0f;
        }
        else if (keyb.IsKeyToggled(lookSensibilityDown) && keyb.IsKeyPressed(lookSensibilityUp))
        {
            vrfps.lookSensibility = 1.0f;
        }

        else if (keyb.IsKeyToggled(sensibilityUp))
        {
            vrfps.Sensibility *= sensibilityFactor;
        }

        else if (keyb.IsKeyToggled(sensibilityDown))
        {
            vrfps.Sensibility /= sensibilityFactor;
        }

        else if (keyb.IsKeyToggled(lookSensibilityUp))
        {
            vrfps.lookSensibility *= lookSensibilityFactor;
        }

        else if (keyb.IsKeyToggled(lookSensibilityDown))
        {
            vrfps.lookSensibility /= lookSensibilityFactor;
        }
    }
    // 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.");
        }
    }
Exemple #17
0
    // 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;
            }
        }
    }
Exemple #18
0
    // 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;
            }
        }
    }