void ConvertToRange(Vector2& Point)
{
Point.x /= 1920.0f;
Point.x *= 2.0f;
Point.x -= 1.0f;
Point.y /= 1080.0f;
Point.y *= 2.0f;
Point.y -= 1.0f;
}
bool WorldToScreen(const Vector3& VecOrigin, Vector2& VecScreen, float* Matrix)
{
VecScreen.x = VecOrigin.x * Matrix[0] + VecOrigin.y * Matrix[1] + VecOrigin.z * Matrix[2] + Matrix[3];
VecScreen.y = VecOrigin.x * Matrix[4] + VecOrigin.y * Matrix[5] + VecOrigin.z * Matrix[6] + Matrix[7];
float W = VecOrigin.x * Matrix[12] + VecOrigin.y * Matrix[13] + VecOrigin.z * Matrix[14] + Matrix[15];
if (W < 0.01f)
return false;
Vector2 NDC;
NDC.x = VecScreen.x / W;
NDC.y = VecScreen.y / W;
VecScreen.x = (1920 / 2 * NDC.x) + (NDC.x + 1920 / 2);
VecScreen.y = (1080 / 2 * NDC.y) + (NDC.y + 1080 / 2);
ConvertToRange(VecScreen);
return true;
}