private static string GetSerial(int dev_index)
        {
            StringBuilder str = new StringBuilder(100);

            PluginCore.hpc_GetDeviceSerial(dev_index, str, 100);
            return(str.ToString());
        }
Example #2
0
        static EditorStateTracking()
        {
            PluginCore.Reset();
#if UNITY_2018_1_OR_NEWER
            EditorApplication.quitting += Quitting;
#endif
        }
Example #3
0
        void OnEnable()
        {
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
            Debug.Log("[Holoplay] Multi-display not supported on OSX or Linux.");
            bgCam.enabled          = false;
            canvas.targetDisplay   = 0;
            holoplay.targetDisplay = PluginCore.GetLKGunityIndex(0);
            singleDisplayMode      = true;
#else
            singleDisplayMode = false;
            if (!Application.isEditor)
            {
                singleDisplayMode = Display.displays.Length < 2;
            }

            if (singleDisplayMode)
            {
                Debug.Log("[Holoplay] Extended UI: single display mode");
                bgCam.enabled = false;
                return;
            }
            PluginCore.GetLoadResults();
            if (CalibrationManager.GetCalibrationCount() < 1)
            {
                Debug.Log("[Holoplay] No LKG detected for extended UI");
                bgCam.enabled          = false;
                holoplay.targetDisplay = 0;
                return;
            }
            // continue with actual extended ui logic
            // set Holoplay target display to the lkg display
            holoplay.targetDisplay = PluginCore.GetLKGunityIndex(0);
            holoplay.ReloadCalibration(); // must reload calibration after setting targetdisplay
            if (!Application.isEditor)
            {
                Display.displays[holoplay.targetDisplay].Activate();
                // Display.displays[holoplay.targetDisplay].SetRenderingResolution(holoplay.cal.screenHeight,
                // holoplay.cal.screenHeight);
                // TODO: nothing works here
// #if UNITY_STANDALONE_WIN
//                 Display.displays[holoplay.targetDisplay].SetParams(
//                  holoplay.cal.screenWidth, holoplay.cal.screenHeight,
//                  holoplay.cal.xpos, holoplay.cal.ypos
//              );
//              Debug.LogFormat("{0}, {1}, {2}, {3}",
//                     holoplay.cal.screenWidth, holoplay.cal.screenHeight,
//                  holoplay.cal.xpos, holoplay.cal.ypos);
// #endif
            }

            // set the canvas target display to the main display
            canvas.targetDisplay = 0;
            if (bgCam)
            {
                bgCam.enabled       = true;
                bgCam.targetDisplay = 0;
            }
#endif
        }
        private static string GetLKGName(int dev_index)
        {
            StringBuilder str = new StringBuilder(100);

            PluginCore.hpc_GetDeviceHDMIName(dev_index, str, 100);
            // Debug.Log(" Device name: " + str);
            return(str.ToString());
        }
Example #5
0
 void Update()
 {
     if (!singleDisplayMode)
     {
         if (holoplay == null)
         {
             Debug.LogWarning("[Holoplay] No holoplay detected for extended UI!");
             enabled = false;
             return;
         }
         holoplay.targetDisplay = PluginCore.GetLKGunityIndex(0);
         if (bgCam && bgCam.enabled && copyBGCamSettings)
         {
             bgCam.CopyFrom(holoplay.cam);
             bgCam.targetDisplay = 0;
         }
     }
 }
Example #6
0
        static void CloseExtraHoloplayWindows()
        {
            var currentWindows = Resources.FindObjectsOfTypeAll(gameViewWindowType);

            PluginCore.GetLoadResults();

            if (manualPreviewSettings != null && CalibrationManager.GetCalibrationCount() < 1)
            {
                foreach (EditorWindow w in currentWindows)
                {
                    if (w.name == "Holoplay")
                    {
                        w.Close();
                        Debug.Log("[Holoplay] Closing extra Holoplay window");
                    }
                }
            }
            EditorApplication.update -= CloseExtraHoloplayWindows;
        }
        // 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;
        }
