private void InitManagers()
    {
        if (kernel == null)
        {
            kernel = MiddleVR.VRKernel;
        }

        if (deviceMgr == null)
        {
            deviceMgr = MiddleVR.VRDeviceMgr;
        }

        if (clusterMgr == null)
        {
            clusterMgr = MiddleVR.VRClusterMgr;
        }
    }
    private void InitManagers()
    {
        if (kernel == null)
        {
            kernel = MiddleVR.VRKernel;
        }

        if (deviceMgr == null)
        {
            deviceMgr = MiddleVR.VRDeviceMgr;
        }

        if (clusterMgr == null)
        {
            clusterMgr = MiddleVR.VRClusterMgr;
        }
    }
Beispiel #3
0
    void UpdateInput()
    {
        vrDeviceManager dmgr = MiddleVR.VRDeviceMgr;

        if (dmgr != null)
        {
            vrButtons wandButtons = dmgr.GetWandButtons();

            if (wandButtons != null)
            {
                uint buttonNb = wandButtons.GetButtonsNb();
                if (buttonNb > 0)
                {
                    WandButton0 = wandButtons.IsPressed(dmgr.GetWandButton0());
                }
                if (buttonNb > 1)
                {
                    WandButton1 = wandButtons.IsPressed(dmgr.GetWandButton1());
                }
                if (buttonNb > 2)
                {
                    WandButton2 = wandButtons.IsPressed(dmgr.GetWandButton2());
                }
                if (buttonNb > 3)
                {
                    WandButton3 = wandButtons.IsPressed(dmgr.GetWandButton3());
                }
                if (buttonNb > 4)
                {
                    WandButton4 = wandButtons.IsPressed(dmgr.GetWandButton4());
                }
                if (buttonNb > 5)
                {
                    WandButton5 = wandButtons.IsPressed(dmgr.GetWandButton5());
                }
            }

            WandAxisHorizontal = dmgr.GetWandHorizontalAxisValue();
            WandAxisVertical   = dmgr.GetWandVerticalAxisValue();
        }
    }
Beispiel #4
0
    // Private methods

    void InitializeVR()
    {
        mouseButtons[0] = mouseButtons[1] = mouseButtons[2] = false;

        if (m_displayLog)
        {
            GameObject gui = new GameObject();
            m_GUI = gui.AddComponent <GUIText>() as GUIText;
            gui.transform.localPosition = new UnityEngine.Vector3(0.5f, 0.0f, 0.0f);
            m_GUI.pixelOffset           = new UnityEngine.Vector2(15, 0);
            m_GUI.anchor = TextAnchor.LowerCenter;
        }

        MVRTools.IsEditor = Application.isEditor;

        if (MiddleVR.VRKernel != null)
        {
            MVRTools.Log(3, "[ ] VRKernel already alive, reset Unity Manager.");
            MVRTools.VRReset();
            m_isInit = true;
            // Not needed because this is the first execution of this script instance
            // m_isGeometrySet = false;
            m_FirstFrameAfterReset = MiddleVR.VRKernel.GetFrame();
        }
        else
        {
            if (CustomLicense)
            {
                MVRTools.CustomLicense     = true;
                MVRTools.CustomLicenseName = CustomLicenseName;
                MVRTools.CustomLicenseCode = CustomLicenseCode;
            }

            m_isInit = MVRTools.VRInitialize(ConfigFile);
        }


        if (SimpleClusterParticles)
        {
            _SetParticlesSeeds();
        }

        // Get AA from vrx configuration file
        m_AntiAliasingLevel = (int)MiddleVR.VRDisplayMgr.GetAntiAliasing();

        DumpOptions();

        if (!m_isInit)
        {
            GameObject gui = new GameObject();
            m_GUI = gui.AddComponent <GUIText>() as GUIText;
            gui.transform.localPosition = new UnityEngine.Vector3(0.2f, 0.0f, 0.0f);
            m_GUI.pixelOffset           = new UnityEngine.Vector2(0, 0);
            m_GUI.anchor = TextAnchor.LowerLeft;

            string txt = m_Kernel.GetLogString(true);
            print(txt);
            m_GUI.text = txt;

            return;
        }

        m_Kernel     = MiddleVR.VRKernel;
        m_DeviceMgr  = MiddleVR.VRDeviceMgr;
        m_DisplayMgr = MiddleVR.VRDisplayMgr;
        m_ClusterMgr = MiddleVR.VRClusterMgr;

        if (SimpleCluster)
        {
            SetupSimpleCluster();
        }

        if (DisableExistingCameras)
        {
            Camera[] cameras = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[];

            foreach (Camera cam in cameras)
            {
                if (cam.targetTexture == null)
                {
                    cam.enabled = false;
                }
            }
        }

        MVRNodesCreator.Instance.CreateNodes(VRSystemCenterNode, DebugNodes, DebugScreens, GrabExistingNodes, TemplateCamera);

        MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA);

        //AttachCameraCB();

        MVRTools.Log(4, "[<] End of VR initialization script");
    }
