Пример #1
0
        static void SetupPreviewWindow(Calibration cal, int targetLKG, int targetDisplay)
        {
            bool isMac = Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.LinuxEditor;

            if (UnityEditor.PlayerSettings.defaultScreenWidth != cal.screenWidth)
            {
                UnityEditor.PlayerSettings.defaultScreenWidth = cal.screenWidth;
            }
            if (UnityEditor.PlayerSettings.defaultScreenHeight != cal.screenHeight)
            {
                UnityEditor.PlayerSettings.defaultScreenHeight = cal.screenHeight;
            }
            // otherwise create one
            gameViewWindow      = (EditorWindow)EditorWindow.CreateInstance(gameViewWindowType);
            gameViewWindow.name = "Holoplay";
            if (!isMac)
            {
                var showModeType     = typeof(Editor).Assembly.GetType("UnityEditor.ShowMode");
                var showWithModeInfo = gameViewWindowType.GetMethod("ShowWithMode", bindingFlags);
                showWithModeInfo.Invoke(gameViewWindow, new [] { Enum.ToObject(showModeType, 1) });
            }
            else
            {
                if (windowInitialized == 2)
                {
                    EditorApplication.update += UpdateWindowPos;
                    windowInitialized         = 1;
                }
                gameViewWindow = EditorWindow.GetWindow(gameViewWindowType);
            }
            // set window size and position
            gameViewWindow.maxSize = new Vector2(cal.screenWidth, cal.screenHeight + tabSize);
            gameViewWindow.minSize = gameViewWindow.maxSize;
            int xpos = CalibrationManager.GetCalibration(targetLKG).xpos;
            int ypos = CalibrationManager.GetCalibration(targetLKG).ypos;

            // Debug.Log("set up preview window on target lkg:" + targetDisplay  + " (" + xpos + "," + ypos);
            // Debug.Log("targetLKG:" + targetLKG + " x:" + xpos + " y:" + ypos);
            if (manualPreviewSettings != null && manualPreviewSettings.manualPosition)
            {
                xpos = manualPreviewSettings.position.x;
                ypos = manualPreviewSettings.position.y;
            }
            gameViewWindow.position = new Rect(
                xpos, ypos - tabSize, gameViewWindow.maxSize.x, gameViewWindow.maxSize.y);
            // set the zoom and resolution
            SetZoom(gameViewWindow);
            SetResolution(gameViewWindow);
            // set display number
#if UNITY_2019_3_OR_NEWER
            gameViewWindowType.GetMethod("set_targetDisplay", bindingFlags).Invoke(gameViewWindow, new object[] { targetDisplay });
#else
            var displayNum = gameViewWindowType.GetField("m_TargetDisplay", bindingFlags);
            displayNum.SetValue(gameViewWindow, targetDisplay);
#endif
        }
Пример #2
0
        // todo: possibly add more vars from the Holoplay for consistency

        // functions
        void OnEnable()
        {
            PluginCore.GetLoadResults();

            // update warning
            int i;

            showUpdateWarning = false;
            for (i = 0; i < CalibrationManager.GetCalibrationCount(); i++)
            {
                if (CalibrationManager.GetCalibration(i).LKGname == "LKG")
                {
                    showUpdateWarning = true;
                }
            }
            initialSetup = true;
            // Debug.Log("onenable");
            Setup(initialSetup);
            initialSetup = false;
        }
Пример #3
0
        // this won't work for multiple monitors
        // but multi-display doesn't work on mac anyway

        static void UpdateWindowPos()
        {
            if (windowInitialized > 0)
            {
                windowInitialized--;
            }
            else
            {
                int xpos = CalibrationManager.GetCalibration(0).xpos;
                int ypos = CalibrationManager.GetCalibration(0).ypos;
                if (manualPreviewSettings != null && manualPreviewSettings.manualPosition)
                {
                    xpos = manualPreviewSettings.position.x;
                    ypos = manualPreviewSettings.position.y;
                }
#if UNITY_2019_3_OR_NEWER && (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
#else
                gameViewWindow.position = new Rect(
                    xpos, ypos - 22,
                    gameViewWindow.maxSize.x, gameViewWindow.maxSize.y);
#endif
                EditorApplication.update -= UpdateWindowPos;
            }
        }
