コード例 #1
0
ファイル: WorldRenderer.java プロジェクト: TOGoS/Chunky
  /**
   * Render overlay icons
   *
   * @param world
   * @param chunky
   * @param g
   * @param renderBuffer
   */
  public void renderHUD(World world, Chunky chunky, Graphics g, RenderBuffer renderBuffer) {

    boolean loadIndicator = chunky.isLoading();
    Chunk.Renderer renderer = chunky.getChunkRenderer();

    ChunkView view = renderBuffer.getView();

    if (loadIndicator) {
      g.drawImage(MiscImages.clock, view.width - 32, 0, 32, 32, null);
    }

    if (world.havePlayerPos()) {
      renderPlayer(
          world,
          g,
          view,
          renderer == Chunk.surfaceRenderer || world.playerLocY() == world.currentLayer());
    }

    if (world.haveSpawnPos()) {
      renderSpawn(
          world,
          g,
          view,
          renderer == Chunk.surfaceRenderer || world.spawnPosY() == world.currentLayer());
    }

    Chunk hoveredChunk = chunky.getHoveredChunk();
    if (!hoveredChunk.isEmpty()) {

      g.setFont(font);
      g.setColor(Color.white);
      g.drawString("Chunk: " + hoveredChunk.getPosition(), 5, view.height - 5);
    }
  }
コード例 #2
0
ファイル: WorldRenderer.java プロジェクト: TOGoS/Chunky
  /**
   * Render the minimap
   *
   * @param world
   * @param renderBuffer
   * @param selection
   */
  public void renderMinimap(
      World world, RenderBuffer renderBuffer, ChunkSelectionTracker selection) {

    ChunkView view = renderBuffer.getView();
    int width = view.width;
    int height = view.height;
    Graphics g = renderBuffer.getGraphics();

    if (world.isEmptyWorld()) {
      renderEmpty(g, width, height);
      return;
    }

    g.setColor(Color.white);
    g.fillRect(0, 0, width, height);

    float[] selectionColor = new float[4];
    float[] color = new float[4];
    se.llbit.math.Color.getRGBAComponents(Layer.selectionColor, selectionColor);
    for (int y = 0; y < height; y++) {
      int cz = y + view.iz0;
      for (int x = 0; x < width; x++) {
        int cx = x + view.ix0;
        ChunkPosition pos = ChunkPosition.get(cx, cz);
        Chunk chunk = world.getChunk(pos);
        if (!chunk.isEmpty()) {
          if (selection.isSelected(pos)) {
            se.llbit.math.Color.getRGBComponents(chunk.avgColor(), color);
            color[0] = color[0] * (1 - selectionColor[3]) + selectionColor[0] * selectionColor[3];
            color[1] = color[1] * (1 - selectionColor[3]) + selectionColor[1] * selectionColor[3];
            color[2] = color[2] * (1 - selectionColor[3]) + selectionColor[2] * selectionColor[3];
            color[3] = 1;
            renderBuffer.setRGB(x, y, se.llbit.math.Color.getRGB(color));
          } else {
            renderBuffer.setRGB(x, y, chunk.avgColor());
          }
        }
      }
    }

    if (world.havePlayerPos()) renderPlayer(world, g, view, true);

    if (world.haveSpawnPos()) renderSpawn(world, g, view, true);
  }
コード例 #3
0
ファイル: WorldRenderer.java プロジェクト: TOGoS/Chunky
  /**
   * Render the map
   *
   * @param world
   * @param renderBuffer
   * @param renderer
   * @param selection
   */
  public void render(
      World world,
      RenderBuffer renderBuffer,
      Chunk.Renderer renderer,
      ChunkSelectionTracker selection) {

    int width = renderBuffer.getWidth();
    int height = renderBuffer.getHeight();

    Graphics g = renderBuffer.getGraphics();
    if (world.isEmptyWorld()) {
      renderEmpty(g, width, height);
      return;
    }

    ChunkView view = renderBuffer.getView();

    ChunkIterator iter = renderBuffer.getChunkIterator();
    while (iter.hasNext()) {
      ChunkPosition pos = iter.next();
      int x = pos.x;
      int z = pos.z;
      if (!view.isChunkVisible(x, z)) continue;

      Chunk chunk = world.getChunk(pos);

      renderer.render(chunk, renderBuffer, x, z);
      if (highlightEnabled) chunk.renderHighlight(renderBuffer, x, z, hlBlock, hlColor);
      if (selection.isSelected(pos)) {
        renderBuffer.fillRectAlpha(
            view.chunkScale * (x - view.ix0),
            view.chunkScale * (z - view.iz0),
            view.chunkScale,
            view.chunkScale,
            Layer.selectionColor);
      }
    }
  }