public static LoadResults GetLoadResults()
        {
            // Debug.Log(PlayerPrefs.GetInt(InitKey));
            bool             isInit  = PlayerPrefs.GetInt(InitKey, DEFAULT) > DEFAULT;
            LoadResults      results = new LoadResults(false, false, false);
            hpc_client_error error;

            if (!isInit)
            {
                error = InitHoloPlayCore();
            }
            else
            {
                error = hpc_RefreshState();
            }

            results.attempted = error == hpc_client_error.hpc_CLIERR_NOERROR;
            if (results.attempted)
            {
                int num_displays = hpc_GetNumDevices();
                // TODO: compare json
                bool isChanged = !isInit || PlayerPrefs.GetInt(InitKey, DEFAULT) != num_displays;

                PlayerPrefs.SetInt(InitKey, num_displays);

                if (isChanged)
                {
                    Debug.Log("[HoloPlay] Found: " + num_displays + " Looking Glass" + (num_displays <= 1 ? "" : "es"));
                }

                results.lkgDisplayFound = num_displays > 0;
                if (results.lkgDisplayFound)
                {
                    results.calibrationFound = true;
                    for (int i = 0; i < num_displays; i++)
                    {
                        string str = GetDeviceStatus(i);
                        if (str != "nocalibration")
                        {
                            continue;
                        }
                        Debug.Log("[HoloPlay] No calibration found for Looking Glass:" + GetLKGName(i));
                        results.calibrationFound = false;
                    }
                    // if (results.calibrationFound)
                    CalibrationManager.Init();
                }
            }
            else
            {
                PrintError(error);
            }

            return(results);
        }
示例#2
0
        public static LoadResults GetLoadResults(int i)
        {
            LoadResults results = new LoadResults();

            results.attempted = true;
            // bit 0: loaded from serial flash
            // bit 1: loaded from local storage
            // if either are true, calibration found is true
            results.calibrationFound = (i & 3) != 0;
            // bit 2: lkg display found
            results.lkgDisplayFound = (i & 4) != 0;
            return(results);
        }
示例#3
0
        // functions
        void OnEnable()
        {
            cam           = GetComponent <Camera>();
            cam.hideFlags = HideFlags.HideInInspector;
            lightfieldMat = new Material(Shader.Find("Holoplay/Lightfield"));
            SetupQuilt();
            quiltRT = new RenderTexture(quiltSettings.quiltWidth, quiltSettings.quiltHeight, 0)
            {
                filterMode = FilterMode.Point, hideFlags = HideFlags.DontSave
            };
            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;
            // load calibration
            loadResults = ReloadCalibration();
            if (!loadResults.calibrationFound)
            {
                Debug.Log("[Holoplay] Attempting to load calibration, but none found!");
            }
            if (!loadResults.lkgDisplayFound)
            {
                Debug.Log("[Holoplay] No LKG display detected");
            }
            Screen.SetResolution(cal.screenWidth, cal.screenHeight, true);
            // call initialization event
            if (onHoloplayReady != null)
            {
                onHoloplayReady.Invoke(loadResults);
            }
        }
示例#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++;
            }
        }
示例#5
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);
            }
            else
                #endif
            {
                cam           = GetComponent <Camera>();
                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;
            // load calibration
            loadResults = ReloadCalibration();
            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);

            // setup the quilt
            SetupQuilt();

            // call initialization event
            if (onHoloplayReady != null)
            {
                onHoloplayReady.Invoke(loadResults);
            }
        }