protected void ComputeViewPortRect(int leftCameraViewPortHeight, int leftCameraViewPortWidth)
        {
            float num  = CameraConfigurationUtility.ExtractVerticalCameraFoV(this.mPrimaryCamera.projectionMatrix.inverse) * 0.0174532924f;
            float num2 = (float)(Math.Tan((double)(CameraDevice.Instance.GetCameraFieldOfViewRads().y / 2f)) / Math.Tan((double)(num / 2f)));
            float num3 = (float)leftCameraViewPortHeight * num2;

            CameraDevice.VideoModeData videoMode          = CameraDevice.Instance.GetVideoMode(this.mCameraDeviceMode);
            ScreenOrientation          surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            float num4;

            if (surfaceOrientation == ScreenOrientation.Landscape || surfaceOrientation == ScreenOrientation.LandscapeLeft || surfaceOrientation == ScreenOrientation.LandscapeRight)
            {
                num4 = num3 * (float)videoMode.width / (float)videoMode.height;
            }
            else
            {
                num4 = num3 * (float)videoMode.height / (float)videoMode.width;
            }
            int num5 = (leftCameraViewPortWidth - (int)num4) / 2;
            int num6 = (leftCameraViewPortHeight - (int)num3) / 2;

            this.mVideoBackgroundViewportRect = new Rect((float)num5, (float)num6, (float)((int)num4), (float)((int)num3));
            if (base.IsVideoBackgroundEnabled())
            {
                this.mVideoBackgroundBehaviours[this.mPrimaryCamera].ApplyStereoDepthToMatrices();
                this.mVideoBackgroundBehaviours[this.mSecondaryCamera].ApplyStereoDepthToMatrices();
            }
        }
예제 #2
0
        public bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            int pixelHeightInt = this.mPrimaryCamera.GetPixelHeightInt();
            int pixelWidthInt  = this.mPrimaryCamera.GetPixelWidthInt();
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (pixelHeightInt != this.mCameraViewPortHeight || pixelWidthInt != this.mCameraViewPortWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mCameraViewPortHeight  = pixelHeightInt;
                this.mCameraViewPortWidth   = pixelWidthInt;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mCameraViewPortWidth, this.mCameraViewPortHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            return(result);
        }
예제 #3
0
        public bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool expr_12 = this.mProjectionOrientation != surfaceOrientation;

            if (expr_12)
            {
                this.mProjectionOrientation = surfaceOrientation;
            }
            orientation = this.mProjectionOrientation;
            return(expr_12);
        }
예제 #4
0
        public virtual void ConfigureVideoBackground()
        {
            Device.Instance.DeleteRenderingPrimitives();
            VuforiaRenderer.VideoBGCfgData videoBackgroundConfig = VuforiaRenderer.Instance.GetVideoBackgroundConfig();
            CameraDevice.VideoModeData     videoMode             = CameraDevice.Instance.GetVideoMode(this.mCameraDeviceMode);
            videoBackgroundConfig.enabled    = 1;
            videoBackgroundConfig.position   = new VuforiaRenderer.Vec2I(0, 0);
            videoBackgroundConfig.reflection = VuforiaRenderer.InternalInstance.GetLastSetReflection();
            bool flag;

            if (VuforiaRuntimeUtilities.IsPlayMode())
            {
                flag = true;
            }
            else
            {
                ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
                flag = (surfaceOrientation == ScreenOrientation.Landscape || surfaceOrientation == ScreenOrientation.LandscapeLeft || surfaceOrientation == ScreenOrientation.LandscapeRight);
            }
            if (flag)
            {
                float num = (float)videoMode.height * ((float)this.mCameraViewPortWidth / (float)videoMode.width);
                videoBackgroundConfig.size = new VuforiaRenderer.Vec2I(this.mCameraViewPortWidth, (int)num);
                if (videoBackgroundConfig.size.y < this.mCameraViewPortHeight)
                {
                    videoBackgroundConfig.size.x = (int)((float)this.mCameraViewPortHeight * ((float)videoMode.width / (float)videoMode.height));
                    videoBackgroundConfig.size.y = this.mCameraViewPortHeight;
                }
            }
            else
            {
                float num2 = (float)videoMode.height * ((float)this.mCameraViewPortHeight / (float)videoMode.width);
                videoBackgroundConfig.size = new VuforiaRenderer.Vec2I((int)num2, this.mCameraViewPortHeight);
                if (videoBackgroundConfig.size.x < this.mCameraViewPortWidth)
                {
                    videoBackgroundConfig.size.x = this.mCameraViewPortWidth;
                    videoBackgroundConfig.size.y = (int)((float)this.mCameraViewPortWidth * ((float)videoMode.width / (float)videoMode.height));
                }
            }
            VuforiaRenderer.InternalInstance.SetVideoBackgroundConfigInternal(videoBackgroundConfig);
            int num3 = videoBackgroundConfig.position.x + (this.mCameraViewPortWidth - videoBackgroundConfig.size.x) / 2;
            int num4 = videoBackgroundConfig.position.y + (this.mCameraViewPortHeight - videoBackgroundConfig.size.y) / 2;

            this.mVideoBackgroundViewportRect        = new Rect((float)num3, (float)num4, (float)videoBackgroundConfig.size.x, (float)videoBackgroundConfig.size.y);
            this.mLastVideoBackGroundMirroredFromSDK = VuforiaRenderer.Instance.GetVideoBackgroundConfig().reflection;
            this.UpdateProjection();
            if (this.mOnVideoBackgroundConfigChanged != null)
            {
                this.mOnVideoBackgroundConfigChanged();
            }
        }
