示例#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);
        }
示例#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++;
        }
示例#3
0
 private void SetUnityScreenOrientation()
 {
     mScreenOrientation = Screen.orientation;
     SurfaceUtilities.SetSurfaceOrientation(mScreenOrientation);
     // set the native orientation (only required on iOS and WSA)
     setSurfaceOrientationiOS((int)mScreenOrientation);
 }
        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();
            }
        }
示例#5
0
 public void Update()
 {
     if (SurfaceUtilities.HasSurfaceBeenRecreated())
     {
         this.InitializeSurface();
     }
 }
示例#6
0
        private void SetUnityScreenOrientation()
        {
            mScreenOrientation = Screen.orientation;
            SurfaceUtilities.SetSurfaceOrientation(mScreenOrientation);
            // set the native orientation (only required on iOS and WSA)
#if ((UNITY_IPHONE || UNITY_IOS) && !UNITY_EDITOR)
            setSurfaceOrientationiOS((int)mScreenOrientation);
#endif
        }
        private void InitializeSurface()
        {
            SurfaceUtilities.OnSurfaceCreated();

            SetUnityScreenOrientation();

            mScreenWidth  = Screen.width;
            mScreenHeight = Screen.height;
            SurfaceUtilities.OnSurfaceChanged(mScreenWidth, mScreenHeight);
        }
示例#8
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);
        }
示例#9
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();
            }
        }
示例#10
0
 /// <summary>
 /// Called from Update, checks for various life cycle events that need to be forwarded
 /// to Vuforia, 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();
         }
     }
 }
示例#11
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.vuforia.VuforiaUnityPlayer.OrientationUtility");
            }
    #endif

            ResetUnityScreenOrientation();
            CheckOrientation();
        }
示例#12
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);
        }
示例#13
0
        private void CheckOrientation()
        {
            // check for the activity orientation for a few frames after it has changed in Unity
            bool getOrientationFromJava = mFramesSinceLastOrientationReset < NUM_FRAMES_TO_QUERY_ORIENTATION;

            if (!getOrientationFromJava)
            {
                getOrientationFromJava = mFramesSinceLastJavaOrientationCheck > JAVA_ORIENTATION_CHECK_FRM_INTERVAL;
            }

            if (getOrientationFromJava)
            {
                // mScreenOrientation remains at the value reported by Unity even when the activity reports a different one
                // otherwise the check for orientation changes will return true every frame.
                int correctScreenOrientation = (int)mScreenOrientation;

#if UNITY_ANDROID
                if (mCurrentActivity != null)
                {
                    // The orientation reported by Unity is not reliable on some devices (e.g. landscape right on the Nexus 10)
                    // We query the correct orientation from the activity to make sure.
                    int activityOrientation = mJavaOrientationUtility.CallStatic <int>("getSurfaceOrientation", mCurrentActivity);
                    if (activityOrientation != 0)
                    {
                        correctScreenOrientation = activityOrientation;
                    }
                }
    #endif
                ScreenOrientation javaScreenOrientation = (ScreenOrientation)correctScreenOrientation;
                if (javaScreenOrientation != mJavaScreenOrientation)
                {
                    mJavaScreenOrientation = javaScreenOrientation;
                    SurfaceUtilities.SetSurfaceOrientation(mJavaScreenOrientation);
                }

                mFramesSinceLastJavaOrientationCheck = 0;
            }
            else
            {
                mFramesSinceLastJavaOrientationCheck++;
            }
        }
示例#14
0
        /// <summary>
        /// Called from Update, checks for various life cycle events that need to be forwarded
        /// to Vuforia, 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();
            }

            mFramesSinceLastOrientationReset++;
        }
示例#15
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);
        }
示例#16
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);
                }
            }
        }
示例#17
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();
            }
        }
        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);
        }
示例#19
0
        private void InitializeSurface()
        {
            SurfaceUtilities.OnSurfaceCreated();

            SetUnityScreenOrientation();
        }
示例#20
0
 private void InitializeSurface()
 {
     SurfaceUtilities.OnSurfaceCreated();
 }
示例#21
0
 public void InitializePlatform()
 {
     VuforiaWrapper.Instance.InitPlatformNative();
     SurfaceUtilities.SetSurfaceOrientation(UnityEngine.ScreenOrientation.Landscape);
 }