Exemplo n.º 1
0
void Scene::render() {
	camera->setup();

	Shader::setMatrixViewProj(Render::params.mViewProj);
	Shader::setViewPos(Render::params.camera.pos);

	checkVisible();

	Render::resetStates();

	// list = collect(RENDER_OPAQUE)
	// list->render()

	// list = collect(RENDER_OPACITY)
	// list->sort(camera->pos)
	// list->render()


//	Render::mode = RENDER_OPAQUE;
	Render::statSetTex = 0;
	Render::statTriCount = 0;
    SceneNode::render();
//	LOG("%d\n", Render::statSetTex);
//	LOG("%d\n", Render::statTriCount);

//	Render::mode = RENDER_OPACITY;
//    SceneNode::render();
//	Render::mode = RENDER_OPAQUE;

//    Mesh::sortRender();
}
Exemplo n.º 2
0
void RenderTerrainNode::walkQuadTree( RenderCamera* camera, Array<RenderElement*>& visible )
{
	bool vis = checkVisible(camera);

	if (vis)
	{
		if (!isLeaf())
		{
			for (int i = 0; i < 4; ++i)
			{
				m_children[i]->walkQuadTree(camera,visible);
			}
		}
		else
		{
			visible.Append(this);
		}
	}
}
Exemplo n.º 3
0
void TextBox::OnMouseDown(Uint16 x, Uint16 y, Uint8 button) {
  if (!handler.ExecOnMouseRange(x, y, "query"))
    return;

  if (button == SDL_BUTTON_LEFT && checkVisible()) {
    switch (performState) {
    case suspend:
      Clear();
      GameSystem::resetTimer(0, SCRIPT_EVENT);
      break;
    case running: 
      while (performState == running) DrawText();
      break;
    case waiting:
      performState = running;
      break;
    }
  }

  if (button == SDL_BUTTON_RIGHT) 
    setVisible(GameObject::FLIP, 1);
}
Exemplo n.º 4
0
void TextBox::DrawText()
{
  if (performState == suspend) return;
 
  if (performState == running && checkVisible()) {
    if (--draw_current <= 0) {
      if (wordsToRender[0] == '/') { //部分文字输出结束,等待用户继续,'/p'为不换行,'/n'为换行
	wordsToRender.erase(0, 1);
	if (wordsToRender[0] == 'n') {
	  NewLine();
	}
	wordsToRender.erase(0, 1);
	performState = waiting;
      } else {
	ProcessWord(wordsToRender[0]);
	wordsToRender.erase(0, 1);
	if (wordsToRender.empty()) 
	  performState = suspend;
      }
      draw_current = draw_interval;
    }
  }
}
Exemplo n.º 5
0
void Topology::Paint(HDC hdc, RECT rc) {

  if (!shapefileopen) return;

  bool nolabels=false;
  if (scaleCategory==10) {
	// for water areas, use scaleDefault
	if ( MapWindow::zoom.RealScale()>scaleDefaultThreshold) {
		return;
	}
	// since we just checked category 10, if we are over scale we set nolabels
	if ( MapWindow::zoom.RealScale()>scaleThreshold) nolabels=true;
  } else 
  if (MapWindow::zoom.RealScale() > scaleThreshold) return;

  // TODO code: only draw inside screen!
  // this will save time with rendering pixmaps especially
  // checkVisible does only check lat lon , not screen pixels..
  // We need to check also screen.

  HPEN  hpOld;
  HBRUSH hbOld;
  HFONT hfOld;

  if (hPen) {
    hpOld = (HPEN)SelectObject(hdc,  hPen);
    hbOld = (HBRUSH)SelectObject(hdc, hbBrush);
  } else {
    hpOld = NULL;
    hbOld = NULL;
  }
  hfOld = (HFONT)SelectObject(hdc, MapLabelFont);

  // get drawing info
    
  int iskip = 1;
  
  // attempt to bugfix 100615 polyline glitch with zoom over 33Km
  // do not skip points, if drawing coast lines which have a scaleThreshold of 100km!
  // != 5 and != 10
  if (scaleCategory>10) { 
  if (MapWindow::zoom.RealScale()>0.25*scaleThreshold) {
    iskip = 2;
  } 
  if (MapWindow::zoom.RealScale()>0.5*scaleThreshold) {
    iskip = 3;
  }
  if (MapWindow::zoom.RealScale()>0.75*scaleThreshold) {
    iskip = 4;
  }
  }

  // use the already existing screenbounds_latlon, calculated by CalculateScreenPositions in MapWindow2
  rectObj screenRect = MapWindow::screenbounds_latlon;

  static POINT pt[MAXCLIPPOLYGON];
  bool labelprinted=false;

  for (int ixshp = 0; ixshp < shpfile.numshapes; ixshp++) {
    
    XShape *cshape = shpCache[ixshp];

    if (!cshape || cshape->hide) continue;    

    shapeObj *shape = &(cshape->shape);

    switch(shape->type) {


      case(MS_SHAPE_POINT):{

	#if 101016
	// -------------------------- NOT PRINTING ICONS ---------------------------------------------
	bool dobitmap=false;
	if (scaleCategory<90 || (MapWindow::zoom.RealScale()<2)) dobitmap=true;
	// first a latlon overlap check, only approximated because of fastcosine in latlon2screen
	if (checkVisible(*shape, screenRect))
		for (int tt = 0; tt < shape->numlines; tt++) {
			for (int jj=0; jj< shape->line[tt].numpoints; jj++) {
				POINT sc;
				MapWindow::LatLon2Screen(shape->line[tt].point[jj].x, shape->line[tt].point[jj].y, sc);
				if (dobitmap) {
					// bugfix 101212 missing case for scaleCategory 0 (markers)
					if (scaleCategory==0||cshape->renderSpecial(hdc, sc.x, sc.y,labelprinted)) 
						MapWindow::DrawBitmapIn(hdc, sc, hBitmap,true);
				} else {
					cshape->renderSpecial(hdc, sc.x, sc.y,labelprinted);
				}
			}
		}
	}

	#else
	// -------------------------- PRINTING ICONS ---------------------------------------------
	#if (TOPOFAST)
	// no bitmaps for small town over a certain zoom level and no bitmap if no label at all levels
	bool nobitmap=false, noiconwithnolabel=false;
	if (scaleCategory==90 || scaleCategory==100) {
		noiconwithnolabel=true;
		if (MapWindow::MapScale>4) nobitmap=true;
	}
	#endif

	if (checkVisible(*shape, screenRect))
		for (int tt = 0; tt < shape->numlines; tt++) {
			for (int jj=0; jj< shape->line[tt].numpoints; jj++) {
				POINT sc;
				MapWindow::LatLon2Screen(shape->line[tt].point[jj].x, shape->line[tt].point[jj].y, sc);
	
				#if (TOPOFAST)
				if (!nobitmap)
				#endif
				#if 101016
				// only paint icon if label is printed too
				if (noiconwithnolabel) {
					if (cshape->renderSpecial(hdc, sc.x, sc.y,labelprinted))
						MapWindow::DrawBitmapIn(hdc, sc, hBitmap,true);
				} else {
					MapWindow::DrawBitmapIn(hdc, sc, hBitmap,true);
					cshape->renderSpecial(hdc, sc.x, sc.y,labelprinted);
				}
				#else
				MapWindow::DrawBitmapIn(hdc, sc, hBitmap,true);
				cshape->renderSpecial(hdc, sc.x, sc.y);
				#endif
			}
		}

	}
	#endif // Use optimized point icons 1.23e
	break;

    case(MS_SHAPE_LINE):

      if (checkVisible(*shape, screenRect))
        for (int tt = 0; tt < shape->numlines; tt ++) {
          
          int minx = rc.right;
          int miny = rc.bottom;
          int msize = min(shape->line[tt].numpoints, MAXCLIPPOLYGON);

	  MapWindow::LatLon2Screen(shape->line[tt].point,
				   pt, msize, 1);
          for (int jj=0; jj< msize; jj++) {
            if (pt[jj].x<=minx) {
              minx = pt[jj].x;
              miny = pt[jj].y;
            }
	  }

          ClipPolygon(hdc, pt, msize, rc, false);
          cshape->renderSpecial(hdc,minx,miny,labelprinted);
        }
      break;
      
    case(MS_SHAPE_POLYGON):

	// if it's a water area (nolabels), print shape up to defaultShape, but print
	// labels only up to custom label levels
	if ( nolabels ) {
		if (checkVisible(*shape, screenRect)) {
			for (int tt = 0; tt < shape->numlines; tt ++) {
				int minx = rc.right;
				int msize = min(shape->line[tt].numpoints/iskip, MAXCLIPPOLYGON);
				MapWindow::LatLon2Screen(shape->line[tt].point, pt, msize*iskip, iskip);
				for (int jj=0; jj< msize; jj++) {
					if (pt[jj].x<=minx) {
						minx = pt[jj].x;
					}
				}
				ClipPolygon(hdc,pt, msize, rc, true);
			}
		}
	} else 
	if (checkVisible(*shape, screenRect)) {
		for (int tt = 0; tt < shape->numlines; tt ++) {
			int minx = rc.right;
			int miny = rc.bottom;
			int msize = min(shape->line[tt].numpoints/iskip, MAXCLIPPOLYGON);
			MapWindow::LatLon2Screen(shape->line[tt].point, pt, msize*iskip, iskip);
			for (int jj=0; jj< msize; jj++) {
				if (pt[jj].x<=minx) {
					minx = pt[jj].x;
					miny = pt[jj].y;
				}
			}
			ClipPolygon(hdc,pt, msize, rc, true);
			cshape->renderSpecial(hdc,minx,miny,labelprinted);          
		}
	}
	break;
      
    default:
      break;
    }
  }
