Optimizing hack With World2Screen & IsNotOnScreen

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Słyszę, słyszę letni powiew.
Kurucu
Katılım
20 Haz 2015
Mesajlar
7,666
Çözümler
136
Tepki puanı
20,724
Ödüller
25
10 HİZMET YILI
Credit:
Bağlantıları görmek için lütfen Giriş Yap
(from u.c)
This will save your hack from executing nonsense or useless esp or lines & etc etc.


First: World2Screen (I added Z position for IsNotOnScreenFunction)
C++:
static bool WorldToScreen(Vector3 pos, D3DXVECTOR3 &screen, D3DXMATRIX matrix, int windowWidth, int windowHeight)
    {
        D3DXVECTOR4 clipCoords;
        clipCoords.x = pos.x*matrix[0] + pos.y*matrix[4] + pos.z*matrix[8] + matrix[12];
        clipCoords.y = pos.x*matrix[1] + pos.y*matrix[5] + pos.z*matrix[9] + matrix[13];
        clipCoords.z = pos.x*matrix[2] + pos.y*matrix[6] + pos.z*matrix[10] + matrix[14];
        clipCoords.w = pos.x*matrix[3] + pos.y*matrix[7] + pos.z*matrix[11] + matrix[15];

        if (clipCoords.w < 0.1f)
            return false;

        D3DXVECTOR3 NDC;
        NDC.x = clipCoords.x / clipCoords.w;
        NDC.y = clipCoords.y / clipCoords.w;
        NDC.z = clipCoords.z / clipCoords.w;

        screen.x = (windowWidth / 2 * NDC.x) + (NDC.x + windowWidth / 2);
        screen.y = -(windowHeight / 2 * NDC.y) + (NDC.y + windowHeight / 2);
        screen.z = NDC.z;
        return true;
    }
    static bool WorldToScreen(D3DXVECTOR3 pos, D3DXVECTOR3 &screen, D3DXMATRIX matrix, int windowWidth, int windowHeight)
    {
        D3DXVECTOR4 clipCoords;
        clipCoords.x = pos.x*matrix[0] + pos.y*matrix[4] + pos.z*matrix[8] + matrix[12];
        clipCoords.y = pos.x*matrix[1] + pos.y*matrix[5] + pos.z*matrix[9] + matrix[13];
        clipCoords.z = pos.x*matrix[2] + pos.y*matrix[6] + pos.z*matrix[10] + matrix[14];
        clipCoords.w = pos.x*matrix[3] + pos.y*matrix[7] + pos.z*matrix[11] + matrix[15];

        if (clipCoords.w < 0.1f)
            return false;

        D3DXVECTOR3 NDC;
        NDC.x = clipCoords.x / clipCoords.w;
        NDC.y = clipCoords.y / clipCoords.w;
        NDC.z = clipCoords.z / clipCoords.w;
       
        screen.x = (windowWidth / 2 * NDC.x) + (NDC.x + windowWidth / 2);
        screen.y = -(windowHeight / 2 * NDC.y) + (NDC.y + windowHeight / 2);
        screen.z = NDC.z; //ADDED THIS TO RETURN IF IS IN THE BACK OR FRONT
        return true;
    }

2nd. IsNotOnScreen Function (This will help you if the object or the entity or the bone is not on screen so if not on screen it will return true)
C++:
bool isNotOnScreen(D3DXVECTOR3 vScreen, D3DVIEWPORT9 viewport) {
    return (EScreen.x > (float)viewport.Width || EScreen.x < 0 || EScreen.y > (float)viewport.Width || EScreen.y < 0 || !(EScreen.z > 0.9f));
}

So example if the object is not on screen you can skip drawing it or rendering it to save execution and performance issue

Usage:
C++:
D3DXVECTOR3 vScreen = { NULL,NULL,NULL };
            D3DXVECTOR3 EntityPosition = GetDecryptedPos(curEntity);
            ClientApp::WorldToScreen(EntityPosition, vScreen, worldMatrix, width, height);
 
 if (isPlayer || isBot && !isNotOnScreen(EScreen, viewport)) {
 
drawESP();
 
}
 
Seçkin Üye
Katılım
1 May 2018
Mesajlar
444
Tepki puanı
121
Ödüller
7
8 HİZMET YILI
Reis thanks sen benim aradığım herşeyi atiyon
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...