public class MisoUtil extends Object implements DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST| Constructor and Description |
|---|
MisoUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
coordsToKey(int x,
int y)
Turns x and y scene coordinates into an integer key.
|
static int |
fineToFull(MisoSceneMetrics metrics,
int fine)
Converts the given fine coordinate to a full coordinate (a tile
coordinate plus a fine coordinate remainder).
|
static void |
fineToPixel(MisoSceneMetrics metrics,
int x,
int y,
Point ppos)
Convert the given fine coordinates to pixel coordinates within
the containing tile.
|
static int |
fullToFine(int val)
Returns the fine coordinate of the given full coordinate.
|
static Point |
fullToScreen(MisoSceneMetrics metrics,
int x,
int y,
Point spos)
Convert the given full coordinates to screen-based pixel
coordinates.
|
static int |
fullToTile(int val)
Returns the tile coordinate of the given full coordinate.
|
static int |
getDirection(MisoSceneMetrics metrics,
int ax,
int ay,
int bx,
int by)
Given two points in screen pixel coordinates, return the
compass direction that point B lies in from point A from an
isometric perspective.
|
static Polygon |
getFootprintPolygon(MisoSceneMetrics metrics,
int x,
int y,
int width,
int height)
Returns a polygon framing the specified scene footprint.
|
static int |
getIsoDirection(int ax,
int ay,
int bx,
int by)
Given two points in an isometric coordinate system (in which
DirectionCodes.NORTH is in the direction of the negative x-axis and DirectionCodes.WEST in the direction of the negative y-axis), return the compass
direction that point B lies in from point A. |
static Polygon |
getMultiTilePolygon(MisoSceneMetrics metrics,
Point sp1,
Point sp2)
Return a screen-coordinates polygon framing the two specified
tile-coordinate points.
|
static int |
getProjectedIsoDirection(int ax,
int ay,
int bx,
int by)
Given two points in screen coordinates, return the isometrically
projected compass direction that point B lies in from point A.
|
static Polygon |
getTilePolygon(MisoSceneMetrics metrics,
int x,
int y)
Return a polygon framing the specified tile.
|
static void |
pixelToFine(MisoSceneMetrics metrics,
int x,
int y,
Point fpos)
Convert the given pixel coordinates, whose origin is at the
top-left of a tile's containing rectangle, to fine coordinates
within that tile.
|
static Point |
screenToFull(MisoSceneMetrics metrics,
int sx,
int sy,
Point fpos)
Convert the given screen-based pixel coordinates to full
scene-based coordinates that include both the tile coordinates
and the fine coordinates in each dimension.
|
static Point |
screenToTile(MisoSceneMetrics metrics,
int sx,
int sy,
Point tpos)
Convert the given screen-based pixel coordinates to their
corresponding tile-based coordinates.
|
static Point |
tilePlusFineToFull(MisoSceneMetrics metrics,
int tileX,
int tileY,
int fineX,
int fineY,
Point full)
Adds the supplied fine coordinates to the supplied tile coordinates
to compute full coordinates.
|
static int |
tileToFull(int tile)
Returns the supplied tile coordinate as a full coordinate assuming a fine offset of 0.
|
static Point |
tileToScreen(MisoSceneMetrics metrics,
int x,
int y,
Point spos)
Convert the given tile-based coordinates to their corresponding
screen-based pixel coordinates.
|
static int |
toFull(int tile,
int fine)
Composes the supplied tile coordinate and fine coordinate offset
into a full coordinate.
|
static int |
toIsoDirection(int dir)
Converts a non-isometric orientation (where north points toward the
top of the screen) to an isometric orientation where north points
toward the upper-left corner of the screen.
|
static int |
xCoordFromKey(int key)
Gets the x coordinate from an integer hash key.
|
static int |
yCoordFromKey(int key)
Gets the y coordinate from an integer hash key.
|
public static int getDirection(MisoSceneMetrics metrics, int ax, int ay, int bx, int by)
ax - the x-position of point A.ay - the y-position of point A.bx - the x-position of point B.by - the y-position of point B.Sprite
class's direction constants.public static int getIsoDirection(int ax,
int ay,
int bx,
int by)
DirectionCodes.NORTH is in the direction of the negative x-axis and DirectionCodes.WEST in the direction of the negative y-axis), return the compass
direction that point B lies in from point A. This method is used
to determine direction for both tile coordinates and fine
coordinates within a tile, since the coordinate systems are the
same.ax - the x-position of point A.ay - the y-position of point A.bx - the x-position of point B.by - the y-position of point B.Sprite
class's direction constants, or DirectionCodes.NONE if
point B is equivalent to point A.public static int getProjectedIsoDirection(int ax,
int ay,
int bx,
int by)
ax - the x-position of point A.ay - the y-position of point A.bx - the x-position of point B.by - the y-position of point B.Sprite
class's direction constants, or DirectionCodes.NONE if
point B is equivalent to point A.public static int toIsoDirection(int dir)
public static int fullToTile(int val)
public static int fullToFine(int val)
public static Point screenToTile(MisoSceneMetrics metrics, int sx, int sy, Point tpos)
sx - the screen x-position pixel coordinate.sy - the screen y-position pixel coordinate.tpos - the point object to place coordinates in.tpos
parameter.public static Point tileToScreen(MisoSceneMetrics metrics, int x, int y, Point spos)
x - the tile x-position coordinate.y - the tile y-position coordinate.spos - the point object to place coordinates in.spos
parameter.public static void fineToPixel(MisoSceneMetrics metrics, int x, int y, Point ppos)
x - the x-position fine coordinate.y - the y-position fine coordinate.ppos - the point object to place coordinates in.public static void pixelToFine(MisoSceneMetrics metrics, int x, int y, Point fpos)
x - the x-position pixel coordinate.y - the y-position pixel coordinate.fpos - the point object to place coordinates in.public static Point screenToFull(MisoSceneMetrics metrics, int sx, int sy, Point fpos)
sx - the screen x-position pixel coordinate.sy - the screen y-position pixel coordinate.fpos - the point object to place coordinates in.public static Point fullToScreen(MisoSceneMetrics metrics, int x, int y, Point spos)
x - the x-position full coordinate.y - the y-position full coordinate.spos - the point object to place coordinates in.public static int fineToFull(MisoSceneMetrics metrics, int fine)
(0, 0).public static int tileToFull(int tile)
public static int toFull(int tile,
int fine)
public static Polygon getTilePolygon(MisoSceneMetrics metrics, int x, int y)
x - the tile x-position coordinate.y - the tile y-position coordinate.public static Polygon getMultiTilePolygon(MisoSceneMetrics metrics, Point sp1, Point sp2)
public static Polygon getFootprintPolygon(MisoSceneMetrics metrics, int x, int y, int width, int height)
x - the x tile coordinate of the "upper-left" of the footprint.y - the y tile coordinate of the "upper-left" of the footprint.width - the width in tiles of the footprint.height - the height in tiles of the footprint.public static Point tilePlusFineToFull(MisoSceneMetrics metrics, int tileX, int tileY, int fineX, int fineY, Point full)
full.public static final int coordsToKey(int x,
int y)
public static final int xCoordFromKey(int key)
public static final int yCoordFromKey(int key)
Copyright © 2015. All rights reserved.