mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Compare commits
3 commits
dbde09f319
...
081ef0f8e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
081ef0f8e9 | ||
|
|
f668d14be6 | ||
|
|
5d59aea830 |
1 changed files with 18 additions and 5 deletions
|
|
@ -307,6 +307,7 @@ public class API {
|
||||||
public static int[] CalculateSceneGraphScreenPosition(int entityX, int entityZ, int yOffset) {
|
public static int[] CalculateSceneGraphScreenPosition(int entityX, int entityZ, int yOffset) {
|
||||||
final int HALF_FIXED_WIDTH = 256;
|
final int HALF_FIXED_WIDTH = 256;
|
||||||
final int HALF_FIXED_HEIGHT = 167;
|
final int HALF_FIXED_HEIGHT = 167;
|
||||||
|
final int RESIZABLE_SD_OFFSET = 500;
|
||||||
|
|
||||||
int elevation = SceneGraph.getTileHeight(plane, entityX, entityZ) - yOffset;
|
int elevation = SceneGraph.getTileHeight(plane, entityX, entityZ) - yOffset;
|
||||||
entityX -= SceneGraph.cameraX;
|
entityX -= SceneGraph.cameraX;
|
||||||
|
|
@ -329,15 +330,27 @@ public class API {
|
||||||
int[] screenPos = new int[2]; // X,Y
|
int[] screenPos = new int[2]; // X,Y
|
||||||
|
|
||||||
if (entityZ >= 50) {
|
if (entityZ >= 50) {
|
||||||
if(GetWindowMode() == WindowMode.FIXED) {
|
if (GetWindowMode() == WindowMode.FIXED) {
|
||||||
screenPos[0] = HALF_FIXED_WIDTH + ((entityX << 9) / entityZ);
|
screenPos[0] = HALF_FIXED_WIDTH + ((entityX << 9) / entityZ);
|
||||||
screenPos[1] = HALF_FIXED_HEIGHT + ((elevation << 9) / entityZ);
|
screenPos[1] = HALF_FIXED_HEIGHT + ((elevation << 9) / entityZ);
|
||||||
} else {
|
} else {
|
||||||
Dimension canvas = GetWindowDimensions();
|
Dimension canvas = GetWindowDimensions();
|
||||||
double newViewDistH = (canvas.width / 2) / Math.tan(Math.toRadians(GlRenderer.hFOV) / 2);
|
double newViewDistH;
|
||||||
double newViewDistV = (canvas.height / 2) / Math.tan(Math.toRadians(GlRenderer.vFOV) / 2);
|
double newViewDistV;
|
||||||
screenPos[0] = canvas.width / 2 + (int)((entityX * newViewDistH) / entityZ);
|
|
||||||
screenPos[1] = canvas.height / 2 + (int)((elevation * newViewDistV) / entityZ);
|
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);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
screenPos[0] = -1;
|
screenPos[0] = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue