Class CoordFine
Coord) is
composed of 128 fine units. Fine space provides sub-tile precision used
for movement, interpolation, animation, and rendering.
A CoordFine stores:
matrixId– the ID of theRSWorldMatrixdefining the local scene originx– fine-space X coordinate (matrix-relative)y– fine-space Y coordinate (matrix-relative)floorLevel– the plane (0–3)
The coordinate is expressed in matrix-relative fine space. To convert a
world Coord into fine units, the world matrix base coordinates are
subtracted, then multiplied by 128, then sub-tile offsets are added.
One full world tile equals 128 fine units.
In the game engine, this is referred to as CoordFine
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondx(int x, int granularity) Translates this fine coordinate horizontally (along the X axis) by a fractional tile amount determined by the given granularity.dy(int y, int granularity) Translates this fine coordinate vertically (along the Y axis) by a fractional tile amount determined by the given granularity.booleanstatic CoordFinefrom(int matrixId, int x, int y) Constructs a new fine coordinate on floor level0, using the given matrix ID as the scene origin.static CoordFinefrom(int matrixId, int x, int y, int floorLevel) Constructs a new fine coordinate at the given matrix-relative fine X/Y values.static CoordFineConverts a world tile coordinate into a fine coordinate *relative to a specificRSWorldMatrix*, using the given sub-tile offsets.static CoordFineConverts a world tile coordinate into a fine coordinate *relative to the matrix associated with the givenCoord*, using the specified sub-tile offsets.static CoordFinefromCoordCenter(jag.oldscape.RSWorldMatrix matrix, Coord coord) Creates a fine coordinate at the center of a world tile, relative to the givenRSWorldMatrix.static CoordFinefromCoordCenter(Coord coord) Creates a fine coordinate at the center of a world tile, relative to the matrix associated with the given coord.static CoordFinefromCoordOrigin(jag.oldscape.RSWorldMatrix matrix, Coord coord) Creates a fine coordinate at the exact origin (bottom-left corner) of a world tile, relative to the givenRSWorldMatrix.static CoordFinefromCoordOrigin(Coord coord) Creates a fine coordinate at the exact origin (bottom-left corner) of a world tile, relative to the matrix associated with the given coord.intintgetSceneContext(int matrixId) intgetSubX()Returns the fine X offset within the current tile.intgetSubY()Returns the fine Y offset within the current tile.intgetX()intgetY()inthashCode()static intprecision(int granularity) Computes the fine-unit step size for a given subdivision precision.static CoordFinetoRootMatrix(jag.oldscape.RSWorldMatrix matrix, CoordFine fine) toString()translate(int x, int y) translate(int x, int y, int granularity) Translates this fine coordinate by a movement expressed in tile units, scaled by a specified granularity.Translates this fine coordinate in the direction specified byDirection, scaled by the given granularity.
-
Field Details
-
NIL
-
UNITS_PER_SQUARE
public static final int UNITS_PER_SQUARE- See Also:
-
HALF_SQUARE_UNITS
public static final int HALF_SQUARE_UNITS- See Also:
-
-
Method Details
-
precision
public static int precision(int granularity) Computes the fine-unit step size for a given subdivision precision.For example:
precision(1) = 128 // whole tile precision(2) = 64 // half-tile precision(4) = 32 // quarter-tile precision(8) = 16 // eighth-tile
- Parameters:
granularity- number of subdivisions per tile (must divide 128)- Returns:
- the fine-unit size of each subdivided segment
-
from
Constructs a new fine coordinate at the given matrix-relative fine X/Y values.The coordinate is associated with a specific world matrix identified by
matrixId. The valuesxandyare interpreted directly in matrix-relative fine space (not world-absolute space).- Parameters:
matrixId- the ID of the world matrix defining the local scene originx- fine-space X coordinate, relative to that matrixy- fine-space Y coordinate, relative to that matrixfloorLevel- the floor/plane (0–3)- Returns:
- a new
CoordFinerepresenting the given matrix-relative fine position
-
from
Constructs a new fine coordinate on floor level0, using the given matrix ID as the scene origin.- Parameters:
matrixId- the ID of the world matrix defining the local scene originx- fine-space X coordinate, relative to that matrixy- fine-space Y coordinate, relative to that matrix- Returns:
- a new
CoordFineon floor level0
-
toRootMatrix
-
fromCoord
public static CoordFine fromCoord(jag.oldscape.RSWorldMatrix matrix, Coord coord, int subX, int subY) Converts a world tile coordinate into a fine coordinate *relative to a specificRSWorldMatrix*, using the given sub-tile offsets.The world-space
Coordis first transformed into scene-space by subtractingmatrix.getBaseX()andmatrix.getBaseY(). The resulting scene-space tile coordinates are then scaled into fine units (128 per tile), and finallysubXandsubYare added to position the coordinate within the tile.subXandsubYmust be in the range0–127, representing the fine-unit offset inside a tile.- Parameters:
matrix- the world matrix providing the base/scene origincoord- the world-space tile coordinate to convertsubX- fine X offset within the tile (0–127)subY- fine Y offset within the tile (0–127)- Returns:
- a
CoordFinerepresenting the matrix-relative fine location
-
fromCoord
Converts a world tile coordinate into a fine coordinate *relative to the matrix associated with the givenCoord*, using the specified sub-tile offsets.This is a convenience overload that resolves the appropriate
RSWorldMatrixby callingGame.getMatrixAt(coord), then delegates tofromCoord(RSWorldMatrix, Coord, int, int).- Parameters:
coord- the world-space tile coordinatesubX- fine X offset within the tile (0–127)subY- fine Y offset within the tile (0–127)- Returns:
- a
CoordFinerepresenting the matrix-relative fine location
-
fromCoordOrigin
Creates a fine coordinate at the exact origin (bottom-left corner) of a world tile, relative to the givenRSWorldMatrix.The world-space
Coordis first converted into scene-space using the provided matrix, then scaled into fine units (128 per tile). The resulting fine coordinate will be at sub-tile offsets(0, 0).- Parameters:
matrix- the world matrix providing the base/scene origincoord- the world-space tile coordinate- Returns:
- a
CoordFinelocated at the tile origin in matrix-relative fine space
-
fromCoordOrigin
Creates a fine coordinate at the exact origin (bottom-left corner) of a world tile, relative to the matrix associated with the given coord.This is a convenience overload that resolves the appropriate
RSWorldMatrixviaGame.getMatrixAt(coord), then delegates tofromCoordOrigin(RSWorldMatrix, Coord).- Parameters:
coord- the world-space tile coordinate- Returns:
- a
CoordFinelocated at the tile origin in matrix-relative fine space
-
fromCoordCenter
Creates a fine coordinate at the center of a world tile, relative to the givenRSWorldMatrix.This uses
precision(2)(which equals64fine units), placing the coordinate at the center of the tile at sub-tile offsets(64, 64).- Parameters:
matrix- the world matrix providing the base/scene origincoord- the world-space tile coordinate- Returns:
- a
CoordFinelocated at the tile center in matrix-relative fine space
-
fromCoordCenter
Creates a fine coordinate at the center of a world tile, relative to the matrix associated with the given coord.This is a convenience overload that resolves the appropriate
RSWorldMatrixviaGame.getMatrixAt(coord), then delegates tofromCoordCenter(RSWorldMatrix, Coord).- Parameters:
coord- the world-space tile coordinate- Returns:
- a
CoordFinelocated at the tile center in matrix-relative fine space
-
getCoordView
-
getSceneContext
-
getSceneContext
-
getMatrixId
public int getMatrixId() -
getX
public int getX() -
getY
public int getY() -
getFloorLevel
public int getFloorLevel() -
getSubX
public int getSubX()Returns the fine X offset within the current tile.Equivalent to
x % 128.- Returns:
- sub-tile X offset in the range 0–127
-
getSubY
public int getSubY()Returns the fine Y offset within the current tile.Equivalent to
y % 128.- Returns:
- sub-tile Y offset in the range 0–127
-
translate
Translates this fine coordinate by a movement expressed in tile units, scaled by a specified granularity.Granularity defines how many sbdivisions a tile is split into:
granularity = 1 -> full tile movement (128 fine units) granularity = 2 -> half-tile movement ( 64 fine units) granularity = 4 -> quarter-tile movement ( 32 fine units) granularity = 8 -> eighth-tile movement ( 16 fine units) ...
- Parameters:
x- the delta along the tile X axis (positive = east, negative = west)y- the delta along the tile Y axis (positive = north, negative = south)granularity- how many equal subdivisions of a tile to move per unit ofx/y- Returns:
- a new
CoordFineoffset by (x,y) at the given granularity
-
translate
- Parameters:
x- The fine x units to translatey- The fine y units to translate- Returns:
- a new
CoordFineoffset by (x,y)
-
translateHalfCoord
-
translate
Translates this fine coordinate in the direction specified byDirection, scaled by the given granularity.This is equivalent to:
translate(direction.getXOffset(), direction.getYOffset(), granularity)
- Parameters:
direction- the movement direction (supports 4, 8, or 16 movement directions)granularity- how many subdivisions of a tile to move in the given direction- Returns:
- a new
CoordFinerepresenting the translated position
-
dx
Translates this fine coordinate horizontally (along the X axis) by a fractional tile amount determined by the given granularity.Positive
xmoves east; negative moves west.- Parameters:
x- the tile-based horizontal deltagranularity- how many subdivisions of a tile to move per unit ofx- Returns:
- a new
CoordFinerepresenting the translated position
-
dy
Translates this fine coordinate vertically (along the Y axis) by a fractional tile amount determined by the given granularity.Positive
ymoves north; negative moves south.- Parameters:
y- the tile-based vertical deltagranularity- how many subdivisions of a tile to move per unit ofy- Returns:
- a new
CoordFinerepresenting the translated position
-
equals
-
hashCode
-
toString
-