CVector2D get_screen_coords(CVector vecWorld) {
float x, y, z;
double fRecip;
const D3DXMATRIX m{ reinterpret_cast<float*>(0xB6FA2C) };
unsigned long dwLenX = *reinterpret_cast<unsigned long*>(0xC17044);
unsigned long dwLenY = *reinterpret_cast<unsigned long*>(0xC17048);
x = (vecWorld.fZ * m._31) + (vecWorld.fY * m._21) + (vecWorld.fX * m._11) + m._41;
y = (vecWorld.fZ * m._32) + (vecWorld.fY * m._22) + (vecWorld.fX * m._12) + m._42;
z = (vecWorld.fZ * m._33) + (vecWorld.fY * m._23) + (vecWorld.fX * m._13) + m._43;
fRecip = 1.0 / z;
x *= static_cast<float>(fRecip * dwLenX);
y *= static_cast<float>(fRecip * dwLenY);
return { x, y };
}
bool is_point_on_screen(CVector vecWorld) {
const D3DXMATRIX m{ reinterpret_cast<float*>(0xB6FA2C) };
const unsigned long dwLenX = *reinterpret_cast<unsigned long*>(0xC17044);
const unsigned long dwLenY = *reinterpret_cast<unsigned long*>(0xC17048);
float z;
z = (vecWorld.fZ * m._33) + (vecWorld.fY * m._23) + (vecWorld.fX * m._13) + m._43;
return z >= 1.0f;
}