示例#1
0
 public DedicatedEyewearCameraConfiguration(Camera leftCamera, Camera rightCamera) : base(leftCamera.GetComponent <BackgroundPlaneAbstractBehaviour>())
 {
     this.mPrimaryCamera    = leftCamera;
     this.mSecondaryCamera  = rightCamera;
     this.mNewNearClipPlane = leftCamera.nearClipPlane;
     this.mNewFarClipPlane  = leftCamera.farClipPlane;
     this.mNewVirtualFoV    = leftCamera.fieldOfView;
     this.mEyewearDevice    = (Device.Instance as EyewearDevice);
 }
        public override bool Init()
        {
            this.mTrackableResultDataArray   = new VuforiaManagerImpl.TrackableResultData[0];
            this.mWordDataArray              = new VuforiaManagerImpl.WordData[0];
            this.mWordResultDataArray        = new VuforiaManagerImpl.WordResultData[0];
            this.mTrackableFoundQueue        = new LinkedList <VuforiaManager.TrackableIdPair>();
            this.mImageHeaderData            = IntPtr.Zero;
            this.mNumImageHeaders            = 0;
            this.mInjectedFrameIdx           = 0;
            this.mLastProcessedFrameStatePtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.FrameState)));
            VuforiaWrapper.Instance.InitFrameState(this.mLastProcessedFrameStatePtr);
            this.InitializeTrackableContainer(0);
            this.mInitialized = true;
            EyewearDevice eyewearDevice = Device.Instance as EyewearDevice;

            this.mIsSeeThroughDevice = (eyewearDevice != null && eyewearDevice.IsSeeThru());
            return(true);
        }
示例#3
0
        private void UpdateProjection()
        {
            if (!VuforiaRuntimeUtilities.IsVuforiaEnabled())
            {
                return;
            }
            if (VuforiaRuntimeUtilities.IsPlayMode())
            {
                Matrix4x4 projectionGL = VuforiaUnity.GetProjectionGL(this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation);
                this.ApplyMatrix(this.mPrimaryCamera, projectionGL);
                this.ApplyMatrix(this.mSecondaryCamera, projectionGL);
                return;
            }
            Device instance = Device.Instance;

            this.mLastAppliedNearClipPlane = this.mNewNearClipPlane;
            this.mLastAppliedFarClipPlane  = this.mNewFarClipPlane;
            Matrix4x4     projectionMatrix            = instance.GetProjectionMatrix(View.VIEW_LEFTEYE, this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation);
            Matrix4x4     projectionMatrix2           = instance.GetProjectionMatrix(View.VIEW_RIGHTEYE, this.mPrimaryCamera.nearClipPlane, this.mPrimaryCamera.farClipPlane, this.mProjectionOrientation);
            Matrix4x4     eyeDisplayAdjustmentMatrix  = instance.GetEyeDisplayAdjustmentMatrix(View.VIEW_LEFTEYE);
            Matrix4x4     eyeDisplayAdjustmentMatrix2 = instance.GetEyeDisplayAdjustmentMatrix(View.VIEW_RIGHTEYE);
            EyewearDevice eyewearDevice = Device.Instance as EyewearDevice;

            if (eyewearDevice != null && eyewearDevice.IsSeeThru())
            {
                DedicatedEyewearCameraConfiguration.SetProjectionAndOffset(this.mPrimaryCamera, projectionMatrix, eyeDisplayAdjustmentMatrix);
                DedicatedEyewearCameraConfiguration.SetProjectionAndOffset(this.mSecondaryCamera, projectionMatrix2, eyeDisplayAdjustmentMatrix2);
            }
            else
            {
                this.mPrimaryCamera.projectionMatrix          = projectionMatrix;
                this.mSecondaryCamera.projectionMatrix        = projectionMatrix2;
                this.mPrimaryCamera.transform.localPosition   = -eyeDisplayAdjustmentMatrix.GetColumn(3);
                this.mPrimaryCamera.transform.localRotation   = StateManagerImpl.ExtractRotationFromMatrix(eyeDisplayAdjustmentMatrix);
                this.mSecondaryCamera.transform.localPosition = -eyeDisplayAdjustmentMatrix2.GetColumn(3);
                this.mSecondaryCamera.transform.localRotation = StateManagerImpl.ExtractRotationFromMatrix(eyeDisplayAdjustmentMatrix2);
            }
            this.mPrimaryCamera.rect   = instance.GetNormalizedViewport(View.VIEW_LEFTEYE);
            this.mSecondaryCamera.rect = instance.GetNormalizedViewport(View.VIEW_RIGHTEYE);
        }
        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();
                }
            }
        }
