Package com.kraken.api.service.camera
Class CameraService
- java.lang.Object
-
- com.kraken.api.service.camera.CameraService
-
public class CameraService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CameraService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustPitch(float percentage)Adjusts the camera pitch to the specified percentage.intangleToTile(net.runelite.api.Actor t)Calculates the angle in degrees from the local player to the specified actor.intangleToTile(net.runelite.api.coords.LocalPoint localPoint)Calculates the angle in degrees from the local player to the specified local point.intangleToTile(net.runelite.api.coords.WorldPoint worldPoint)Calculates the angle in degrees from the local player to the specified world point.intangleToTile(net.runelite.api.TileObject t)Calculates the angle in degrees from the local player to the specified tile object.intcalculateCameraYaw(int npcAngle)Calculates the CameraYaw based on the given NPC or object angle.floatcameraPitchPercentage()Calculates the current camera pitch as a percentage of the total pitch range.voidcenterTileOnScreen(net.runelite.api.coords.LocalPoint tile)Rotates the camera to center on the specified tile, using a default margin tolerance of 10%.voidcenterTileOnScreen(net.runelite.api.coords.LocalPoint tile, double marginPercentage)Rotates the camera to center on the specified tile, if it is not already within the given margin tolerance.intgetAngle()Gets the current camera yaw angle.intgetAngleTo(int degrees)Calculates the angular difference between the current camera angle and the target angle.intgetCharacterAngle(net.runelite.api.Actor actor)Gets the camera angle needed to face the specified actor.intgetObjectAngle(net.runelite.api.TileObject tileObject)Gets the camera angle needed to face the specified tile object.intgetPitch()Gets the current camera pitch value.intgetTileAngle(net.runelite.api.Actor actor)Calculates the camera angle needed to face the specified actor.intgetTileAngle(net.runelite.api.TileObject tileObject)Calculates the camera angle needed to face the specified tile object.intgetYaw()Gets the current camera yaw (compass facing direction).intgetZoom()Gets the current camera zoom level.booleanisAngleGood(int targetAngle, int desiredMaxAngle)Checks if the angle to the target is within the desired max anglebooleanisTileCenteredOnScreen(net.runelite.api.coords.LocalPoint tile)Determines whether the specified tile is centered on the screen, using a default margin tolerance of 10%.booleanisTileCenteredOnScreen(net.runelite.api.coords.LocalPoint tile, double marginPercentage)Determines whether the specified tile is centered on the screen within a given tolerance.booleanisTileOnScreen(net.runelite.api.coords.LocalPoint localPoint)Checks if the specified local point is visible on the screen.booleanisTileOnScreen(net.runelite.api.TileObject tileObject)Checks if the specified tile object is visible on the screen.booleanisTrackingNpc()Checks if a NPC is being trackedvoidresetPitch()Resets the camera pitch to 280 if it is currently less than 280.voidresetZoom()Resets the camera zoom to 200 if it is currently greater than 200.voidsetAngle(int targetDegrees, int maxAngle)Sets the angle of the camera to the target degrees limited by the max angle.voidsetPitch(int pitch)Sets the camera pitch to the specified value.voidsetYaw(int yaw)Sets the camera yaw (compass facing direction).voidsetZoom(int zoom)Sets the camera zoom to the specified level.voidstopTrackingNpc()Stop tracking the NPC with the cameravoidtrackNpc(int npcId)Track the NPC with the cameravoidturnTo(net.runelite.api.Actor actor)Rotates the camera to face the specified actor with a default maximum angle of 40 degrees.voidturnTo(net.runelite.api.Actor actor, int maxAngle)Rotates the camera to face the specified actor with a custom maximum angle.voidturnTo(net.runelite.api.coords.LocalPoint localPoint)Rotates the camera to face the specified local point with a default maximum angle of 40 degrees.voidturnTo(net.runelite.api.coords.LocalPoint localPoint, int maxAngle)Rotates the camera to face the specified local point with a custom maximum angle.voidturnTo(net.runelite.api.TileObject tileObject)Rotates the camera to face the specified tile object with a default maximum angle of 40 degrees.voidturnTo(net.runelite.api.TileObject tileObject, int maxAngle)Rotates the camera to face the specified tile object with a custom maximum angle.
-
-
-
Method Detail
-
angleToTile
public int angleToTile(net.runelite.api.Actor t)
Calculates the angle in degrees from the local player to the specified actor.- Parameters:
t- the target actor- Returns:
- the angle in degrees (0-359), where 0 is east and increases counter-clockwise
-
angleToTile
public int angleToTile(net.runelite.api.TileObject t)
Calculates the angle in degrees from the local player to the specified tile object.- Parameters:
t- the target tile object- Returns:
- the angle in degrees (0-359), where 0 is east and increases counter-clockwise
-
angleToTile
public int angleToTile(net.runelite.api.coords.LocalPoint localPoint)
Calculates the angle in degrees from the local player to the specified local point.- Parameters:
localPoint- the target local point- Returns:
- the angle in degrees (0-359), where 0 is east and increases counter-clockwise
-
angleToTile
public int angleToTile(net.runelite.api.coords.WorldPoint worldPoint)
Calculates the angle in degrees from the local player to the specified world point.- Parameters:
worldPoint- the target world point- Returns:
- the angle in degrees (0-359), where 0 is east and increases counter-clockwise
-
turnTo
public void turnTo(net.runelite.api.Actor actor)
Rotates the camera to face the specified actor with a default maximum angle of 40 degrees.- Parameters:
actor- the actor to turn towards
-
turnTo
public void turnTo(net.runelite.api.Actor actor, int maxAngle)Rotates the camera to face the specified actor with a custom maximum angle.- Parameters:
actor- the actor to turn towardsmaxAngle- the maximum angle to rotate in a single adjustment
-
turnTo
public void turnTo(net.runelite.api.TileObject tileObject)
Rotates the camera to face the specified tile object with a default maximum angle of 40 degrees.- Parameters:
tileObject- the tile object to turn towards
-
turnTo
public void turnTo(net.runelite.api.TileObject tileObject, int maxAngle)Rotates the camera to face the specified tile object with a custom maximum angle.- Parameters:
tileObject- the tile object to turn towardsmaxAngle- the maximum angle to rotate in a single adjustment
-
turnTo
public void turnTo(net.runelite.api.coords.LocalPoint localPoint)
Rotates the camera to face the specified local point with a default maximum angle of 40 degrees.- Parameters:
localPoint- the local point to turn towards
-
turnTo
public void turnTo(net.runelite.api.coords.LocalPoint localPoint, int maxAngle)Rotates the camera to face the specified local point with a custom maximum angle.- Parameters:
localPoint- the local point to turn towardsmaxAngle- the maximum angle to rotate in a single adjustment
-
getCharacterAngle
public int getCharacterAngle(net.runelite.api.Actor actor)
Gets the camera angle needed to face the specified actor.- Parameters:
actor- the target actor- Returns:
- the camera angle in degrees (0-359)
-
getObjectAngle
public int getObjectAngle(net.runelite.api.TileObject tileObject)
Gets the camera angle needed to face the specified tile object.- Parameters:
tileObject- the target tile object- Returns:
- the camera angle in degrees (0-359)
-
getTileAngle
public int getTileAngle(net.runelite.api.Actor actor)
Calculates the camera angle needed to face the specified actor. Adjusts the mathematical angle to camera coordinates.- Parameters:
actor- the target actor- Returns:
- the camera angle in degrees (0-359)
-
getTileAngle
public int getTileAngle(net.runelite.api.TileObject tileObject)
Calculates the camera angle needed to face the specified tile object. Adjusts the mathematical angle to camera coordinates.- Parameters:
tileObject- the target tile object- Returns:
- the camera angle in degrees (0-359)
-
isAngleGood
public boolean isAngleGood(int targetAngle, int desiredMaxAngle)Checks if the angle to the target is within the desired max angle
The desired max angle should not go over 80-90 degrees as the target will be out of view
- Parameters:
targetAngle- the angle to the targetdesiredMaxAngle- the maximum angle to the target (Should be a positive number)- Returns:
- true if the angle to the target is within the desired max angle
-
setAngle
public void setAngle(int targetDegrees, int maxAngle)Sets the angle of the camera to the target degrees limited by the max angle.- Parameters:
targetDegrees- the angle to the targetmaxAngle- the maximum angle to the target (Should be a positive number)
-
adjustPitch
public void adjustPitch(float percentage)
Adjusts the camera pitch to the specified percentage. Uses keyboard input to smoothly transition to the target pitch.- Parameters:
percentage- the target pitch as a percentage (0.0 to 1.0, where 0 is looking down and 1 is looking up)
-
getPitch
public int getPitch()
Gets the current camera pitch value.- Returns:
- the current camera pitch (128-383, where 128 is looking down and 383 is looking up)
-
setPitch
public void setPitch(int pitch)
Sets the camera pitch to the specified value. The pitch is clamped between the minimum (128) and maximum (383) values.- Parameters:
pitch- the target pitch value (will be clamped to 128-383 range)
-
cameraPitchPercentage
public float cameraPitchPercentage()
Calculates the current camera pitch as a percentage of the total pitch range.- Returns:
- the pitch percentage (0.0 to 1.0, where 0 is looking down and 1 is looking up)
-
getAngleTo
public int getAngleTo(int degrees)
Calculates the angular difference between the current camera angle and the target angle. Returns a positive value if the target is to the left, negative if to the right.- Parameters:
degrees- the target angle in degrees- Returns:
- the angular difference (-180 to 180 degrees)
-
getAngle
public int getAngle()
Gets the current camera yaw angle. Converts from the client's fixed-point radians to degrees.- Returns:
- the current camera angle in degrees (0-359)
-
calculateCameraYaw
public int calculateCameraYaw(int npcAngle)
Calculates the CameraYaw based on the given NPC or object angle.- Parameters:
npcAngle- the angle of the NPC or object relative to the player (0-359 degrees)- Returns:
- the calculated CameraYaw (0-2047)
-
trackNpc
public void trackNpc(int npcId)
Track the NPC with the camera- Parameters:
npcId- the ID of the NPC to track
-
stopTrackingNpc
public void stopTrackingNpc()
Stop tracking the NPC with the camera
-
isTrackingNpc
public boolean isTrackingNpc()
Checks if a NPC is being tracked- Returns:
- true if a NPC is being tracked, false otherwise
-
isTileOnScreen
public boolean isTileOnScreen(net.runelite.api.TileObject tileObject)
Checks if the specified tile object is visible on the screen.- Parameters:
tileObject- the tile object to check- Returns:
- true if the tile object is within the viewport bounds, false otherwise
-
isTileOnScreen
public boolean isTileOnScreen(net.runelite.api.coords.LocalPoint localPoint)
Checks if the specified local point is visible on the screen. Verifies that the tile polygon intersects with the viewport and that the tile is in front of the camera.- Parameters:
localPoint- the local point to check- Returns:
- true if the tile is within the viewport bounds and in front of the camera, false otherwise
-
getZoom
public int getZoom()
Gets the current camera zoom level.- Returns:
- the current zoom value from VarClientInt.CAMERA_ZOOM_RESIZABLE_VIEWPORT
-
setZoom
public void setZoom(int zoom)
Sets the camera zoom to the specified level. Invokes the CAMERA_DO_ZOOM script on the client thread.- Parameters:
zoom- the target zoom level
-
getYaw
public int getYaw()
Gets the current camera yaw (compass facing direction).- Returns:
- the current yaw value (0-2047, where 0/2048=North, 512=West, 1024=South, 1536=East)
-
setYaw
public void setYaw(int yaw)
Sets the camera yaw (compass facing direction).Yaw values:
- North = 0, 2048
- East = 1536
- South = 1024
- West = 512
- Parameters:
yaw- the target yaw value (must be between 0 and 2047)
-
resetPitch
public void resetPitch()
Resets the camera pitch to 280 if it is currently less than 280.
-
resetZoom
public void resetZoom()
Resets the camera zoom to 200 if it is currently greater than 200.
-
isTileCenteredOnScreen
public boolean isTileCenteredOnScreen(net.runelite.api.coords.LocalPoint tile, double marginPercentage)Determines whether the specified tile is centered on the screen within a given tolerance.Projects the tile to screen space, computes its bounding rectangle, and then checks whether that rectangle lies entirely inside a centered "box" whose width and height are the given percentage of the viewport dimensions.
- Parameters:
tile- the local tile coordinate to test (may not be null)marginPercentage- the size of the centered tolerance box, expressed as a percentage of the viewport (e.g. 10.0 for 10%)- Returns:
trueif the tile's screen bounds lie entirely within the centered margin box;falseif the tile cannot be projected or lies outside that box
-
isTileCenteredOnScreen
public boolean isTileCenteredOnScreen(net.runelite.api.coords.LocalPoint tile)
Determines whether the specified tile is centered on the screen, using a default margin tolerance of 10%.- Parameters:
tile- the local tile coordinate to test (may not be null)- Returns:
trueif the tile's screen bounds lie entirely within the centered 10% margin box;falseotherwise- See Also:
isTileCenteredOnScreen(LocalPoint, double)
-
centerTileOnScreen
public void centerTileOnScreen(net.runelite.api.coords.LocalPoint tile, double marginPercentage)Rotates the camera to center on the specified tile, if it is not already within the given margin tolerance.Computes the bearing from the camera to the tile, adjusts it into a [0–360) range, and then issues a small-angle camera turn if
isTileCenteredOnScreen(LocalPoint, double)returnsfalse.- Parameters:
tile- the local tile coordinate to center on (may not be null)marginPercentage- the size of the centered tolerance box, expressed as a percentage of the viewport (e.g. 10.0 for 10%)- See Also:
angleToTile(LocalPoint),setAngle(int, int)
-
centerTileOnScreen
public void centerTileOnScreen(net.runelite.api.coords.LocalPoint tile)
Rotates the camera to center on the specified tile, using a default margin tolerance of 10%.- Parameters:
tile- the local tile coordinate to center on (may not be null)- See Also:
centerTileOnScreen(LocalPoint, double)
-
-