Beispiel #1
0
    private void _EnableNavigationFly(bool iEnable)
    {
        m_Fly = iEnable;

        VRInteractionNavigationElastic navigationElastic = m_Wand.GetComponent <VRInteractionNavigationElastic>();

        if (navigationElastic != null)
        {
            navigationElastic.Fly = m_Fly;
        }

        VRInteractionNavigationWandJoystick navigationWandJoystick = m_Wand.GetComponent <VRInteractionNavigationWandJoystick>();

        if (navigationWandJoystick != null)
        {
            navigationWandJoystick.Fly = m_Fly;
        }

        vrInteractionManager interactionMgr = vrInteractionManager.GetInstance();

        for (uint i = 0, iEnd = interactionMgr.GetInteractionsNb(); i < iEnd; ++i)
        {
            vrProperty flyProp = interactionMgr.GetInteractionByIndex(i).GetProperty("Fly");
            if (flyProp != null)
            {
                flyProp.SetBool(m_Fly);
            }
        }
    }
Beispiel #2
0
    private void _EnableNavigationFly(bool iEnable)
    {
        m_Fly = iEnable;

        vrInteractionManager interactionMgr = vrInteractionManager.GetInstance();

        for (uint i = 0, iEnd = interactionMgr.GetInteractionsNb(); i < iEnd; ++i)
        {
            vrProperty flyProp = interactionMgr.GetInteractionByIndex(i).GetProperty("Fly");
            if (flyProp != null)
            {
                flyProp.SetBool(m_Fly);
            }
        }
    }
Beispiel #3
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;
            }
        }
    }