Compare commits

..

3 commits

Author SHA1 Message Date
GregF
b55267ae61 Merge branch 'SlayerPluginUpdate' into 'master'
Update the slayer plugin to support all slayer tasks

See merge request 2009scape/rt4-client!22
2024-11-04 22:47:46 +00:00
Ceikry
f668d14be6 Merge branch 'resizable-sd-screenpos' into 'master'
Resizable SD Screenpos Support

See merge request 2009scape/rt4-client!27
2024-11-04 22:42:52 +00:00
downthecrop
5d59aea830 Resizable SD Screenpos Support 2024-11-04 22:42:52 +00:00

View file

@ -307,6 +307,7 @@ public class API {
public static int[] CalculateSceneGraphScreenPosition(int entityX, int entityZ, int yOffset) {
final int HALF_FIXED_WIDTH = 256;
final int HALF_FIXED_HEIGHT = 167;
final int RESIZABLE_SD_OFFSET = 500;
int elevation = SceneGraph.getTileHeight(plane, entityX, entityZ) - yOffset;
entityX -= SceneGraph.cameraX;
@ -334,8 +335,20 @@ public class API {
screenPos[1] = HALF_FIXED_HEIGHT + ((elevation << 9) / entityZ);
} else {
Dimension canvas = GetWindowDimensions();
double newViewDistH = (canvas.width / 2) / Math.tan(Math.toRadians(GlRenderer.hFOV) / 2);
double newViewDistV = (canvas.height / 2) / Math.tan(Math.toRadians(GlRenderer.vFOV) / 2);
double newViewDistH;
double newViewDistV;
if (API.IsHD()) {
newViewDistH = (canvas.width / 2) / Math.tan(Math.toRadians(GlRenderer.hFOV) / 2);
newViewDistV = (canvas.height / 2) / Math.tan(Math.toRadians(GlRenderer.vFOV) / 2);
} else {
double aspectRatio = (double) canvas.width / canvas.height;
double vFOV = 2 * Math.toDegrees(Math.atan((double) canvas.height / (2 * RESIZABLE_SD_OFFSET)));
double hFOV = 2 * Math.toDegrees(Math.atan(Math.tan(Math.toRadians(vFOV / 2)) * aspectRatio));
newViewDistH = (canvas.width / 2) / Math.tan(Math.toRadians(hFOV) / 2);
newViewDistV = (canvas.height / 2) / Math.tan(Math.toRadians(vFOV) / 2);
}
screenPos[0] = canvas.width / 2 + (int) ((entityX * newViewDistH) / entityZ);
screenPos[1] = canvas.height / 2 + (int) ((elevation * newViewDistV) / entityZ);
}