예제 #5
0
        public bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (Screen.height != this.mScreenHeight || Screen.width != this.mScreenWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mScreenWidth           = Screen.width;
                this.mScreenHeight          = Screen.height;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mScreenWidth, this.mScreenHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            if (Math.Abs(this.mSecondaryCamera.fieldOfView - this.mPrimaryCamera.fieldOfView) > 0.01f)
            {
                Debug.LogWarning("Field of view values of left and right camera are not identical. This is currently not supported by Vuforia!");
            }
            if (Math.Abs(this.mSecondaryCamera.nearClipPlane - this.mPrimaryCamera.nearClipPlane) > 0.01f || Math.Abs(this.mSecondaryCamera.farClipPlane - this.mPrimaryCamera.farClipPlane) > 0.01f)
            {
                Debug.LogWarning("Clip plane positions of left and right camera are not identical. This is currently not supported by Vuforia!");
            }
            if (this.mNeedToCheckStereo && this.mEyewearDevice.IsDualDisplay() && !this.mEyewearDevice.IsDisplayExtended())
            {
                if (this.mSecondaryCamera != null)
                {
                    Debug.Log("Detecting stereo camera setup, setting stereo mode.");
                    this.mEyewearDevice.SetDisplayExtended(true);
                }
                else
                {
                    Debug.LogWarning("Device is a stereo capable eyewear device, but only one camera has been set up.");
                }
                this.mNeedToCheckStereo = false;
            }
            return(result);
        }
        public virtual bool CheckForSurfaceChanges(out ScreenOrientation orientation)
        {
            ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
            bool result = false;

            if (Screen.height != this.mScreenHeight || Screen.width != this.mScreenWidth || this.mProjectionOrientation != surfaceOrientation)
            {
                this.mScreenWidth           = Screen.width;
                this.mScreenHeight          = Screen.height;
                this.mProjectionOrientation = surfaceOrientation;
                SurfaceUtilities.OnSurfaceChanged(this.mScreenWidth, this.mScreenHeight);
            }
            CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;

            if (cameraDeviceImpl.CameraReady && (VuforiaUnity.IsRendererDirty() || this.CameraParameterChanged()))
            {
                this.ConfigureVideoBackground();
                cameraDeviceImpl.ResetDirtyFlag();
                result = true;
                this.mCameraParameterChanged = false;
            }
            orientation = this.mProjectionOrientation;
            return(result);
        }
예제 #7
0
        public void ConfigureVideoBackground()
        {
            Device.Instance.DeleteRenderingPrimitives();
            VuforiaRenderer.VideoBGCfgData videoBackgroundConfig = VuforiaRenderer.Instance.GetVideoBackgroundConfig();
            CameraDevice.VideoModeData     videoMode             = CameraDevice.Instance.GetVideoMode(this.mCameraDeviceMode);
            videoBackgroundConfig.enabled  = 1;
            videoBackgroundConfig.position = new VuforiaRenderer.Vec2I(0, 0);
            float num  = (float)this.mScreenHeight;
            float num2 = (float)this.mScreenWidth;

            if (!this.mEyewearDevice.IsSeeThru())
            {
                ScreenOrientation surfaceOrientation = SurfaceUtilities.GetSurfaceOrientation();
                if (surfaceOrientation == ScreenOrientation.Landscape || surfaceOrientation == ScreenOrientation.LandscapeLeft || surfaceOrientation == ScreenOrientation.LandscapeRight)
                {
                    num2 = num * (float)videoMode.width / (float)videoMode.height;
                }
                else
                {
                    num2 = num * (float)videoMode.height / (float)videoMode.width;
                }
            }
            videoBackgroundConfig.size       = new VuforiaRenderer.Vec2I((int)num2, (int)num);
            videoBackgroundConfig.reflection = VuforiaRenderer.VideoBackgroundReflection.OFF;
            VuforiaRenderer.InternalInstance.SetVideoBackgroundConfigInternal(videoBackgroundConfig);
            int num3 = videoBackgroundConfig.position.x + (this.mScreenWidth - videoBackgroundConfig.size.x) / 2;
            int num4 = videoBackgroundConfig.position.y + (this.mScreenHeight - videoBackgroundConfig.size.y) / 2;

            this.mVideoBackgroundViewportRect        = new Rect((float)num3, (float)num4, (float)videoBackgroundConfig.size.x, (float)videoBackgroundConfig.size.y);
            this.mLastVideoBackGroundMirroredFromSDK = VuforiaRenderer.Instance.GetVideoBackgroundConfig().reflection;
            this.UpdateProjection();
            if (this.mOnVideoBackgroundConfigChanged != null)
            {
                this.mOnVideoBackgroundConfigChanged();
            }
        }