Exemplo n.º 6
0
void Topology::Paint(Canvas &canvas, MapWindow &m_window, const RECT rc) {

  if (!shapefileopen) return;

  MapWindowProjection &map_projection = m_window;
  LabelBlock *label_block = m_window.getLabelBlock();

  double map_scale = map_projection.GetMapScaleUser();

  if (map_scale > scaleThreshold)
    return;

  // TODO code: only draw inside screen!
  // this will save time with rendering pixmaps especially
  // we already do an outer visibility test, but may need a test
  // in screen coords

  canvas.select(hPen);
  canvas.select(hbBrush);
  canvas.select(MapLabelFont);

  // get drawing info

  int iskip = 1;

  if (map_scale>0.25*scaleThreshold) {
    iskip = 2;
  }
  if (map_scale>0.5*scaleThreshold) {
    iskip = 3;
  }
  if (map_scale>0.75*scaleThreshold) {
    iskip = 4;
  }

  rectObj screenRect = map_projection.CalculateScreenBounds(0.0);

  static POINT pt[MAXCLIPPOLYGON];
  const bool render_labels = (m_window.SettingsMap().DeclutterLabels<2);

  for (int ixshp = 0; ixshp < shpfile.numshapes; ixshp++) {

    XShape *cshape = shpCache[ixshp];

    if (!cshape || cshape->hide) continue;

    shapeObj *shape = &(cshape->shape);

    switch(shape->type) {
      case(MS_SHAPE_POINT):{

        if (checkVisible(*shape, screenRect)) {
          for (int tt = 0; tt < shape->numlines; tt++) {

            for (int jj=0; jj< shape->line[tt].numpoints; jj++) {

              POINT sc;
              GEOPOINT l;
              l.Longitude = shape->line[tt].point[jj].x;
              l.Latitude = shape->line[tt].point[jj].y;
              if (m_window.draw_masked_bitmap_if_visible(canvas, hBitmap, l,
                  10, 10, &sc)) {
                if (render_labels)
                  cshape->renderSpecial(canvas, *label_block, sc.x, sc.y);
              }
            }
          }
        }

      }; break;

    case(MS_SHAPE_LINE):

      if (checkVisible(*shape, screenRect))
        for (int tt = 0; tt < shape->numlines; tt ++) {

          int minx = rc.right;
          int miny = rc.bottom;
          int msize = min(shape->line[tt].numpoints, MAXCLIPPOLYGON);

          map_projection.LonLat2Screen(shape->line[tt].point,
              pt, msize, 1);

          for (int jj=0; jj< msize; jj++) {
            if (pt[jj].x<=minx) {
              minx = pt[jj].x;
              miny = pt[jj].y;
            }
          }

          canvas.polyline(pt, msize);
          if (render_labels)
            cshape->renderSpecial(canvas, *label_block, minx, miny);
        }
      break;

    case(MS_SHAPE_POLYGON):

      if (checkVisible(*shape, screenRect))
        for (int tt = 0; tt < shape->numlines; tt ++) {

          int minx = rc.right;
          int miny = rc.bottom;
          int msize = min(shape->line[tt].numpoints/iskip, MAXCLIPPOLYGON);

          map_projection.LonLat2Screen(shape->line[tt].point,
              pt, msize*iskip, iskip);

          for (int jj=0; jj< msize; jj++) {
            if (pt[jj].x<=minx) {
              minx = pt[jj].x;
              miny = pt[jj].y;
            }
          }
          canvas.polygon(pt, msize);
          if (render_labels)
            cshape->renderSpecial(canvas, *label_block, minx, miny);
        }
      break;

    default:
      break;
    }
  }
}