Class CoordPolygonView
java.lang.Object
org.rspeer.game.coord.shape.CoordPolygonView
Screen-space view utilities for
CoordPolygon.
Like CoordAreaView, but backed by a filled CoordPolygon shape.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the outline points used bygetOutlinePolygon().Computes an approximate single screen-space outline polygon of thisCoordPolygon.getTilePolygons(int granularity) Computes screen-space polygons for every tile contained within thisCoordPolygon.
-
Method Details
-
getTilePolygons
Computes screen-space polygons for every tile contained within thisCoordPolygon.This method iterates through all world-tile coordinates returned by
CoordPolygon.getCoords(), converts each toCoordFine, and then usesCoordView.getPolygon(int)to project that tile into screen space.Tiles that cannot be projected (off-viewport / behind camera) typically produce polygons with
npoints == 0and are excluded.- Parameters:
granularity- subdivision factor passed toCoordView.getPolygon(int)- Returns:
- list of non-empty tile polygons in screen space
-
getOutlinePolygon
Computes an approximate single screen-space outline polygon of thisCoordPolygon.Implementation:
- Take the polygon's vertex coords (
CoordPolygon.getVertices()) - Project each vertex tile into screen-space via
CoordView.getPolygon() - 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.
- Return a screen-space polygon made from those points (in iteration order).
Note: because
CoordPolygonstores vertices in aSet, 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
- Take the polygon's vertex coords (
-
getOutlinePoints
Returns the outline points used bygetOutlinePolygon().
-