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[]COSINEstatic intLOCAL_COORD_BITSstatic intLOCAL_HALF_TILE_SIZEstatic intLOCAL_TILE_SIZEstatic intSCENE_SIZEstatic int[]SINEstatic doubleUNIT
-
Constructor Summary
Constructors Constructor Description Perspective()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static PointgetCanvasImageLocation(Client client, LocalPoint localLocation, BufferedImage image, int zOffset)Calculates image position and centers depending on image size.static PointgetCanvasSpriteLocation(Client client, LocalPoint localLocation, SpritePixels sprite, int zOffset)Calculates sprite position and centers depending on sprite size.static PointgetCanvasTextLocation(Client client, Graphics2D graphics, LocalPoint localLocation, String text, int zOffset)Calculates text position and centers depending on string length.static PointgetCanvasTextMiniMapLocation(Client client, Graphics2D graphics, LocalPoint localLocation, String text)Calculates text position and centers on minimap depending on string length.static PolygongetCanvasTileAreaPoly(Client client, LocalPoint localLocation, int size)Returns a polygon representing an area.static PolygongetCanvasTileAreaPoly(Client client, LocalPoint localLocation, int sizeX, int sizeY, int level, int heightOffset)Returns a polygon representing an area.static PolygongetCanvasTilePoly(Client client, LocalPoint localLocation)Calculates a tile polygon from offset worldToScreen() points.static PolygongetCanvasTilePoly(Client client, LocalPoint localLocation, int zOffset)Calculates a tile polygon from offset worldToScreen() points.static ShapegetClickbox(Client client, WorldView wv, Model model, int orientation, int x, int y, int z)You don't want this.static intgetFootprintTileHeight(Client client, LocalPoint p, int level, int footprintSize)static PointgetMiniMapImageLocation(Client client, LocalPoint localLocation, BufferedImage image)Calculates image position and centers depending on image size.static intgetTileHeight(Client client, LocalPoint point, int plane)Calculates the above ground height of a tile point.static PointlocalToCanvas(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 PointlocalToCanvas(Client client, int worldId, int x, int y, int z)static PointlocalToCanvas(Client client, LocalPoint point, int plane)Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.static PointlocalToCanvas(Client client, LocalPoint point, int plane, int heightOffset)Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the game screen.static PointlocalToMinimap(Client client, LocalPoint point)Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.static PointlocalToMinimap(Client client, LocalPoint point, int distance)Translates two-dimensional ground coordinates within the 3D world to their corresponding coordinates on the Minimap.static voidmodelToCanvas(Client client, int end, int x3dCenter, int y3dCenter, int z3dCenter, int rotate, float[] x3d, float[] y3d, float[] z3d, int[] x2d, int[] y2d)Deprecated.static voidmodelToCanvas(Client client, WorldView wv, 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
Pointon screen corresponding to the position in 3D-space
-
localToCanvas
@Nullable public static Point localToCanvas(@Nonnull Client client, @Nonnull LocalPoint point, int plane, int heightOffset)
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 axisheightOffset- distance from ground on the z axis- Returns:
- a
Pointon 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
Pointon screen corresponding to the position in 3D-space
-
localToCanvas
public static Point localToCanvas(@Nonnull Client client, int worldId, int x, int y, int z)
-
modelToCanvas
@Deprecated 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)
Deprecated.
-
modelToCanvas
public static void modelToCanvas(Client client, WorldView wv, 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
Pointon 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
Pointon 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
-
getFootprintTileHeight
public static int getFootprintTileHeight(@Nonnull Client client, @Nonnull LocalPoint p, int level, int footprintSize)
-
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
Polygonon 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
Polygonon 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 level, int heightOffset)
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 z axislevel- the level of the areaheightOffset- offset from ground level- 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
Pointon 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
Pointon 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
Pointon 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
Pointon screen corresponding to the given localLocation.
-
getClickbox
@Nullable @Internal public static Shape getClickbox(@Nonnull Client client, WorldView wv, 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
modelas though it's for the object on the tile at (localX,localY) and rotated to angleorientation.- Parameters:
client- the game clientwv- the worldviewmodel- 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
Pointon screen corresponding to the given localLocation.
-
-