Exemple #1
0
        private void UpdateProfile()
        {
            GetProfile(profileData);
            GvrProfile.Viewer device = new GvrProfile.Viewer();
            GvrProfile.Screen screen = new GvrProfile.Screen();
            device.maxFOV.outer          = profileData[0];
            device.maxFOV.upper          = profileData[1];
            device.maxFOV.inner          = profileData[2];
            device.maxFOV.lower          = profileData[3];
            screen.width                 = profileData[4];
            screen.height                = profileData[5];
            screen.border                = profileData[6];
            device.lenses.separation     = profileData[7];
            device.lenses.offset         = profileData[8];
            device.lenses.screenDistance = profileData[9];
            device.lenses.alignment      = (int)profileData[10];
            device.distortion.Coef       = new [] { profileData[11], profileData[12] };
            Profile.screen               = screen;
            Profile.viewer               = device;

            float[] rect = new float[4];
            Profile.GetLeftEyeNoLensTanAngles(rect);
            float maxRadius = GvrProfile.GetMaxRadius(rect);

            Profile.viewer.inverse = GvrProfile.ApproximateInverse(
                Profile.viewer.distortion, maxRadius);
        }
Exemple #2
0
    public void UpdateStereoValues()
    {
        Matrix4x4 proj = GvrViewer.Instance.Projection(eye);

        realProj = GvrViewer.Instance.Projection(eye, GvrViewer.Distortion.Undistorted);

        CopyCameraAndMakeSideBySide(controller, proj[0, 2], proj[1, 2]);

        // Fix aspect ratio and near/far clipping planes.
        float nearClipPlane = monoCamera.nearClipPlane;
        float farClipPlane  = monoCamera.farClipPlane;

        GvrCameraUtils.FixProjection(cam.rect, nearClipPlane, farClipPlane, ref proj);
        //GvrCameraUtils.FixProjection(new Rect(0,0,0.5f,1), nearClipPlane, farClipPlane, ref proj);
        GvrCameraUtils.FixProjection(cam.rect, nearClipPlane, farClipPlane, ref realProj);
        //GvrCameraUtils.FixProjection(new Rect(0, 0, 0.5f, 01), nearClipPlane, farClipPlane, ref realProj);

        // Zoom the stereo cameras if requested.
        float monoProj11 = monoCamera.projectionMatrix[1, 1];

        GvrCameraUtils.ZoomStereoCameras(controller.matchByZoom, controller.matchMonoFOV,
                                         monoProj11, ref proj);
        // Set the eye camera's projection for rendering.
        cam.projectionMatrix = proj;
        //if (Application.isEditor)
        //{
        // So you can see the approximate frustum in the Scene view when the camera is selected.
        cam.fieldOfView = 2 * Mathf.Atan(1 / proj[1, 1]) * Mathf.Rad2Deg;
        //}

        // Draw to the mono camera's target, or the stereo screen.
        //cam.targetTexture = monoCamera.targetTexture ?? GvrViewer.Instance.StereoScreen.GetRenderTexture(0);
        if (monoCamera.targetTexture == null && GvrViewer.Instance.StereoScreen != null)
        {
            //	  GvrViewer.Instance.StereoScreen.NextRenderTexture ();
            cam.targetTexture = GvrViewer.Instance.StereoScreen.GetRenderTexture(0);
        }
        else
        {
            cam.targetTexture = monoCamera.targetTexture;
        }
        if (cam.targetTexture == null)
        {
            // When drawing straight to screen, account for lens FOV limits.
            // Note: do this after all calls to FixProjection() which needs the unfixed rect.
            Rect viewport   = GvrViewer.Instance.Viewport(eye);
            bool isRightEye = eye == GvrViewer.Eye.Right;
            cam.rect = GvrCameraUtils.FixViewport(cam.rect, viewport, isRightEye);

            // The game window's aspect ratio may not match the device profile parameters.
            if (Application.isEditor)
            {
                GvrProfile.Screen profileScreen = GvrViewer.Instance.Profile.screen;
                float             profileAspect = profileScreen.width / profileScreen.height;
                float             windowAspect  = (float)Screen.width / Screen.height;
                cam.rect = GvrCameraUtils.FixEditorViewport(cam.rect, profileAspect, windowAspect);
            }
        }
    }
Exemple #3
0
    private void UpdateProfile() {
      GetProfile(profileData);
      GvrProfile.Viewer device = new GvrProfile.Viewer();
      GvrProfile.Screen screen = new GvrProfile.Screen();
      device.maxFOV.outer = profileData[0];
      device.maxFOV.upper = profileData[1];
      device.maxFOV.inner = profileData[2];
      device.maxFOV.lower = profileData[3];
      screen.width = profileData[4];
      screen.height = profileData[5];
      screen.border = profileData[6];
      device.lenses.separation = profileData[7];
      device.lenses.offset = profileData[8];
      device.lenses.screenDistance = profileData[9];
      device.lenses.alignment = (int)profileData[10];
      device.distortion.Coef = new [] { profileData[11], profileData[12] };
      Profile.screen = screen;
      Profile.viewer = device;

      float[] rect = new float[4];
      Profile.GetLeftEyeNoLensTanAngles(rect);
      float maxRadius = GvrProfile.GetMaxRadius(rect);
      Profile.viewer.inverse = GvrProfile.ApproximateInverse(
          Profile.viewer.distortion, maxRadius);
    }