public Matrix CalculateBaseProjectionMatrix()
 {
     if (!base.Eye.HasValue)
     {
         float num  = 90f;
         float num2 = 1f;
         if (SettingsManager.ViewAngleMode == ViewAngleMode.Narrow)
         {
             num2 = 0.8f;
         }
         else if (SettingsManager.ViewAngleMode == ViewAngleMode.Normal)
         {
             num2 = 0.9f;
         }
         ViewWidget viewWidget = base.GameWidget.ViewWidget;
         float      num3       = viewWidget.ActualSize.X / viewWidget.ActualSize.Y;
         float      num4       = MathUtils.Min(num * num3, num);
         float      num5       = num4 * num3;
         if (num5 < 90f)
         {
             num4 *= 90f / num5;
         }
         else if (num5 > 175f)
         {
             num4 *= 175f / num5;
         }
         return(Matrix.CreatePerspectiveFieldOfView(MathUtils.DegToRad(num4 * num2), num3, 0.1f, 2048f));
     }
     return(VrManager.GetProjectionMatrix(base.Eye.Value, 0.1f, 2048f));
 }
Example #2
0
 public static void Draw()
 {
     if (VrManager.IsVrStarted)
     {
         Point2 point = new Point2(Display.Viewport.Width, Display.Viewport.Height);
         if (MathUtils.Max(point.X, point.Y) == 0)
         {
             point = new Point2(1500, 1000);
         }
         while (MathUtils.Max(point.X, point.Y) < 1024)
         {
             point *= 2;
         }
         if (m_uiRenderTarget == null || m_uiRenderTarget.Width != point.X || m_uiRenderTarget.Height != point.Y)
         {
             Utilities.Dispose(ref m_uiRenderTarget);
             m_uiRenderTarget = new RenderTarget2D(point.X, point.Y, 1, ColorFormat.Rgba8888, DepthFormat.Depth24Stencil8);
         }
         RenderTarget2D renderTarget = Display.RenderTarget;
         try
         {
             Display.RenderTarget = m_uiRenderTarget;
             LayoutAndDrawWidgets();
             Display.RenderTarget = VrManager.VrRenderTarget;
             for (VrEye vrEye = VrEye.Left; vrEye <= VrEye.Right; vrEye++)
             {
                 Display.Clear(Color.Black, 1f, 0);
                 DrawVrBackground();
                 DrawVrQuad();
                 Matrix hmdMatrix        = VrManager.HmdMatrix;
                 Matrix m                = Matrix.Invert(VrManager.GetEyeToHeadTransform(vrEye));
                 Matrix m2               = Matrix.Invert(hmdMatrix);
                 Matrix projectionMatrix = VrManager.GetProjectionMatrix(vrEye, 0.1f, 1024f);
                 m_pr3.Flush(m2 * m * projectionMatrix);
                 VrManager.SubmitEyeTexture(vrEye, VrManager.VrRenderTarget);
             }
         }
         finally
         {
             Display.RenderTarget = renderTarget;
         }
         m_pr2.TexturedBatch(m_uiRenderTarget, useAlphaTest: false, 0, DepthStencilState.None, RasterizerState.CullNoneScissor, BlendState.Opaque, SamplerState.PointClamp).QueueQuad(new Vector2(0f, 0f), new Vector2(m_uiRenderTarget.Width, m_uiRenderTarget.Height), 0f, new Vector2(0f, 0f), new Vector2(1f, 1f), Color.White);
         m_pr2.Flush();
     }
     else
     {
         Utilities.Dispose(ref m_uiRenderTarget);
         LayoutAndDrawWidgets();
     }
 }