Class Coord
- All Implemented Interfaces:
SceneNode
-
Nested Class Summary
Nested classes/interfaces inherited from interface SceneNode
SceneNode.Query<Q> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondx(int x) dy(int y) booleanstatic Coordfrom(int x, int y) Creates a newCoordat the specified world X/Y coordinates on floor level0.static Coordfrom(int x, int y, int floorLevel) Creates a newCoordfrom world-space X/Y coordinates and a floor level.static Coordfrom(int x, int y, int floorLevel, float subX, float subY) static Coordstatic CoordConverts aCoordFineinto a worldCoord, resolving the associatedRSWorldMatrixviaGame.getMatrix(int).static Coordstatic Coordstatic Coordstatic CoordfromPacked(int packed) Unpacks a 32-bit packed coordinate into aCoord.getCoord()intintfloatfloatintReturns the region ID for this coordinate.Returns the underlying world-space coordinate that thisCoordwas derived from during instance or subworld transformation.floatgetSubX()floatgetSubY()intgetX()intgetY()inthashCode()static intpack(int x, int y, int floor) Packs a tile coordinate into a 32-bit integer using the standard RuneScape-style coordinate packing format.static CoordRotates a coordinate within its containing 8x8 chunk by the given rotation.toString()translate(int x, int y) Methods inherited from interface SceneNode
distance, distance, distance, distance, getArea, getCoordArea, getCoordArea, getEntityPositionHeight, getEntityPositionWidth, getSceneContext, getWorldEntity, getWorldEntity, isInFieldOfViewOf, isInFieldOfViewOf
-
Field Details
-
NIL
-
-
Method Details
-
from
-
from
Creates a newCoordfrom world-space X/Y coordinates and a floor level.This is the primary factory method for constructing world coordinates.
- Parameters:
x- the world X coordinatey- the world Y coordinatefloorLevel- the floor/plane (typically 0–3)- Returns:
- a new
Coordrepresenting the given world position
-
from
Creates a newCoordat the specified world X/Y coordinates on floor level0.This is a convenience overload for situations where the floor is implicitly ground level.
- Parameters:
x- the world X coordinatey- the world Y coordinate- Returns:
- a new
Coordat the given world position on floor0
-
fromGrid
Converts aCoordGrid(matrix-local tile coordinate) into a world-spaceCoordusing the givenRSWorldMatrix.In the engine, a
CoordGridstores coordinates relative to the originating matrix/scene. To convert these to absolute world coordinates, the matrix base is applied:worldX = grid.x + matrix.getBaseX() worldY = grid.y + matrix.getBaseY()
The floor level is preserved.
- Parameters:
matrix- the world matrix providing base coordinate offsets; must not benullgrid- the matrix-local tile coordinate to convert- Returns:
- the corresponding world-space
Coord
-
fromGrid
Converts aCoordGridinto a world-spaceCoordby resolving the associatedRSWorldMatrixusing the given matrix ID.This is equivalent to:
Coord.fromGrid(Game.getMatrix(matrixId), grid)
- Parameters:
matrixId- the matrix ID used to look up theRSWorldMatrixgrid- the matrix-local tile coordinate to convert- Returns:
- the world-space
Coord, orCoord.NILif the matrix cannot be resolved
-
fromGrid
Converts aCoordGridinto a world-spaceCoordusing the matrix referenced directly by the grid's ownmatrixId.This is the most convenient overload and is equivalent to:
Coord.fromGrid(Game.getMatrix(grid.getMatrixId()), grid)
- Parameters:
grid- the matrix-local tile coordinate to convert- Returns:
- the corresponding world-space
Coord, orCoord.NILif the grid's matrix cannot be resolved
-
fromFine
Converts aCoordFine(fine-coordinate space, usually 128 sub-units per tile) into a world-spaceCoord, preserving sub-tile precision and automatically resolving instance and subworld transformations.This method performs the following steps in order:
- Instance coordinate translation:
If the fine coordinate originates inside a dynamically-built instanced region, the underlying instance template chunk is resolved and converted into its corresponding top-level world tile viafromInstance(...). - Subworld → root world transformation:
If the providedRSWorldMatrixdoes not match the game's top-level world matrix, the coordinate is transformed using the appropriate baseX/baseY offset viafromMatrix(...). - Fine → world tile conversion:
The fine-coordinate X/Y values are divided byCoordFine.UNITS_PER_SQUAREto recover the integer grid coordinate, and the remainder is used to computesubX/subY, which describe the precise fractional position within the tile (0.0–1.0).
The returned
Coordalways describes the final, fully-resolved world position as seen by pathfinding, collision, and interaction systems. If an instance/subworld transformation is required, the intermediate transformedCoordretains a reference to its pre-transformed world-space source coordinate viagetSource().- Parameters:
matrix- the world matrix used to interpret the fine coordinate's local basefine- the fine-resolution coordinate to convert- Returns:
- a fully resolved, world-space
Coordwith sub-tile precision
- Instance coordinate translation:
-
fromFine
Converts aCoordFineinto a worldCoord, resolving the associatedRSWorldMatrixviaGame.getMatrix(int).This is a convenience overload that calls
fromFine(RSWorldMatrix, CoordFine)with the matrix referenced byfine.getMatrixId().- Parameters:
fine- the fine-coordinate to convert; must not be null- Returns:
- a
Coordrepresenting the world coord derived from the fine position
-
fromPacked
Unpacks a 32-bit packed coordinate into aCoord.The packed format uses:
- bits 28–29: floor level (0–3)
- bits 14–27: X coordinate (0–16383)
- bits 0–13 : Y coordinate (0–16383)
- Parameters:
packed- the packed coordinate value- Returns:
- a
Coordextracted from the packed integer
-
rotate
Rotates a coordinate within its containing 8x8 chunk by the given rotation.Rotation is performed around the origin of the 8x8 chunk containing
coord, using the standard RuneScape convention:- 0 – no rotation
- 1 – 90 degrees clockwise
- 2 – 180 degrees
- 3 – 270 degrees clockwise
- Parameters:
coord- the coordinate to rotaterotation- rotation value in the range 0–3- Returns:
- a new
Coordrepresenting the rotated position
-
pack
public static int pack(int x, int y, int floor) Packs a tile coordinate into a 32-bit integer using the standard RuneScape-style coordinate packing format.The layout is:
floor (2 bits) | x (14 bits) | y (14 bits) [28..29] | [14..27] | [0..13]- Parameters:
x- the X tile coordinate (0–16383)y- the Y tile coordinate (0–16383)floor- the floor level (0–3)- Returns:
- a packed 32-bit integer containing x, y, and floor
-
getMatrixId
public int getMatrixId()- Specified by:
getMatrixIdin interfaceSceneNode
-
getX
-
getY
-
getPosition
- Specified by:
getPositionin interfaceSceneNode
-
getCoord
-
getCoordFine
- Specified by:
getCoordFinein interfaceSceneNode
-
getCoordView
- Specified by:
getCoordViewin interfaceSceneNode
-
getFloorLevel
public int getFloorLevel()- Specified by:
getFloorLevelin interfaceSceneNode
-
getSource
Returns the underlying world-space coordinate that thisCoordwas derived from during instance or subworld transformation.If this coordinate was produced by
fromFine(RSWorldMatrix, CoordFine)and required instance template translation or subworld-to-root-world matrix adjustment, the returned value corresponds to the original resolved world coordinate.If no transformation occurred, this method simply returns
this.In short:
- Normal world coords: returns
this - Instanced coords → world coords: returns the raw instance coord
- Subworld coords → top-level coords: returns the raw subworld coord
- Returns:
- the world-space source coordinate, or this coordinate if none exists
- Normal world coords: returns
-
getSubX
public float getSubX() -
getSubY
public float getSubY() -
getPreciseX
public float getPreciseX() -
getPreciseY
public float getPreciseY() -
getRegionId
public int getRegionId()Returns the region ID for this coordinate.The region ID is computed from the 8x8 regions:
regionX = x >> 6 regionY = y >> 6 regionId = (regionX invalid input: '<'invalid input: '<' 8) | regionY
- Returns:
- the packed region ID
-
translate
-
translate
-
dx
-
dy
-
getInstanced
-
hashCode
-
equals
-
toString
-