Class CoordAreaView

java.lang.Object
org.rspeer.game.coord.shape.CoordAreaView

public class CoordAreaView extends Object
  • Method Details

    • getTilePolygons

      public List<Polygon> getTilePolygons(int granularity)
      Computes screen-space polygons for every tile contained within this CoordArea.

      This method iterates through all world-tile coordinates returned by CoordArea.getCoords(), converts each tile to a CoordFine, and then uses CoordView.getPolygon(int) to project that tile (or sub-tile) into screen space.

      Granularity

      The granularity parameter is passed directly to CoordView.getPolygon(int), which controls how each tile is subdivided:
      • granularity = 1 → full tile polygon
      • granularity = 2 → 2x2
      • granularity = 4 → 4x4
      • granularity = 8 … etc.
      A higher granularity produces smaller, more precise screen-space quads inside each tile.

      Visibility

      If a tile cannot be projected to screen (e.g., off-viewport or behind camera), its polygon will have npoints == 0 and will be excluded from the result.
      Parameters:
      granularity - the subdivision factor applied to each tile when projected to screen; 1 = full tile, higher values subdivide tiles into smaller visual regions
      Returns:
      a list of non-empty Polygon instances, one for each visible tile within the area; tiles that cannot be projected are omitted
    • getOutlinePolygon

      public Polygon getOutlinePolygon()
      Computes a single screen-space polygon outlining the entire area.

      This works by:

      1. Taking the four world corners of the CoordArea
      2. For each, building a CoordFine (typically tile center)
      3. Using CoordView.getPolygon(int) for that corner tile to get its four screen-space corner points
      4. Selecting the correct vertex from each tile polygon:
        • bottom-left tile → bottom-left vertex
        • top-left tile → top-left vertex
        • top-right tile → top-right vertex
        • bottom-right tile → bottom-right vertex
      5. Connecting these four screen points into a single Polygon
      Returns:
      a polygon outlining the entire area, or an empty polygon if any of the corner polygons are off-screen / invalid