typedef bool (__cdecl *WorldCoords2ScreenCoords_t)(myVector*, myVector*, float * , float * , char, char);
WorldCoords2ScreenCoords_t WorldCoords2ScreenCoords = (WorldCoords2ScreenCoords_t)0x70CE30;
bool Players::IsOnScreen()
{
XYZ position = GetPos();
myVector inPoint = { position.x, position.y, position.z};
if(!(position.x == 0.0f) && !(position.y == 0.0f) && !(position.z == 0.0f))
{
tuple<float, float, bool> result = Convert3DposTo2Dscreen(inPoint);
if(get<2>(result) == true)
{
screenPos[0] = get<0>(result);
screenPos[1] = get<1>(result);
return true;
}
}
return false;
}
tuple<float, float, bool> Convert3DposTo2Dscreen(myVector inPoint)
{
bool isOnScreen;
float x, y;
myVector outPoint;
WorldCoords2ScreenCoords(&inPoint, &outPoint, &x, &y, 0, 0);
outPoint.pos[0] /= x;
outPoint.pos[0] /= outPoint.pos[2];
outPoint.pos[1] /= y;
outPoint.pos[1] /= outPoint.pos[2];
outPoint.pos[0] *= resolutionX; //or use 1650.0 //640.0
outPoint.pos[1] *= resolutionY; //or use 1050.0 //448.0
if(x > 0.0 && y > 0.0)
{
isOnScreen = true;
}
else
{
isOnScreen = false;
}
return make_tuple(outPoint.pos[0], outPoint.pos[1], isOnScreen);
}