Package net.runelite.api
Class Perspective
- java.lang.Object
-
- net.runelite.api.Perspective
-
public class Perspective extends Object
A utility class containing methods to help with conversion between in-game features to canvas areas.
-
-
Field Summary
Fields Modifier and Type Field Description static int[]
COSINE
static int
LOCAL_COORD_BITS
static int
LOCAL_HALF_TILE_SIZE
static int
LOCAL_TILE_SIZE
static int
SCENE_SIZE
static int[]
SINE
static double
UNIT
-
Constructor Summary
Constructors Constructor Description Perspective()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Point
getCanvasImageLocation(Client client, LocalPoint localLocation, BufferedImage image, int zOffset)
Calculates image position and centers depending on image size.static Point
getCanvasSpriteLocation(Client client, LocalPoint localLocation, SpritePixels sprite, int zOffset)
Calculates sprite position and centers depending on sprite size.static Point
getCanvasTextLocation(Client client, Graphics2D graphics, LocalPoint localLocation, String text, int zOffset)
Calculates text position and centers depending on string length.static Point
getCanvasTextMiniMapLocation(Client client, Graphics2D graphics, LocalPoint localLocation, String text)
Calculates text position and centers on minimap depending on string length.static Polygon
getCanvasTileAreaPoly(Client client, LocalPoint localLocation, int size)
Returns a polygon representing an area.static Polygon
getCanvasTileAreaPoly(Client client, LocalPoint localLocation, int sizeX, int sizeY, int plane, int zOffset)
Returns a polygon representing an area.static Polygon
getCanvasTilePoly(Client client, LocalPoint localLocation)
Calculates a tile polygon from offset worldToScreen() points.static Polygon
getCanvasTilePoly(Client client, LocalPoint localLocation, int zOffset)
Calculates a tile polygon from offset worldToScreen() points.static Shape
getClickbox(Client client, Model model, int orientation, int x, int y, int z)
You don't want this.static Point
getMiniMapImageLocation(Client client, LocalPoint localLocation, BufferedImage image)
Calculates image position and centers depending on image size.static int
getTileHeight(Client client, LocalPoint point, int plane)
Calculates the above ground height of a tile point.static Point
localToCanvas(Client client, int x, int y, int z)
Translates three-dimensional local coordinates within the 3D world to their corresponding coordinates on the game screen.static Point
localToCanvas(Client client, LocalPoint point, int plane)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.static Point
localToCanvas(Client client, LocalPoint point, int plane, int zOffset)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.static Point
localToMinimap(Client client, LocalPoint point)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.static Point
localToMinimap(Client client, LocalPoint point, int distance)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.static void
modelToCanvas(Client client, int end, int x3dCenter, int y3dCenter, int z3dCenter, int rotate, float[] x3d, float[] y3d, float[] z3d, int[] x2d, int[] y2d)
Translates a model's vertices into 2d space.
-
-
-
Field Detail
-
UNIT
public static final double UNIT
- See Also:
- Constant Field Values
-
LOCAL_COORD_BITS
public static final int LOCAL_COORD_BITS
- See Also:
- Constant Field Values
-
LOCAL_TILE_SIZE
public static final int LOCAL_TILE_SIZE
- See Also:
- Constant Field Values
-
LOCAL_HALF_TILE_SIZE
public static final int LOCAL_HALF_TILE_SIZE
- See Also:
- Constant Field Values
-
SCENE_SIZE
public static final int SCENE_SIZE
- See Also:
- Constant Field Values
-
SINE
public static final int[] SINE
-
COSINE
public static final int[] COSINE
-
-
Method Detail
-
localToCanvas
@Nullable public static Point localToCanvas(@Nonnull Client client, @Nonnull LocalPoint point, int plane)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.- Parameters:
client
- the game clientpoint
- ground coordinateplane
- ground plane on the z axis- Returns:
- a
Point
on screen corresponding to the position in 3D-space
-
localToCanvas
@Nullable public static Point localToCanvas(@Nonnull Client client, @Nonnull LocalPoint point, int plane, int zOffset)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.- Parameters:
client
- the game clientpoint
- ground coordinateplane
- ground plane on the z axiszOffset
- distance from ground on the z axis- Returns:
- a
Point
on screen corresponding to the position in 3D-space
-
localToCanvas
public static Point localToCanvas(@Nonnull Client client, int x, int y, int z)
Translates three-dimensional local coordinates within the 3D world to their corresponding coordinates on the game screen.- Parameters:
client
- the game clientx
- ground coordinate on the x axisy
- ground coordinate on the y axisz
-- Returns:
- a
Point
on screen corresponding to the position in 3D-space
-
modelToCanvas
public static void modelToCanvas(Client client, int end, int x3dCenter, int y3dCenter, int z3dCenter, int rotate, float[] x3d, float[] y3d, float[] z3d, int[] x2d, int[] y2d)
Translates a model's vertices into 2d space.
-
localToMinimap
@Nullable public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.- Parameters:
client
- the game clientpoint
- ground coordinate- Returns:
- a
Point
on screen corresponding to the position in 3D-space
-
localToMinimap
@Nullable public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point, int distance)
Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.- Parameters:
client
- the game clientpoint
- ground coordinatedistance
- max distance from local player to minimap point- Returns:
- a
Point
on screen corresponding to the position in 3D-space
-
getTileHeight
public static int getTileHeight(@Nonnull Client client, @Nonnull LocalPoint point, int plane)
Calculates the above ground height of a tile point.- Parameters:
client
- the game clientpoint
- the local ground coordinateplane
- the client plane/ground level- Returns:
- the offset from the ground of the tile
-
getCanvasTilePoly
public static Polygon getCanvasTilePoly(@Nonnull Client client, @Nonnull LocalPoint localLocation)
Calculates a tile polygon from offset worldToScreen() points.- Parameters:
client
- the game clientlocalLocation
- local location of the tile- Returns:
- a
Polygon
on screen corresponding to the given localLocation.
-
getCanvasTilePoly
public static Polygon getCanvasTilePoly(@Nonnull Client client, @Nonnull LocalPoint localLocation, int zOffset)
Calculates a tile polygon from offset worldToScreen() points.- Parameters:
client
- the game clientlocalLocation
- local location of the tilezOffset
- offset from ground plane- Returns:
- a
Polygon
on screen corresponding to the given localLocation.
-
getCanvasTileAreaPoly
public static Polygon getCanvasTileAreaPoly(@Nonnull Client client, @Nonnull LocalPoint localLocation, int size)
Returns a polygon representing an area.- Parameters:
client
- the game clientlocalLocation
- the center location of the AoEsize
- the size of the area (ie. 3x3 AoE evaluates to size 3)- Returns:
- a polygon representing the tiles in the area
-
getCanvasTileAreaPoly
public static Polygon getCanvasTileAreaPoly(@Nonnull Client client, @Nonnull LocalPoint localLocation, int sizeX, int sizeY, int plane, int zOffset)
Returns a polygon representing an area.- Parameters:
client
- the game clientlocalLocation
- the center location of the AoEsizeX
- the size of the area in tiles on the x axissizeY
- the size of the area in tiles on the y axisplane
- the plane of the areazOffset
- offset from ground plane- Returns:
- a polygon representing the tiles in the area
-
getCanvasTextLocation
public static Point getCanvasTextLocation(@Nonnull Client client, @Nonnull Graphics2D graphics, @Nonnull LocalPoint localLocation, @Nullable String text, int zOffset)
Calculates text position and centers depending on string length.- Parameters:
client
- the game clientgraphics
- the game graphicslocalLocation
- local location of the tiletext
- string for width measurementzOffset
- offset from ground plane- Returns:
- a
Point
on screen corresponding to the given localLocation.
-
getCanvasImageLocation
public static Point getCanvasImageLocation(@Nonnull Client client, @Nonnull LocalPoint localLocation, @Nonnull BufferedImage image, int zOffset)
Calculates image position and centers depending on image size.- Parameters:
client
- the game clientlocalLocation
- local location of the tileimage
- image for size measurementzOffset
- offset from ground plane- Returns:
- a
Point
on screen corresponding to the given localLocation.
-
getMiniMapImageLocation
public static Point getMiniMapImageLocation(@Nonnull Client client, @Nonnull LocalPoint localLocation, @Nonnull BufferedImage image)
Calculates image position and centers depending on image size.- Parameters:
client
- the game clientlocalLocation
- local location of the tileimage
- image for size measurement- Returns:
- a
Point
on screen corresponding to the given localLocation.
-
getCanvasSpriteLocation
public static Point getCanvasSpriteLocation(@Nonnull Client client, @Nonnull LocalPoint localLocation, @Nonnull SpritePixels sprite, int zOffset)
Calculates sprite position and centers depending on sprite size.- Parameters:
client
- the game clientlocalLocation
- local location of the tilesprite
- SpritePixel for size measurementzOffset
- offset from ground plane- Returns:
- a
Point
on screen corresponding to the given localLocation.
-
getClickbox
@Nullable @Internal public static Shape getClickbox(@Nonnull Client client, Model model, int orientation, int x, int y, int z)
You don't want this. UseTileObject.getClickbox()
instead.Get the on-screen clickable area of
model
as though it's for the object on the tile at (localX
,localY
) and rotated to angleorientation
.- Parameters:
client
- the game clientmodel
- the model to calculate a clickbox fororientation
- the orientation of the model (0-2048, where 0 is north)x
- x coord in local spacez
- y coord in local space- Returns:
- the clickable area of the model
-
getCanvasTextMiniMapLocation
public static Point getCanvasTextMiniMapLocation(@Nonnull Client client, @Nonnull Graphics2D graphics, @Nonnull LocalPoint localLocation, @Nonnull String text)
Calculates text position and centers on minimap depending on string length.- Parameters:
client
- the game clientgraphics
- the game graphicslocalLocation
- local location of the tiletext
- string for width measurement- Returns:
- a
Point
on screen corresponding to the given localLocation.
-
-