-
Notifications
You must be signed in to change notification settings - Fork 5
/
ProjectWorldToScreen.h
47 lines (33 loc) · 1.56 KB
/
ProjectWorldToScreen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Vector3 ProjectWorldToScreen(Vector3 WorldLocation)
{
Vector3 Screenlocation = Vector3(0, 0, 0);
Vector3 Camera;
auto chain69 = read<uintptr_t>(offset::local_player + 0xA8);
uint64_t chain699 = read<uintptr_t>(chain69 + 8);
Camera.x = read<float>(chain699 + 0x7F8);
Camera.y = read<float>(offset::root_component + 0x12C);
float test = asin(Camera.x);
float degrees = test * (180.0 / M_PI);
Camera.x = degrees;
if (Camera.y < 0)
Camera.y = 360 + Camera.y;
D3DMATRIX tempMatrix = Matrix2(Camera);
Vector3 vAxisX, vAxisY, vAxisZ;
vAxisX = Vector3(tempMatrix.m[0][0], tempMatrix.m[0][1], tempMatrix.m[0][2]);
vAxisY = Vector3(tempMatrix.m[1][0], tempMatrix.m[1][1], tempMatrix.m[1][2]);
vAxisZ = Vector3(tempMatrix.m[2][0], tempMatrix.m[2][1], tempMatrix.m[2][2]);
uint64_t chain = read<uint64_t>(offset::local_player + 0x70);
uint64_t chain1 = read<uint64_t>(chain + 0x98);
uint64_t chain2 = read<uint64_t>(chain1 + 0x140);
Vector3 vDelta = WorldLocation - read<Vector3>(chain2 + 0x10);
Vector3 vTransformed = Vector3(vDelta.Dot(vAxisY), vDelta.Dot(vAxisZ), vDelta.Dot(vAxisX));
if (vTransformed.z < 1.f)
vTransformed.z = 1.f;
zoom = read<float>(chain699 + 0x590);
float FovAngle = 80.0f / (zoom / 1.19f);
float ScreenCenterX = Width / 2.0f;
float ScreenCenterY = Height / 2.0f;
Screenlocation.x = ScreenCenterX + vTransformed.x * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z;
Screenlocation.y = ScreenCenterY - vTransformed.y * (ScreenCenterX / tanf(FovAngle * (float)M_PI / 360.f)) / vTransformed.z;
return Screenlocation;
}