Esempio n. 1
0
    void ZEDReady()
    {
        //Add the fader
        gameObject.AddComponent <LoadingFade>();
        zedCamera = sl.ZEDCamera.GetInstance();
        SetTextures(zedCamera, viewMode);
        canvas.SetActive(true);
        canvas.transform.SetParent(mainCamera.transform);
        ConfigureLightAndShadow(mainCamera.actualRenderingPath);

        //Move the plane with the optical centers
        float   plane_distance = 0.15f;
        Vector4 opticalCenters = zedCamera.ComputeOpticalCenterOffsets(plane_distance);

        if (side == 0)
        {
            canvas.transform.localPosition = new Vector3(opticalCenters.x, -1.0f * opticalCenters.y, plane_distance);
        }
        else if (side == 1)
        {
            canvas.transform.localPosition = new Vector3(opticalCenters.z, -1.0f * opticalCenters.w, plane_distance);
        }


        //Set the camera parameters and scale the screen
        if (zedCamera.IsCameraReady)
        {
            mainCamera.fieldOfView      = zedCamera.VerticalFieldOfView * Mathf.Rad2Deg;
            mainCamera.projectionMatrix = zedCamera.Projection;
            mainCamera.nearClipPlane    = 0.1f;
            mainCamera.farClipPlane     = 500.0f;
            scale(canvas.gameObject, GetFOVYFromProjectionMatrix(mainCamera.projectionMatrix));
        }
        else
        {
            scale(canvas.gameObject, mainCamera.fieldOfView);
        }
    }