Logo Search packages:      
Sourcecode: gaia version File versions  Download package

void FlatEarthView::Render (  )  [virtual]

Render one frame.

Implements EarthView.

Definition at line 29 of file FlatEarthView.cc.

References AspectCorrection(), EarthView::m_Eye, EarthView::m_MasterLayer, EarthView::m_ViewportHeight, EarthView::m_ViewportWidth, Region::p, MasterLayer::RenderRegion(), Region::v, Region::w, Vector2< T >::x, Vector3< T >::x, Eye::x, Eye::xspan(), Vector2< T >::y, Vector3< T >::y, Eye::y, and Eye::yspan().

                           {
      /* x and y span of viewable size in global coords */
      double yspan = m_Eye.yspan((double)m_ViewportWidth/(double)m_ViewportHeight);
      double xspan = m_Eye.xspan((double)m_ViewportWidth/(double)m_ViewportHeight);

      xspan *= AspectCorrection();

      /* setup projection */
      glMatrixMode(GL_PROJECTION);
      double m[16] = {
            2.0/m_ViewportWidth,    0,                0,    0,
            0,                2.0/m_ViewportHeight,   0,    0,
            0,                0,                1.0,  0,
            -1.0,             -1.0,             0,    1.0,
      };
      glLoadMatrixd(m);

      /* calculate virtual coordinates for sides of world rectangle */
      double world_left_virtual = ((-0.5 - m_Eye.x) * (double)m_ViewportWidth/xspan) + double(m_ViewportWidth)/2.0;
      double world_right_virtual = ((0.5 - m_Eye.x) * (double)m_ViewportWidth/xspan) + double(m_ViewportWidth)/2.0;
      double world_top_virtual = ((0.25 - m_Eye.y) * (double)m_ViewportHeight/yspan) + double(m_ViewportHeight)/2.0;
      double world_bottom_virtual = ((-0.25 - m_Eye.y) * (double)m_ViewportHeight/yspan) + double(m_ViewportHeight)/2.0;

      Region rgn(Vector3d(0, 0, 0),
            Vector3d((double)m_ViewportWidth, 0, 0),
            Vector3d((double)m_ViewportWidth, (double)m_ViewportHeight, 0),
            Vector3d(0, (double)m_ViewportHeight, 0),

            Vector2d(m_Eye.x - xspan/2.0, m_Eye.y - yspan/2.0),
            Vector2d(m_Eye.x + xspan/2.0, m_Eye.y + yspan/2.0),

            Vector3d(0, 0, 0),
            Vector3d((double)m_ViewportWidth, 0, 0),
            Vector3d((double)m_ViewportWidth, (double)m_ViewportHeight, 0),
            Vector3d(0, (double)m_ViewportHeight, 0));

      /* tune coords for the cases where earth bounds appear on screen */
      if (world_left_virtual > 0.0) {
            rgn.v[0].x = rgn.v[3].x = world_left_virtual;
            rgn.p[0].x = rgn.p[3].x = world_left_virtual;
            rgn.w[0].x = -0.5;
      }

      if (world_right_virtual < (double)m_ViewportWidth) {
            rgn.v[1].x = rgn.v[2].x = world_right_virtual;
            rgn.p[1].x = rgn.p[2].x = world_right_virtual;
            rgn.w[1].x = 0.5;
      }

      if (world_bottom_virtual > 0.0) {
            rgn.v[0].y = rgn.v[1].y = world_bottom_virtual;
            rgn.p[0].y = rgn.p[1].y = world_bottom_virtual;
            rgn.w[0].y = -0.25;
      }

      if (world_top_virtual < (double)m_ViewportHeight) {
            rgn.v[2].y = rgn.v[3].y = world_top_virtual;
            rgn.p[2].y = rgn.p[3].y = world_top_virtual;
            rgn.w[1].y = 0.25;
      }

      /* call master layer */
      m_MasterLayer->RenderRegion(&rgn);
}


Generated by  Doxygen 1.6.0   Back to index