Ejemplo n.º 1
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;
        }

        MiddleVRTools.IsEditor = Application.isEditor;

        if (MiddleVR.VRKernel != null)
        {
            MiddleVRTools.Log(3, "[ ] VRKernel already alive, reset Unity Manager.");
            MiddleVRTools.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
        {
            m_isInit = MiddleVRTools.VRInitialize(ConfigFile);
        }

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

        DumpOptions();

        kernel     = MiddleVR.VRKernel;
        displayMgr = MiddleVR.VRDisplayMgr;

        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 = kernel.GetLogString(true);
            print(txt);
            m_GUI.text = txt;

            return;
        }

        if (SimpleCluster)
        {
            SetupSimpleCluster();
        }

        if (ChangeWorldScale)
        {
            displayMgr.SetChangeWorldScale(true);
            displayMgr.SetWorldScale(WorldScale);
        }

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

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

        MiddleVRTools.CreateNodes(RootNode, DebugNodes, DebugScreens, GrabExistingNodes, TemplateCamera);
        MiddleVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA);

        //AttachCameraCB();

        MiddleVRTools.Log(4, "[<] End of VR initialization script");
    }
Ejemplo n.º 2
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;
        }

        MiddleVRTools.IsEditor = Application.isEditor;

        m_isInit = MiddleVRTools.VRInitialize(ConfigFile);

        DumpOptions();

        kernel     = MiddleVR.VRKernel;
        displayMgr = MiddleVR.VRDisplayMgr;

        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 = kernel.GetLogString(true);
            print(txt);
            m_GUI.text = txt;

            return;
        }

        if (SimpleCluster)
        {
            SetupSimpleCluster();
        }

        if (ChangeWorldScale)
        {
            displayMgr.SetChangeWorldScale(true);
            displayMgr.SetWorldScale(WorldScale);
        }

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

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

        MiddleVRTools.CreateNodes(RootNode, DebugNodes, DebugScreens, GrabExistingNodes, TemplateCamera);
        MiddleVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry);

        //AttachCameraCB();

        MiddleVRTools.Log(4, "[<] End of VR initialization script");
    }