Example #8
0
        // functions
        void OnEnable()
        {
#if UNITY_POST_PROCESSING_STACK_V2
            PostProcessLayer postLayer = GetComponent <PostProcessLayer>();
            if (postLayer != null && postLayer.enabled)
            {
                postProcessCam           = GetComponent <Camera>();
                postProcessCam.hideFlags = HideFlags.HideInInspector;
                var camGO = new GameObject(postProcessCamName);
                camGO.hideFlags = HideFlags.HideAndDontSave;
                camGO.transform.SetParent(transform);
                camGO.transform.localPosition = Vector3.zero;
                camGO.transform.localRotation = Quaternion.identity;
                cam = camGO.AddComponent <Camera>();
                cam.CopyFrom(postProcessCam);
                Debug.Log("set up cam");
            }
            else
#endif
            {
                cam = GetComponent <Camera>();
                //Debug.Log("set up cam"+cam.projectionMatrix);
                cam.hideFlags = HideFlags.HideInInspector;
            }
            lightfieldMat = new Material(Shader.Find("Holoplay/Lightfield"));
            instance      = this;        // most recently enabled Capture set as instance
            // lightfield camera (only does blitting of the quilt into a lightfield)
            var lightfieldCamGO = new GameObject(lightfieldCamName);
            lightfieldCamGO.hideFlags = HideFlags.HideAndDontSave;
            lightfieldCamGO.transform.SetParent(transform);
            var lightfieldPost = lightfieldCamGO.AddComponent <LightfieldPostProcess>();
            lightfieldPost.holoplay = this;
            lightfieldCam           = lightfieldCamGO.AddComponent <Camera>();
#if UNITY_2017_3_OR_NEWER
            lightfieldCam.allowDynamicResolution = false;
#endif
            lightfieldCam.allowHDR    = false;
            lightfieldCam.allowMSAA   = false;
            lightfieldCam.cullingMask = 0;
            lightfieldCam.clearFlags  = CameraClearFlags.Nothing;

#if !UNITY_EDITOR
            if (instance == null)
            {
                Debug.Log("empty when running");
            }
#endif
            ReloadCalibration();

            // // load calibration
            // if (!loadResults.calibrationFound)
            //  Debug.Log("[HoloPlay] Attempting to load calibration, but none found!");
            // if (!loadResults.lkgDisplayFound)
            //  Debug.Log("[HoloPlay] No LKG display detected");

            // setup the window to play on the looking glass
            Screen.SetResolution(cal.screenWidth, cal.screenHeight, true);
#if UNITY_2019_3_OR_NEWER
            if (!Application.isEditor && targetDisplay == 0)
            {
#if UNITY_STANDALONE_OSX
                targetDisplay = PluginCore.GetLKGunityIndex(targetLKG);
                lightfieldCam.targetDisplay = targetDisplay;
                Display.displays[targetDisplay].Activate();
#else
                Display.displays[targetDisplay].Activate(0, 0, 0);

#if UNITY_STANDALONE_WIN
                Display.displays[targetDisplay].SetParams(
                    cal.screenWidth, cal.screenHeight,
                    cal.xpos, cal.ypos
                    );
                // Debug.Debug.LogFormat("{0}, {1}, {2}, {3}", cal.screenWidth, cal.screenHeight,
                //  cal.xpos, cal.ypos)
#endif
#endif
            }
#endif

            // setup the quilt
            SetupQuilt();

            // call initialization event
            if (onHoloplayReady != null)
            {
                onHoloplayReady.Invoke(loadResults);
            }
        }
 void OnEnable()
 {
     PluginCore.GetLoadResults();
 }
Example #10
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++;
            }
        }
 public static void Init()
 {
     // Debug.Log("init calibrations");
     calibrations = PluginCore.GetCalibrationArray();
     isInit       = calibrations.Length > 0;
 }
Example #12
0
        public static void HandlePreview(bool toggling = true)
        {
            // set standalone resolution
            // PluginCore.GetLoadResults();
            if (Holoplay.Instance != null)
            {
                Holoplay.Instance.ReloadCalibration();
            }
            else
            {
                PluginCore.GetLoadResults();
            }

            // close the window if its open
            var  currentWindows = Resources.FindObjectsOfTypeAll(gameViewWindowType);
            bool windowWasOpen  = false;

            foreach (EditorWindow w in currentWindows)
            {
                if (w.name == "Holoplay")
                {
                    w.Close();
                    windowWasOpen = true;
                }
                else
                {
                    // to avoid ugliness, if there is a game window open
                    // make sure it takes the same resolution
                    SetResolution(w);
                }
            }
            if (toggling)
            {
                if (windowWasOpen)
                {
                    return;
                }
            }
            else
            {
                if (!windowWasOpen)
                {
                    return;
                }
            }

            /*
             *      logic for multiplexing
             *      - get number of holoplays in the scene
             *      - for the target display of each Holoplay
             *              - create a window on that display
             *              - just assign
             */
            var hps = GameObject.FindObjectsOfType <Holoplay>();

            // open up a preview in the looking glass even if no holoplays found
            if (hps.Length == 0)
            {
                SetupPreviewWindow(new Calibration(0), 0, 0);
            }
            foreach (var hp in hps)
            {
                // Debug.Log(string.Format("set up preview window for lkg index {0}, target lkg {1}, target display {2}, {3}", hp.cal.index, hp.targetLKG, hp.targetDisplay, hp.name));
                SetupPreviewWindow(hp.cal, hp.targetLKG, hp.targetDisplay);
            }
        }
Example #13
0
 static void Quitting()
 {
     // Debug.Log("Editor quitting");
     PluginCore.Reset();
 }