Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called from Update, checks for various life cycle events that need to be forwarded
        /// to QCAR, e.g. orientation changes
        /// </summary>
        public void Update()
        {
            if (SurfaceUtilities.HasSurfaceBeenRecreated())
            {
                InitializeSurface();
            }
            else
            {
                // if Unity reports that the orientation has changed, reset the member variable
                // - this will trigger a check in Java for a few frames...
                if (Screen.orientation != mScreenOrientation)
                {
                    ResetUnityScreenOrientation();
                }

                CheckOrientation();

                if (mScreenWidth != Screen.width || mScreenHeight != Screen.height)
                {
                    mScreenWidth  = Screen.width;
                    mScreenHeight = Screen.height;
                    SurfaceUtilities.OnSurfaceChanged(mScreenWidth, mScreenHeight);
                }
            }

            mFramesSinceLastOrientationReset++;
        }
Exemplo n.º 3
0
        private void InitializeSurface()
        {
            SurfaceUtilities.OnSurfaceCreated();

            SetUnityScreenOrientation();

            mScreenWidth  = Screen.width;
            mScreenHeight = Screen.height;
            SurfaceUtilities.OnSurfaceChanged(mScreenWidth, mScreenHeight);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        private void InitializeSurface()
        {
            SurfaceUtilities.OnSurfaceCreated();

    #if UNITY_ANDROID
            AndroidJavaClass javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            mCurrentActivity = javaUnityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            if (mCurrentActivity != null)
            {
                mJavaOrientationUtility = new AndroidJavaClass("com.qualcomm.QCARUnityPlayer.OrientationUtility");
            }
    #endif

            ResetUnityScreenOrientation();
            CheckOrientation();

            mScreenWidth  = Screen.width;
            mScreenHeight = Screen.height;
            SurfaceUtilities.OnSurfaceChanged(mScreenWidth, mScreenHeight);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Called from Update, checks for various life cycle events that need to be forwarded
        /// to QCAR, e.g. orientation changes
        /// </summary>
        public void Update()
        {
            if (SurfaceUtilities.HasSurfaceBeenRecreated())
            {
                InitializeSurface();
            }
            else
            {
                // if Unity reports that the orientation has changed, set it correctly in native
                if (Screen.orientation != mScreenOrientation)
                {
                    SetUnityScreenOrientation();
                }

                if (mScreenWidth != Screen.width || mScreenHeight != Screen.height)
                {
                    mScreenWidth  = Screen.width;
                    mScreenHeight = Screen.height;
                    SurfaceUtilities.OnSurfaceChanged(mScreenWidth, mScreenHeight);
                }
            }
        }
        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);
        }