Beispiel #5
0
    // Private methods

    private void InitializeVR()
    {
        mouseButtons[0] = mouseButtons[1] = mouseButtons[2] = false;

        if (m_displayLog)
        {
            GameObject gui = new GameObject();
            m_GUI = gui.AddComponent<GUIText>() as GUIText;
            gui.transform.localPosition = new UnityEngine.Vector3(0.5f, 0.0f, 0.0f);
            m_GUI.pixelOffset = new UnityEngine.Vector2(15, 0);
            m_GUI.anchor = TextAnchor.LowerCenter;
        }

        MVRTools.IsEditor = Application.isEditor;

        if( MiddleVR.VRKernel != null )
        {
            MVRTools.Log(3, "[ ] VRKernel already alive, reset Unity Manager.");
            MVRTools.VRReset();
            m_isInit = true;
            // Not needed because this is the first execution of this script instance
            // m_isGeometrySet = false;
            m_FirstFrameAfterReset = MiddleVR.VRKernel.GetFrame();

        }
        else
        {
            if( CustomLicense )
            {
                MVRTools.CustomLicense = true;
                MVRTools.CustomLicenseName = CustomLicenseName;
                MVRTools.CustomLicenseCode = CustomLicenseCode;
            }

            m_isInit = MVRTools.VRInitialize(ConfigFile);
        }


        if (SimpleClusterParticles)
        {
            _SetParticlesSeeds();
        }

        // Get AA from vrx configuration file
        m_AntiAliasingLevel = (int)MiddleVR.VRDisplayMgr.GetAntiAliasing();

        DumpOptions();

        if (!m_isInit)
        {
            GameObject gui = new GameObject();
            m_GUI = gui.AddComponent<GUIText>() as GUIText;
            gui.transform.localPosition = new UnityEngine.Vector3(0.2f, 0.0f, 0.0f);
            m_GUI.pixelOffset = new UnityEngine.Vector2(0, 0);
            m_GUI.anchor = TextAnchor.LowerLeft;

            string txt = m_Kernel.GetLogString(true);
            print(txt);
            m_GUI.text = txt;

            return;
        }

        m_Kernel = MiddleVR.VRKernel;
        m_DeviceMgr = MiddleVR.VRDeviceMgr;
        m_DisplayMgr = MiddleVR.VRDisplayMgr;
        m_ClusterMgr = MiddleVR.VRClusterMgr;

        if (SimpleCluster)
        {
            SetupSimpleCluster();
        }

        if (DisableExistingCameras)
        {
            Camera[] cameras = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[];

            foreach (Camera cam in cameras)
            {
                if (cam.targetTexture == null)
                {
                    cam.enabled = false;
                }
            }
        }

        MVRNodesCreator.Instance.CreateNodes(
            VRSystemCenterNode,
            DebugNodes, DebugScreens,
            GrabExistingNodes, TemplateCamera);

        MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, true);

        MVRTools.Log(4, "[<] End of VR initialization script");
    }
    // Private methods

    private void InitializeVR()
    {
        mouseButtons[0] = mouseButtons[1] = mouseButtons[2] = false;

        if (MiddleVR.VRKernel != null)
        {
            MVRTools.Log(3, "[ ] VRKernel already alive, reset Unity Manager.");
            MVRTools.VRReset();
            m_isInit = true;
            // Not needed because this is the first execution of this script instance
            // m_isGeometrySet = false;
            m_FirstFrameAfterReset = MiddleVR.VRKernel.GetFrame();
        }
        else
        {
            if (CustomLicense)
            {
                MVRTools.CustomLicense     = true;
                MVRTools.CustomLicenseName = CustomLicenseName;
                MVRTools.CustomLicenseCode = CustomLicenseCode;
            }

            m_isInit = MVRTools.VRInitialize(ConfigFile);
        }


        if (SimpleClusterParticles)
        {
            _SetParticlesSeeds();
        }

        // Get AA from vrx configuration file
        m_AntiAliasingLevel = (int)MiddleVR.VRDisplayMgr.GetAntiAliasing();

        DumpOptions();

        m_Kernel     = MiddleVR.VRKernel;
        m_DeviceMgr  = MiddleVR.VRDeviceMgr;
        m_DisplayMgr = MiddleVR.VRDisplayMgr;
        m_ClusterMgr = MiddleVR.VRClusterMgr;

        if (SimpleCluster)
        {
            SetupSimpleCluster();
        }

        if (DisableExistingCameras)
        {
            Camera[] cameras = GameObject.FindObjectsOfType(typeof(Camera)) as Camera[];

            foreach (Camera cam in cameras)
            {
                if (cam.targetTexture == null)
                {
                    cam.enabled = false;
                }
            }
        }

        MVRNodesCreator.Instance.CreateNodes(
            VRSystemCenterNode,
            DebugNodes, DebugScreens,
            GrabExistingNodes, TemplateCamera);

        MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, true);

        MVRTools.Log(4, "[<] End of VR initialization script");
    }
    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, "[>] Unity: Starting VR End of Frame.");

        if( kernel == null )
        {
            kernel = MiddleVR.VRKernel;
        }

        if (dmgr == null)
        {
            dmgr = MiddleVR.VRDeviceMgr;
        }

        if(cmgr == null)
        {
            cmgr = MiddleVR.VRClusterMgr;
        }

        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
                    {
                        // If we're not in cluster, we quit when ESCAPE is pressed
                        // If we're in cluster, only the master should quit
                        //if (!cmgr.IsCluster() || (cmgr.IsCluster() && cmgr.IsServer()))
                        {
                            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, "[<] Unity: 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.");
        }
    }
Beispiel #8
0
    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.GetComponent <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.";
        }

        MVRTools.Log(4, "[>] Unity: Starting VR End of Frame.");

        if (kernel == null)
        {
            kernel = MiddleVR.VRKernel;
        }

        if (dmgr == null)
        {
            dmgr = MiddleVR.VRDeviceMgr;
        }

        if (cmgr == null)
        {
            cmgr = MiddleVR.VRClusterMgr;
        }

        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))
                {
                    vrmgr.QuitApplication();
                }
            }
            else
            {
                if (!LoggedNoKeyboard)
                {
                    MVRTools.Log("[X] No VR keyboard");
                    LoggedNoKeyboard = true;
                }
            }
        }

        if (kernel != null)
        {
            /*
             * MVRTools.Log("SavingRT"); ;
             * SaveRT();
             */
            kernel.PostFrameUpdate();
        }

        MVRTools.Log(4, "[<] Unity: End of VR End of Frame.");

        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.");
        }
    }