Package org.rspeer.game.coord.shape
Class CoordAreaView
- java.lang.Object
-
- org.rspeer.game.coord.shape.CoordAreaView
-
public class CoordAreaView extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PolygongetOutlinePolygon()Computes a single screen-space polygon outlining the entire area.List<Polygon>getTilePolygons(int granularity)Computes screen-space polygons for every tile contained within thisCoordArea.
-
-
-
Method Detail
-
getTilePolygons
public List<Polygon> getTilePolygons(int granularity)
Computes screen-space polygons for every tile contained within thisCoordArea.This method iterates through all world-tile coordinates returned by
CoordArea.getCoords(), converts each tile to aCoordFine, and then usesCoordView.getPolygon(int)to project that tile (or sub-tile) into screen space.Granularity
Thegranularityparameter is passed directly toCoordView.getPolygon(int), which controls how each tile is subdivided:granularity = 1→ full tile polygongranularity = 2→ 2x2granularity = 4→ 4x4granularity = 8… etc.
Visibility
If a tile cannot be projected to screen (e.g., off-viewport or behind camera), its polygon will havenpoints == 0and 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
Polygoninstances, 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:
- Taking the four world corners of the
CoordArea - For each, building a
CoordFine(typically tile center) - Using
CoordView.getPolygon(int)for that corner tile to get its four screen-space corner points - 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
- 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
- Taking the four world corners of the
-
-