Class CoordView
CoordFine, such as converting
a world-space fine coordinate into screen-space or minimap-space positions.
Internally, this uses the client's camera position, pitch, yaw, and viewport settings to perform the same kind of 3D → 2D projections as the game engine.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]batchPolygons(CoordFine[] fines, int granularity) static intbatchPolygons(CoordFine[] fines, int granularity, CoordView.BatchProjectionBuffers buffers) static long[]batchToScreen(CoordFine[] fines) static intbatchToScreen(CoordFine[] fines, CoordView.BatchProjectionBuffers buffers) Computes a screen-space polygon representing the tile (or sub-tile) occupied by this coordinate, using a default granularity of1.getPolygon(int granularity) Computes a screen-space polygon representing the area around thisCoordFine, optionally at sub-tile granularity.getSubPolygons(int granularity) projectTextOnViewport(Graphics g, String text) Computes a screen-space render point for drawing text at this coordinate with no vertical Z-offset.projectTextOnViewport(Graphics g, String text, int zOffset) Computes a screen-space render point for drawing text at this coordinate, applying an explicit Z-offset.projectTextOnViewport(Graphics g, String text, Entity<?> entity) Computes a screen-space render point for drawing text above a given entity.Projects this coordinate into minimap space.toScreen()Projects this coordinate into the main 3D game viewport (screen space).toScreen(int zOffset) Projects this coordinate into the main 3D game viewport (screen space), applying a custom vertical Z-offset.static PolygonunpackPolygon(int[] points, int index) static PointunpackScreenPoint(long packed)
-
Field Details
-
SINE
public static final int[] SINEPrecomputed sine table for 2048 discrete angles (0–2047) in the client angle space. Values are scaled by 65536 (1 << 16) for fixed-point math. -
COSINE
public static final int[] COSINEPrecomputed cosine table for 2048 discrete angles (0–2047) in the client angle space. Values are scaled by 65536 (1 << 16) for fixed-point math.
-
-
Method Details
-
batchToScreen
-
batchPolygons
-
batchToScreen
-
batchPolygons
public static int batchPolygons(CoordFine[] fines, int granularity, CoordView.BatchProjectionBuffers buffers) -
unpackScreenPoint
-
unpackPolygon
-
getPolygon
Computes a screen-space polygon representing the tile (or sub-tile) occupied by this coordinate, using a default granularity of1.A granularity of
1corresponds to the full tile. SeegetPolygon(int)for details.- Returns:
- a
Polygondescribing the screen-space quad covering this tile; an empty polygon if the tile is not visible on the screen
-
getPolygon
Computes a screen-space polygon representing the area around thisCoordFine, optionally at sub-tile granularity.How granularity works:
Granularity divides a tile into smaller logical segments based on an internal step granularity ofg * 2when callingCoordFine.translate(int, int, int):granularity = 1→ full tilegranularity = 2→ 2x2granularity = 4→ 4x4granularity = 8→ 8x8
stepGranularity = granularity * 2, so each steptranslate(dx, dy, stepGranularity)moves the coordinate by128 / (granularity * 2)fine units, and the full polygon width becomes128 / granularityfine units.- Parameters:
granularity- the subdivision factor- Returns:
- a
Polygonrepresenting the on-screen quad around this coordinate at the given granularity; or an empty polygon if off-screen
-
getSubPolygons
-
toScreen
Projects this coordinate into the main 3D game viewport (screen space).This uses the client's camera position, pitch, yaw and viewport scale to perform a fixed-point 3D → 2D projection.
- Returns:
- a
Pointin screen coordinates, or(-1, -1)if the coordinate is not in a loaded scene region or outside the viewport, ornullif camera pitch/yaw are invalid
-
toScreen
Projects this coordinate into the main 3D game viewport (screen space), applying a custom vertical Z-offset.This method performs a full fixed-point 3D → 2D projection using:
- the client's camera position (X/Y/Z)
- current camera pitch and yaw
- the scene's floor height at this coordinate
- the viewport size and scale
- Parameters:
zOffset- the vertical offset (in world units) applied before projection; positive values lower the projected point, negative values raise it- Returns:
- a
Pointin screen coordinates,(-1, -1)if the coordinate is not visible or outside the viewport, ornullif the camera's pitch or yaw values are invalid
-
projectTextOnViewport
Computes a screen-space render point for drawing text above a given entity.This projects the entity's world coordinate into screen space and adjusts the horizontal position so that the provided text is centered horizontally.
- Parameters:
g- the graphics context used to measure string boundstext- the text to be renderedentity- the target entity whose height is used as the Z-offset- Returns:
- the top-left
Pointat which the text should be rendered, ornullif the text is empty or invalid, or(-1, -1)if the coordinate cannot be projected onto the screen
-
projectTextOnViewport
Computes a screen-space render point for drawing text at this coordinate with no vertical Z-offset.This projects the coordinate into screen space and horizontally centers the provided text around that point.
- Parameters:
g- the graphics context used to measure string boundstext- the text to be rendered- Returns:
- the top-left
Pointat which the text should be drawn, ornullif the text is empty or invalid, or(-1, -1)if the coordinate cannot be projected onto the screen
-
projectTextOnViewport
Computes a screen-space render point for drawing text at this coordinate, applying an explicit Z-offset.This method:
- Projects the world coordinate to screen space using
toScreen(int) - Centers the provided text horizontally using the given
Graphics
- Parameters:
g- the graphics context used to measure string boundstext- the text to be renderedzOffset- the vertical offset (in world units) applied before projection- Returns:
- the top-left
Pointat which the text should be rendered,nullif the text is empty, or(-1, -1)if projection fails
- Projects the world coordinate to screen space using
-
toMinimap
Projects this coordinate into minimap space.The returned point is the location of this world coordinate on the minimap widget, taking into account the player's position, minimap rotation, and the active interface layout (fixed, resized-line, resized-stone).
When the player is on special transport (e.g., boats), the minimap's center shifts to the associated
RSWorldEntity.- Returns:
- a
Pointin minimap pixel coordinates, or(-1, -1)if the point lies outside the minimap bounds, the minimap component is hidden/unavailable, or the distance exceeds the minimap radius
-