示例#5
0
        private void PositionVideoMesh()
        {
            float num = (float)this.mViewWidth / (float)this.mViewHeight;

            if (float.IsNaN(num))
            {
                return;
            }
            ScreenOrientation screenOrientation = VuforiaRuntimeUtilities.ScreenOrientation;

            base.gameObject.transform.localRotation = BackgroundPlaneAbstractBehaviour.DefaultRotationTowardsCamera;
            if (this.mVuforiaBehaviour != null)
            {
                if (screenOrientation == ScreenOrientation.LandscapeLeft)
                {
                    Transform expr_4E = base.gameObject.transform;
                    expr_4E.localRotation = expr_4E.localRotation * Quaternion.identity;
                }
                else if (screenOrientation == ScreenOrientation.Portrait)
                {
                    Transform expr_77 = base.gameObject.transform;
                    expr_77.localRotation = expr_77.localRotation * Quaternion.AngleAxis(90f, Vector3.up);
                }
                else if (screenOrientation == ScreenOrientation.LandscapeRight)
                {
                    Transform expr_A7 = base.gameObject.transform;
                    expr_A7.localRotation = expr_A7.localRotation * Quaternion.AngleAxis(180f, Vector3.up);
                }
                else if (screenOrientation == ScreenOrientation.PortraitUpsideDown)
                {
                    Transform expr_D7 = base.gameObject.transform;
                    expr_D7.localRotation = expr_D7.localRotation * Quaternion.AngleAxis(270f, Vector3.up);
                }
                if (CameraDevice.Instance.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_FRONT && (screenOrientation == ScreenOrientation.Portrait || screenOrientation == ScreenOrientation.PortraitUpsideDown))
                {
                    Transform expr_116 = base.gameObject.transform;
                    expr_116.localRotation = expr_116.localRotation * Quaternion.AngleAxis(180f, Vector3.up);
                }
                EyewearDevice eyewearDevice = Device.Instance as EyewearDevice;
                if (eyewearDevice != null && eyewearDevice.IsSeeThru())
                {
                    base.gameObject.transform.localPosition = new Vector3(0f, 0f, this.mStereoDepth);
                    base.gameObject.transform.localScale    = Vector3.zero;
                }
                else
                {
                    Plane plane = new Plane(this.mCamera.transform.forward, this.mCamera.transform.position + this.mCamera.transform.forward * this.mStereoDepth);
                    Ray   ray   = this.mCamera.ScreenPointToRay(new Vector3(this.mCamera.pixelRect.xMin + (this.mCamera.pixelRect.xMax - this.mCamera.pixelRect.xMin) / 2f, this.mCamera.pixelRect.yMin + (this.mCamera.pixelRect.yMax - this.mCamera.pixelRect.yMin) / 2f, 0f));
                    float num2  = 0f;
                    plane.Raycast(ray, out num2);
                    Vector3 localPosition = this.mCamera.transform.InverseTransformPoint(ray.GetPoint(num2));
                    base.gameObject.transform.localPosition = localPosition;
                    Transform expr_2BB = base.gameObject.transform;
                    expr_2BB.position = expr_2BB.position + this.mBackgroundOffset;
                    float num3 = 1f / this.mCamera.projectionMatrix[5];
                    float num4 = this.mStereoDepth * num3;
                    float num5 = num4 * num;
                    Rect  videoBackgroundRectInViewPort = this.mVuforiaBehaviour.GetVideoBackgroundRectInViewPort();
                    if ((int)videoBackgroundRectInViewPort.height != this.mViewHeight)
                    {
                        num4 *= videoBackgroundRectInViewPort.height / (float)this.mViewHeight;
                    }
                    if ((int)videoBackgroundRectInViewPort.width != this.mViewWidth)
                    {
                        num5 *= videoBackgroundRectInViewPort.width / (float)this.mViewWidth;
                    }
                    float num6;
                    if (VuforiaRuntimeUtilities.IsPortraitOrientation)
                    {
                        num6 = (float)this.mTextureInfo.imageSize.y / (float)this.mTextureInfo.imageSize.x;
                    }
                    else
                    {
                        num6 = (float)this.mTextureInfo.imageSize.x / (float)this.mTextureInfo.imageSize.y;
                    }
                    if (!float.IsNaN(num6))
                    {
                        if (this.ShouldFitWidth())
                        {
                            if (num6 > 1f)
                            {
                                base.gameObject.transform.localScale = new Vector3(num5, 1f, num5 / num6);
                            }
                            else
                            {
                                base.gameObject.transform.localScale = new Vector3(num5 / num6, 1f, num5);
                            }
                        }
                        else if (num6 > 1f)
                        {
                            base.gameObject.transform.localScale = new Vector3(num4 * num6, 1f, num4);
                        }
                        else
                        {
                            base.gameObject.transform.localScale = new Vector3(num4, 1f, num4 * num6);
                        }
                    }
                }
            }
            if (this.mBackgroundPlacedCallback != null)
            {
                this.mBackgroundPlacedCallback();
            }
        }