#define ADDR_MENU 0xBA67A4
void CalcScreenCoors(CVector * vecWorld, CVector * vecScreen)
{
D3DXMATRIX m((float*)(0xB6FA2C));
DWORD *dwLenX = (DWORD*)(0xC17044);
DWORD *dwLenY = (DWORD*)(0xC17048);
vecScreen->fX = vecWorld->fZ * m._31 + vecWorld->fY * m._21 + vecWorld->fX * m._11 + m._41;
vecScreen->fY = vecWorld->fZ * m._32 + vecWorld->fY * m._22 + vecWorld->fX * m._12 + m._42;
vecScreen->fZ = vecWorld->fZ * m._33 + vecWorld->fY * m._23 + vecWorld->fX * m._13 + m._43;
float fRecip = 1.0f / vecScreen->fZ;
vecScreen->fX *= fRecip * (*dwLenX);
vecScreen->fY *= fRecip * (*dwLenY);
}
void DrawTextB(int uiLeft, int uiTop, int uiRight, int uiBottom, unsigned long ulColor, const char* szText, float fScaleX, float fScaleY, unsigned long ulFormat, LPD3DXFONT pDXFont)
{
if (pDXFont)
{
uiLeft = unsigned int((float)uiLeft * (1.0f / fScaleX));
uiTop = unsigned int((float)uiTop * (1.0f / fScaleY));
uiRight = unsigned int((float)uiRight * (1.0f / fScaleX));
uiBottom = unsigned int((float)uiBottom * (1.0f / fScaleY));
RECT rect;
SetRect(&rect, uiLeft, uiTop, uiRight, uiBottom);
m_font->DrawTextA(NULL, szText, -1, &rect, ulFormat, ulColor);
}
}
//Sprite *sp = new Sprite(200, 200, D3DCOLOR_ARGB(255, 255, 255, 255));
HRESULT D3DHook::Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,
CONST RGNDATA *pDirtyRegion)
{
D3DCOLOR fontColor = D3DCOLOR_ARGB(255, 255, 0, 0);
CVector vecScreenPosition;
float *position = (*(DWORD *)0xB6F5F0) ? (float *)(*(DWORD *)(*(DWORD *)0xB6F5F0 + 0x14) + 0x30) : NULL;
if (position != NULL)
{
CalcScreenCoors(new CVector(position[0], position[1], position[2] + 1.3f), &vecScreenPosition);
}
int iScreenPosX = static_cast <int> (vecScreenPosition.fX);
int iScreenPosY = static_cast <int> (vecScreenPosition.fY);
if (*(PBYTE)ADDR_MENU == 0) //В меню рендерить не будет, можно убрать если у вас по другому.
{
DrawTextB(iScreenPosX, iScreenPosY, iScreenPosX, iScreenPosY, D3DCOLOR_ARGB(255, 255, 255, 255), "LocalPed", 1.0f, 1.0f, DT_NOCLIP | DT_CENTER, m_font);
}
return origIDirect3DDevice9->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}