private void ConfigureView()
        {
            EyewearDevice eyewearDevice = Device.Instance as EyewearDevice;
            bool          arg_4E_0      = Device.Instance.IsViewerActive() || (eyewearDevice != null && eyewearDevice.IsDualDisplay());
            bool          flag          = this.mCentralAnchorPoint != base.VuforiaBehaviour.transform && this.mCentralAnchorPoint != null;

            if (!arg_4E_0)
            {
                if (this.mSecondaryCamera && this.mSecondaryCamera.enabled)
                {
                    this.mPrimaryCameraOriginalRect      = new Rect(this.mPrimaryCamera.rect);
                    this.mSecondaryCameraOriginalRect    = new Rect(this.mSecondaryCamera.rect);
                    this.mSecondaryCamera.enabled        = false;
                    this.mSecondaryCameraDisabledLocally = true;
                    this.DisableDistortionRendering();
                    Rect rect = new Rect(0f, 0f, 1f, 1f);
                    this.mPrimaryCamera.rect        = rect;
                    this.mPrimaryCamera.fieldOfView = 60f;
                }
            }
            else
            {
                if (this.mSecondaryCamera && !this.mSecondaryCamera.enabled)
                {
                    if (!flag)
                    {
                        this.mSecondaryCamera.enabled = true;
                    }
                    if (this.mSecondaryCameraDisabledLocally)
                    {
                        this.mSecondaryCameraDisabledLocally = false;
                        this.mPrimaryCamera.rect             = this.mPrimaryCameraOriginalRect;
                        this.mSecondaryCamera.rect           = this.mSecondaryCameraOriginalRect;
                    }
                }
                if (!flag && this.mSecondaryCamera == null)
                {
                    this.mPrimaryCamera.name = "StereoCameraLeft";
                    this.mPrimaryCamera.rect = new Rect(0f, 0f, 0.5f, 1f);
                    this.mSecondaryCamera    = UnityEngine.Object.Instantiate <Camera>(this.mPrimaryCamera);
                    this.mSecondaryCamera.transform.parent        = this.mPrimaryCamera.transform.parent;
                    this.mSecondaryCamera.transform.localPosition = this.mPrimaryCamera.transform.localPosition;
                    this.mSecondaryCamera.transform.localRotation = this.mPrimaryCamera.transform.localRotation;
                    this.mSecondaryCamera.transform.localScale    = this.mPrimaryCamera.transform.localScale;
                    this.mSecondaryCamera.name = "StereoCameraRight";
                    this.mSecondaryCamera.rect = new Rect(0.5f, 0f, 0.5f, 1f);
                    BackgroundPlaneAbstractBehaviour componentInChildren = this.mSecondaryCamera.GetComponentInChildren <BackgroundPlaneAbstractBehaviour>();
                    if (componentInChildren != null)
                    {
                        UnityEngine.Object.Destroy(componentInChildren.gameObject);
                    }
                    VideoBackgroundAbstractBehaviour component = this.mSecondaryCamera.GetComponent <VideoBackgroundAbstractBehaviour>();
                    if (component != null)
                    {
                        component.DisconnectFromBackgroundBehaviour();
                    }
                }
            }
            if (this.mPrimaryCamera && VuforiaARController.IsValidPrimaryCamera(this.mPrimaryCamera))
            {
                this.mPrimaryCamera.transform.localRotation = Quaternion.identity;
                this.mPrimaryCamera.transform.localScale    = Vector3.one;
                if (this.mSecondaryCamera && (flag || this.mSecondaryCamera.enabled) && VuforiaARController.IsValidSecondaryCamera(this.mSecondaryCamera))
                {
                    this.mSecondaryCamera.transform.localRotation = Quaternion.identity;
                    this.mSecondaryCamera.transform.localScale    = Vector3.one;
                    if (flag)
                    {
                        this.CameraConfiguration = new ExternalStereoCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera);
                        Debug.Log("Creating an External Stereo Camera Configuration (Check for reflection)");
                    }
                    else if (eyewearDevice != null)
                    {
                        this.CameraConfiguration = new DedicatedEyewearCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera);
                        Debug.Log("Creating a Dedicated Eyewear Camera Configuration (Check for reflection)");
                    }
                    else
                    {
                        this.CameraConfiguration = new StereoViewerCameraConfiguration(this.mPrimaryCamera, this.mSecondaryCamera, this.mCameraOffset, this.mDistortionRenderingMode > DistortionRenderingMode.None);
                        Debug.Log("Creating a Stereo Viewer Camera Configuration (Check for reflection)");
                        this.EnableDistortionRendering();
                    }
                }
                else
                {
                    this.CameraConfiguration = new MonoCameraConfiguration(this.mPrimaryCamera);
                    Debug.Log("Creating a Mono Camera Configuration (Check for reflection)");
                }
            }
            else
            {
                this.CameraConfiguration = new NullCameraConfiguration();
                Debug.Log("Creating a Null Camera Configuration (Check for reflection)");
            }
            this.mVuforiaBehaviour.InitCameraConfiguration();
            this.CameraConfiguration.Init();
            if (this.mPrimaryCamera != null)
            {
                HideExcessAreaAbstractBehaviour component2 = this.mPrimaryCamera.GetComponent <HideExcessAreaAbstractBehaviour>();
                if (component2)
                {
                    component2.OnConfigurationChanged();
                }
            }
            if (this.mSecondaryCamera != null)
            {
                HideExcessAreaAbstractBehaviour component3 = this.mSecondaryCamera.GetComponent <HideExcessAreaAbstractBehaviour>();
                if (component3)
                {
                    component3.OnConfigurationChanged();
                }
            }
        }
Exemple #2
0
 public CameraService(ILogger logger, ICommandBus bus, ICameraConfiguration cameraConfiguration)
 {
     _logger = logger;
     _bus    = bus;
     _cameraConfiguration = cameraConfiguration;
 }