Пример #4
0
        void Setup(bool reloadCalibration = false)
        {
            // Debug.Log("set up multiplxing");
            // if there's no holoplays, just return
            if (holoplays == null || holoplays.Length == 0)
            {
                return;
            }
            // limit rows and columns to 8 units
            columns = Mathf.Clamp(columns, 1, 8);
            rows    = Mathf.Clamp(rows, 1, 8 / columns);
            if (holoplays.Length > 8)
            {
                Debug.Log("[Holoplay] Multiplex cannot support more than 8 Holoplay Captures");
                System.Array.Resize(ref holoplays, 8);
            }
            // return if it's not automatic arrangement
            if (!automaticArrangement)
            {
                return;
            }

            LoadResults loadResults = PluginCore.GetLoadResults();

            if (!loadResults.calibrationFound)
            {
                return;
            }
            // first sort displays
            List <DisplayPositioner> targetDisplayPositions = new List <DisplayPositioner>();

            for (int lkg = 0; lkg < CalibrationManager.GetCalibrationCount(); lkg++)
            {
                targetDisplayPositions.Add(new DisplayPositioner()
                {
                    targetLKG     = lkg,
                    targetDisplay = PluginCore.GetLKGunityIndex(lkg),
                    position      = new Vector2Int(
                        Mathf.RoundToInt(CalibrationManager.GetCalibration(lkg).xpos / 100f),
                        Mathf.RoundToInt(CalibrationManager.GetCalibration(lkg).ypos / 100f)
                        )
                });
            }
            targetDisplayPositions.Sort();

            // automatic arrangement
            int   i = 0;
            float totalCenterSweep      = 0f;
            float horizontalOffsetSweep = 0f;
            float verticalOffsetSweep   = 0f;

            if (columns > 1)
            {
                // hard coded magic number of 8 for now
                totalCenterSweep      = 8f * Holoplay.Instance.cal.aspect * (columns - 1f) / Holoplay.Instance.cal.viewCone;
                horizontalOffsetSweep = 2f * (columns - 1f);
            }
            if (rows > 1)
            {
                verticalOffsetSweep = -2f * (rows - 1f);                 // -Holoplay.Instance.fov * 0.5f * (rows - 1f);
            }
            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    var h = holoplays[i];
                    h.gameObject.SetActive(true);
                    h.size = size;
                    int   yi      = rows - 1 - y;
                    float xOffset = x - (columns - 1) * 0.5f;
                    float yOffset = yi - (rows - 1) * 0.5f;
                    float span    = size * (1f + separation);
                    h.transform.localPosition = new Vector3(2f * xOffset * h.cal.aspect * span, 2f * yOffset * span);
                    float offsetLerpX = columns > 1 ? ((float)x / (columns - 1f) - 0.5f) : 0f;
                    float offsetLerpY = rows > 1 ? ((float)y / (rows - 1f) - 0.5f) : 0f;
                    h.centerOffset            = offsetLerpX * totalCenterSweep * frustumShifting;
                    h.horizontalFrustumOffset = offsetLerpX * horizontalOffsetSweep * frustumShifting;
                    h.verticalFrustumOffset   = offsetLerpY * verticalOffsetSweep * frustumShifting;
                    if (reloadCalibration)
                    {
                        if (targetDisplayPositions.Count > i)
                        {
                            h.targetDisplay = targetDisplayPositions[i].targetDisplay;
                            h.targetLKG     = targetDisplayPositions[i].targetLKG;
                            h.cal.index     = h.targetLKG;
                            // Debug.Log(h.name + " is set to be target at display " + h.targetDisplay);
                            h.ReloadCalibration();
                            if (Display.displays.Length > h.targetDisplay)
                            {
                                // Debug.Log("active display:"+h.targetDisplay);
                                Display.displays[h.targetDisplay].Activate();
                                Display.displays[h.targetDisplay].SetRenderingResolution(h.cal.screenWidth, h.cal.screenHeight);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("[Holoplay] Not enough displays connected for current multiview setup");
                        }
                    }
                    i++;
                }
            }
            // disable the inactive ones
            while (i < 8)
            {
                holoplays[i].gameObject.SetActive(false);
                i++;
            }
        }