Class Perspective


  • public class Perspective
    extends Object
    A utility class containing methods to help with conversion between in-game features to canvas areas.
    • Constructor Detail

      • Perspective

        public Perspective()
    • 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 client
        point - ground coordinate
        plane - 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 client
        point - ground coordinate
        plane - ground plane on the z axis
        zOffset - 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 client
        x - ground coordinate on the x axis
        y - ground coordinate on the y axis
        z -
        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,
                                         int[] x3d,
                                         int[] y3d,
                                         int[] 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 client
        point - 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 client
        point - ground coordinate
        distance - 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 client
        point - the local ground coordinate
        plane - 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 client
        localLocation - 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 client
        localLocation - local location of the tile
        zOffset - 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 client
        localLocation - the center location of the AoE
        size - 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 size,
                                                    int zOffset)
        Returns a polygon representing an area.
        Parameters:
        client - the game client
        localLocation - the center location of the AoE
        size - the size of the area (ie. 3x3 AoE evaluates to size 3)
        zOffset - 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 client
        graphics - the game graphics
        localLocation - local location of the tile
        text - string for width measurement
        zOffset - 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 client
        localLocation - local location of the tile
        image - image for size measurement
        zOffset - 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 client
        localLocation - local location of the tile
        image - 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 client
        localLocation - local location of the tile
        sprite - SpritePixel for size measurement
        zOffset - offset from ground plane
        Returns:
        a Point on screen corresponding to the given localLocation.
      • getClickbox

        @Nullable
        public static Shape getClickbox​(@Nonnull
                                        Client client,
                                        Model model,
                                        int orientation,
                                        LocalPoint point)
        You don't want this. Use TileObject.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 angle orientation.

        Parameters:
        client - the game client
        model - the model to calculate a clickbox for
        orientation - the orientation of the model (0-2048, where 0 is north)
        point - the coordinate of the tile
        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 client
        graphics - the game graphics
        localLocation - local location of the tile
        text - string for width measurement
        Returns:
        a Point on screen corresponding to the given localLocation.