Class CoordPolygonView

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

public class CoordPolygonView extends Object
Screen-space view utilities for CoordPolygon.

Like CoordAreaView, but backed by a filled CoordPolygon shape.

  • Method Details

    • getTilePolygons

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

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

      Tiles that cannot be projected (off-viewport / behind camera) typically produce polygons with npoints == 0 and are excluded.

      Parameters:
      granularity - subdivision factor passed to CoordView.getPolygon(int)
      Returns:
      list of non-empty tile polygons in screen space
    • getOutlinePolygon

      public Polygon getOutlinePolygon()
      Computes an approximate single screen-space outline polygon of this CoordPolygon.

      Implementation:

      1. Take the polygon's vertex coords (CoordPolygon.getVertices())
      2. Project each vertex tile into screen-space via CoordView.getPolygon()
      3. Pick the screen-space corner of that tile most consistent with the vertex direction: we choose the tile vertex closest to the projected tile center.
      4. Return a screen-space polygon made from those points (in iteration order).

      Note: because CoordPolygon stores vertices in a Set, the vertex order may be undefined. If you need a stable outline, store vertices in order (e.g., List) in the shape and iterate deterministically.

      Returns:
      outline polygon, or empty polygon if any vertex cannot be projected
    • getOutlinePoints

      public List<Point> getOutlinePoints()
      Returns the outline points used by getOutlinePolygon().