示例#1
0
    private int[] GetJojoMap(DisplayDesc desc)
    {
        int rightShift     = RightShift(desc.m_renderViewCount);
        int numRenderViews = desc.m_renderViewCount;

        int[] map = new int[numRenderViews];
        if (m_jojoEffect)
        {
            int jojo = 0;
            for (int i = 0; i < numRenderViews; i++)
            {
                //pattern for 8 cameras -> [0,1,2,3,4,3,2,1]
                int x = (i < numRenderViews / 2) ? +1 : -1;
                map[i] = jojo + rightShift;
                jojo  += x;
            }
        }
        else
        {
            for (int i = 0; i < numRenderViews; i++)
            {
                map[i] = i; //with the jojo deactivated, there is no maping, the inidices are their identities
            }
        }
        return(map);
    }
示例#2
0
    // used for loading at runtime from menu
    public void LoadConfig(string fileName)
    {
        string jsonFileName = fileName + ".json";
        string jsonFilePath = m_configDirPath + Path.DirectorySeparatorChar + jsonFileName;

        m_screenSettings = JsonUtility.FromJson <DisplayDesc>(File.ReadAllText(jsonFilePath));
        Debug.Log("Read json file from path: " + jsonFilePath);
    }
示例#3
0
    // used for initial automatic screen detection
    private List <DisplayDesc> LoadAllConfigs()
    {
        List <DisplayDesc> configs = new List <DisplayDesc>();

        foreach (string configFilename in Directory.EnumerateFiles(m_configDirPath, "*.json"))
        {
            string      configFile = File.ReadAllText(configFilename);
            DisplayDesc config     = JsonUtility.FromJson <DisplayDesc>(configFile);
            if (string.IsNullOrWhiteSpace(config.m_name))
            {
                FileInfo fileInfo = new FileInfo(configFilename);
                config.m_name = fileInfo.Name.Substring(0, fileInfo.Name.LastIndexOf("."));
            }
            configs.Add(config);
        }

        return(configs);
    }
示例#4
0
    private void Start()
    {
        if (m_uiOverlayTexture == null)
        {
            Debug.LogError("No overlay texture was set");
        }

        m_focusGizmo     = GameObject.Find("AS3D_FOCUS_GIZMO");
        m_zoomFocusGizmo = Instantiate((GameObject)Resources.Load("AS3D/AS3D_FOCUS_GIZMO", typeof(GameObject)), transform);
        m_zoomFocusGizmo.transform.localPosition = Vector3.forward * m_focusDistance;
        m_zoomFocusGizmo.name = "AS3D_ZOOM_FOCUS_GIZMO";

        if (m_focusGizmo != null)
        {
            m_focusGizmo.GetComponent <SpriteRenderer>().enabled = false;
            m_useFocusGizmo = true;
        }
        else
        {
            m_useFocusGizmo = false;
        }

        m_zoomFocusGizmo.GetComponent <SpriteRenderer>().enabled = false;

        m_configDirPath = $"{Application.persistentDataPath}{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}AS3D_Screen_Settings";
        Directory.CreateDirectory(m_configDirPath); // create directory for jsons to be saved in
        WriteDefaultJsonSettings();

        List <string> displayIds = DisplayIdentifier.GetDisplayIDs();

        Debug.Log("Detected displays: " + string.Join(", ", displayIds));

        bool configFound           = false;
        List <DisplayDesc> configs = LoadAllConfigs();

        foreach (string ID in displayIds)
        {
            foreach (DisplayDesc config in configs)
            {
                if (config.m_deviceIds.Contains(ID))
                {
                    m_screenSettings = config;
                    configFound      = true;
                    Debug.Log($"Found config '{config.m_name}' for monitor '{ID}'");
                    break;
                }
            }
        }

        if (!configFound)
        {
            Debug.LogWarning("Could not detect AS3D display or configuration file.");
        }

        m_originalCursorVisibility = Cursor.visible;
        m_originalLockMode         = Cursor.lockState;
        autoStereoUI = GameObject.Find("AutoStereoUI");
        if (autoStereoUI == null)
        {
            Debug.LogWarning("AutoStereoUI not found in scene");
        }
        else
        {
            autoStereoUI.SetActive(false);
            if (m_useFocusGizmo)
            {
                autoStereoUI.GetComponentInChildren <UIBehaviour>().m_focusLengthSlider.interactable = false;
                Debug.Log("Override focus length slider with AS3D_FOCUS_GIZMO in scene");
            }
        }

        m_sourceCamera = GetComponent <Camera>();

        if (m_reconstructView == false)
        {
            m_sourceCamera.cullingMask = 0; // main camera rendering of the scene is disabled
            m_originalClearFlag        = m_sourceCamera.clearFlags;
            m_sourceCamera.clearFlags  = CameraClearFlags.Nothing;
        }

        Shader as3dShader = Shader.Find("Autostereo");

        if (as3dShader != null)
        {
            m_material = new Material(as3dShader);
        }
        else
        {
            Debug.Assert(false, "Autostereo shader could not be found.");
            return;
        }

        m_colorTargets = new RenderTexture[m_maxRenderViews];

        CreateRenderCameras();
    }
示例#5
0
 public int[] getJojoMapAndManageCameras(DisplayDesc desc)
 {
     int[] map = GetJojoMap(desc);
     DeactivateUnusedCameras(desc.m_renderViewCount, map);
     return(map);
 }