Вопрос Проблемы с esp

Начинающий
Статус
Оффлайн
Регистрация
14 Авг 2020
Сообщения
21
Реакции[?]
1
Поинты[?]
0
Взял за основу
Пожалуйста, авторизуйтесь для просмотра ссылки.

Начал заниматься esp, но что-то пошло не так

код, который использовался:

C++:
// game/helpers/helpers.cpp
std::pair<math::vec2_t, bool> world_to_screen(const math::vec3_t& world) {
        static const auto& matrix = *reinterpret_cast<math::matrix4x4_t*>(*SIG("client.dll", "0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9").self_offset(+0x3).cast<std::uintptr_t*>() + 0xb0);

        auto ret = math::vec2_t();

        ret.x = matrix[0u].x * world.x + matrix[0u].y * world.y + matrix[0u].z * world.z + matrix[0u].w;
        ret.y = matrix[1u].x * world.x + matrix[1u].y * world.y + matrix[1u].z * world.z + matrix[1u].w;

        const auto length = matrix[3u].x * world.x + matrix[3u].y * world.y + matrix[3u].z * world.z + matrix[3u].w;
        if (length <= 0.001f)
            return std::make_pair(ret, true);

        ret /= length;

        const auto screen_size = render::m_screen_size;

        ret.x = screen_size.x / 2.f + ret.x * screen_size.x / 2.f;
        ret.y = screen_size.y / 2.f - ret.y * screen_size.y / 2.f;

        return std::make_pair(ret, true);
    }

    RECT get_bbox(game::entity_t* entity) {

        RECT  rect{};

            auto collideable = entity->get_collideable();

            if (!collideable)
                return rect;

            math::vec3_t min = collideable->get_obb_mins();
            math::vec3_t max = collideable->get_obb_maxs();

            const math::matrix3x4_t& trans = entity->coordinate_frame();

            math::vec3_t points[] = {
                math::vec3_t(min.x, min.y, min.z),
                math::vec3_t(min.x, max.y, min.z),
                math::vec3_t(max.x, max.y, min.z),
                math::vec3_t(max.x, min.y, min.z),
                math::vec3_t(max.x, max.y, max.z),
                math::vec3_t(min.x, max.y, max.z),
                math::vec3_t(min.x, min.y, max.z),
                math::vec3_t(max.x, min.y, max.z)
            };

            math::vec3_t pointsTransformed[8];
            math::vec2_t screen_points[8];

            bool init = false;

            for (int i = 1; i < 8; i++) {

                math::vector_transform(points[i], trans, pointsTransformed[i]);

                auto screen = world_to_screen(pointsTransformed[i]);
                screen_points[i] = screen.first;
                if (!screen.second)
                    return rect;

                if (!init) {
                    rect.left = screen_points[0].x;
                    rect.top = screen_points[0].y;
                    rect.right = screen_points[0].x;
                    rect.bottom = screen_points[0].y;
                    init = true;
                }
                else {
                    if (rect.left > screen_points[i].x)
                        rect.left = screen_points[i].x;
                    if (rect.top < screen_points[i].y)
                        rect.top = screen_points[i].y;
                    if (rect.right < screen_points[i].x)
                        rect.right = screen_points[i].x;
                    if (rect.bottom > screen_points[i].y)
                        rect.bottom = screen_points[i].y;
                }
            }

        return rect;

    }
C++:
// player_
ctx.box = game::get_bbox(entity);

// player_::boxes
render::rect(math::vec2_t(ctx.box.left, ctx.box.top), math::vec2_t(ctx.box.right, ctx.box.bottom), math::col_t(255, 255, 255), ctx.settings->box_round, ctx.settings->box_thickness);

//render::rect

void rect(const math::vec2_t& pos, const math::vec2_t& pos2, const math::col_t& color, float round, float thickness) {
    m_draw_list->add_rect(*reinterpret_cast<const im_vec2_t*>(&pos), *reinterpret_cast<const im_vec2_t*>(&pos2), color.hex(), round, thickness);
}
Думаю, что ошибка в get_bbox либо world_to_screen
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
21 Дек 2018
Сообщения
188
Реакции[?]
14
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
// player_::boxes render::rect(math::vec2_t(ctx.box.left, ctx.box.top), math::vec2_t(ctx.box.right, ctx.box.bottom), math::col_t(255, 255, 255), ctx.settings->box_round, ctx.settings->box_thickness)
C++:
player_::boxes render::rect(math::vec2_t(ctx.box.left, ctx.box.top), math::vec2_t(ctx.box.left + ctx.box.right, ctx.box.top + ctx.box.bottom), math::col_t(255, 255, 255), ctx.settings->box_round, ctx.settings->box_thickness)
 
Начинающий
Статус
Оффлайн
Регистрация
14 Авг 2020
Сообщения
21
Реакции[?]
1
Поинты[?]
0
C++:
player_::boxes render::rect(math::vec2_t(ctx.box.left, ctx.box.top), math::vec2_t(ctx.box.left + ctx.box.right, ctx.box.top + ctx.box.bottom), math::col_t(255, 255, 255), ctx.settings->box_round, ctx.settings->box_thickness)
мимо1629719891092.png
наверно запутал вас тем, что вместо size на самом деле pos2
 
Забаненный
Статус
Оффлайн
Регистрация
21 Дек 2018
Сообщения
188
Реакции[?]
14
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
math::vec2_t screen_points[8];
math::vec3_t screen_points[8];

А вообще возьми дефолтный getbbox от симпла, а не его сломанную версию:
C++:
RECT GetBBox(C_BaseEntity* ent) {
    RECT rect{};
    auto collideable = ent->GetCollideable();

    if (!collideable)
        return rect;

    auto min = collideable->OBBMins();
    auto max = collideable->OBBMaxs();

    const matrix3x4_t& trans = ent->m_rgflCoordinateFrame();

    Vector points[] = {
        Vector(min.x, min.y, min.z),
        Vector(min.x, max.y, min.z),
        Vector(max.x, max.y, min.z),
        Vector(max.x, min.y, min.z),
        Vector(max.x, max.y, max.z),
        Vector(min.x, max.y, max.z),
        Vector(min.x, min.y, max.z),
        Vector(max.x, min.y, max.z)
    };

    Vector pointsTransformed[8];
    for (int i = 0; i < 8; i++) {
        Math::VectorTransform(points[i], trans, pointsTransformed[i]);
    }

    Vector screen_points[8] = {};

    for (int i = 0; i < 8; i++) {
        if (!Math::WorldToScreen(pointsTransformed[i], screen_points[i]))
            return rect;
    }

    auto left = screen_points[0].x;
    auto top = screen_points[0].y;
    auto right = screen_points[0].x;
    auto bottom = screen_points[0].y;

    for (int i = 1; i < 8; i++) {
        if (left > screen_points[i].x)
            left = screen_points[i].x;
        if (top < screen_points[i].y)
            top = screen_points[i].y;
        if (right < screen_points[i].x)
            right = screen_points[i].x;
        if (bottom > screen_points[i].y)
            bottom = screen_points[i].y;
    }
    return RECT{ (long)left, (long)top, (long)right, (long)bottom };
}
C++:
    void VectorTransform( const Vector& in1, const matrix3x4_t& in2, Vector& out ) {
        out[0] = in1.Dot( in2[0] ) + in2[0][3];
        out[1] = in1.Dot( in2[1] ) + in2[1][3];
        out[2] = in1.Dot( in2[2] ) + in2[2][3];
    }

    static bool screen_transform( const Vector& in, Vector& out ) {
        static auto& w2sMatrix = g_EngineClient->WorldToScreenMatrix( );

        out.x = w2sMatrix.m[0][0] * in.x + w2sMatrix.m[0][1] * in.y + w2sMatrix.m[0][2] * in.z + w2sMatrix.m[0][3];
        out.y = w2sMatrix.m[1][0] * in.x + w2sMatrix.m[1][1] * in.y + w2sMatrix.m[1][2] * in.z + w2sMatrix.m[1][3];
        out.z = 0.0f;

        float w = w2sMatrix.m[3][0] * in.x + w2sMatrix.m[3][1] * in.y + w2sMatrix.m[3][2] * in.z + w2sMatrix.m[3][3];

        if( w < 0.001f ) {
            out.x *= 100000;
            out.y *= 100000;
            return false;
        }

        out.x /= w;
        out.y /= w;

        return true;
    }
    bool WorldToScreen( const Vector& in, Vector& out ) {
        if( screen_transform( in, out ) ) {
            int w, h;
            g_EngineClient->GetScreenSize( w, h );

            out.x = ( w / 2.0f ) + ( out.x * w ) / 2.0f;
            out.y = ( h / 2.0f ) - ( out.y * h ) / 2.0f;

            return true;
        }
        return false;
    }
 
Начинающий
Статус
Оффлайн
Регистрация
14 Авг 2020
Сообщения
21
Реакции[?]
1
Поинты[?]
0
C++:
RECT GetBBox(C_BaseEntity* ent) {
    RECT rect{};
    auto collideable = ent->GetCollideable();

    if (!collideable)
        return rect;

    auto min = collideable->OBBMins();
    auto max = collideable->OBBMaxs();

    const matrix3x4_t& trans = ent->m_rgflCoordinateFrame();

    Vector points[] = {
        Vector(min.x, min.y, min.z),
        Vector(min.x, max.y, min.z),
        Vector(max.x, max.y, min.z),
        Vector(max.x, min.y, min.z),
        Vector(max.x, max.y, max.z),
        Vector(min.x, max.y, max.z),
        Vector(min.x, min.y, max.z),
        Vector(max.x, min.y, max.z)
    };

    Vector pointsTransformed[8];
    for (int i = 0; i < 8; i++) {
        Math::VectorTransform(points[i], trans, pointsTransformed[i]);
    }

    Vector screen_points[8] = {};

    for (int i = 0; i < 8; i++) {
        if (!Math::WorldToScreen(pointsTransformed[i], screen_points[i]))
            return rect;
    }

    auto left = screen_points[0].x;
    auto top = screen_points[0].y;
    auto right = screen_points[0].x;
    auto bottom = screen_points[0].y;

    for (int i = 1; i < 8; i++) {
        if (left > screen_points[i].x)
            left = screen_points[i].x;
        if (top < screen_points[i].y)
            top = screen_points[i].y;
        if (right < screen_points[i].x)
            right = screen_points[i].x;
        if (bottom > screen_points[i].y)
            bottom = screen_points[i].y;
    }
    return RECT{ (long)left, (long)top, (long)right, (long)bottom };
}
C++:
    void VectorTransform( const Vector& in1, const matrix3x4_t& in2, Vector& out ) {
        out[0] = in1.Dot( in2[0] ) + in2[0][3];
        out[1] = in1.Dot( in2[1] ) + in2[1][3];
        out[2] = in1.Dot( in2[2] ) + in2[2][3];
    }

    static bool screen_transform( const Vector& in, Vector& out ) {
        static auto& w2sMatrix = g_EngineClient->WorldToScreenMatrix( );

        out.x = w2sMatrix.m[0][0] * in.x + w2sMatrix.m[0][1] * in.y + w2sMatrix.m[0][2] * in.z + w2sMatrix.m[0][3];
        out.y = w2sMatrix.m[1][0] * in.x + w2sMatrix.m[1][1] * in.y + w2sMatrix.m[1][2] * in.z + w2sMatrix.m[1][3];
        out.z = 0.0f;

        float w = w2sMatrix.m[3][0] * in.x + w2sMatrix.m[3][1] * in.y + w2sMatrix.m[3][2] * in.z + w2sMatrix.m[3][3];

        if( w < 0.001f ) {
            out.x *= 100000;
            out.y *= 100000;
            return false;
        }

        out.x /= w;
        out.y /= w;

        return true;
    }
    bool WorldToScreen( const Vector& in, Vector& out ) {
        if( screen_transform( in, out ) ) {
            int w, h;
            g_EngineClient->GetScreenSize( w, h );

            out.x = ( w / 2.0f ) + ( out.x * w ) / 2.0f;
            out.y = ( h / 2.0f ) - ( out.y * h ) / 2.0f;

            return true;
        }
        return false;
    }
возвращает (0,0) на world_to_screen


math::vec3_t screen_points[8];
у экрана 2 координаты, зачем третья? ( если что все равно vec3 поставил)

что в итоге получилось в сурсе
Код:
    static bool screen_transform(const math::vec3_t in, math::vec3_t out) {

        static const auto& w2sMatrix = interfaces::m_engine->get_w2s_matrix();

        out.x = w2sMatrix.m_value[0][0] * in.x + w2sMatrix.m_value[0][1] * in.y + w2sMatrix.m_value[0][2] * in.z + w2sMatrix.m_value[0][3];
        out.y = w2sMatrix.m_value[1][0] * in.x + w2sMatrix.m_value[1][1] * in.y + w2sMatrix.m_value[1][2] * in.z + w2sMatrix.m_value[1][3];
        out.z = 0;

        float w = w2sMatrix.m_value[3][0] * in.x + w2sMatrix.m_value[3][1] * in.y + w2sMatrix.m_value[3][2] * in.z + w2sMatrix.m_value[3][3];

        if (w < 0.001f) {
            out.x *= 100000;
            out.y *= 100000;
            return false;
        }

        out.x /= w;
        out.y /= w;

        return true;


    }
    bool world_to_screen(const math::vec3_t& in, math::vec3_t& out) {
        if (screen_transform(in, out)) {
            int w, h;
            interfaces::m_engine->get_screen_size(w, h);

            out.x = (w / 2.0f) + (out.x * w) / 2.0f;
            out.y = (h / 2.0f) - (out.y * h) / 2.0f;

            return true;
        }
        return false;
    }

    RECT get_bbox(game::entity_t* entity) {
        RECT rect{};
        auto collideable = entity->get_collideable();

        if (!collideable)
            return rect;

        math::vec3_t min = collideable->get_obb_mins();
        math::vec3_t max = collideable->get_obb_maxs();

        const math::matrix3x4_t& trans = entity->coordinate_frame();

        math::vec3_t points[] = {
             math::vec3_t(min.x, min.y, min.z),
             math::vec3_t(min.x, max.y, min.z),
             math::vec3_t(max.x, max.y, min.z),
             math::vec3_t(max.x, min.y, min.z),
             math::vec3_t(max.x, max.y, max.z),
             math::vec3_t(min.x, max.y, max.z),
             math::vec3_t(min.x, min.y, max.z),
             math::vec3_t(max.x, min.y, max.z)
        };

        math::vec3_t pointsTransformed[8];
        for (int i = 0; i < 8; i++) {
            math::vector_transform(points[i], trans, pointsTransformed[i]);
        }

        math::vec3_t screen_points[8] = {};
        for (int i = 0; i < 8; i++) {
            if (!world_to_screen(pointsTransformed[i], screen_points[i]))
                return rect;
        }

        auto left = screen_points[0].x;
        auto top = screen_points[0].y;
        auto right = screen_points[0].x;
        auto bottom = screen_points[0].y;

        for (int i = 1; i < 8; i++) {
            if (left > screen_points[i].x)
                left = screen_points[i].x;
            if (top < screen_points[i].y)
                top = screen_points[i].y;
            if (right < screen_points[i].x)
                right = screen_points[i].x;
            if (bottom > screen_points[i].y)
                bottom = screen_points[i].y;
        }
        return RECT{(long)left, (long)top, (long)right, (long)bottom};
    }
 
Забаненный
Статус
Оффлайн
Регистрация
21 Дек 2018
Сообщения
188
Реакции[?]
14
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
возвращает (0,0) на world_to_screen



у экрана 2 координаты, зачем третья? ( если что все равно vec3 поставил)

что в итоге получилось в сурсе
Код:
    static bool screen_transform(const math::vec3_t in, math::vec3_t out) {

        static const auto& w2sMatrix = interfaces::m_engine->get_w2s_matrix();

        out.x = w2sMatrix.m_value[0][0] * in.x + w2sMatrix.m_value[0][1] * in.y + w2sMatrix.m_value[0][2] * in.z + w2sMatrix.m_value[0][3];
        out.y = w2sMatrix.m_value[1][0] * in.x + w2sMatrix.m_value[1][1] * in.y + w2sMatrix.m_value[1][2] * in.z + w2sMatrix.m_value[1][3];
        out.z = 0;

        float w = w2sMatrix.m_value[3][0] * in.x + w2sMatrix.m_value[3][1] * in.y + w2sMatrix.m_value[3][2] * in.z + w2sMatrix.m_value[3][3];

        if (w < 0.001f) {
            out.x *= 100000;
            out.y *= 100000;
            return false;
        }

        out.x /= w;
        out.y /= w;

        return true;


    }
    bool world_to_screen(const math::vec3_t& in, math::vec3_t& out) {
        if (screen_transform(in, out)) {
            int w, h;
            interfaces::m_engine->get_screen_size(w, h);

            out.x = (w / 2.0f) + (out.x * w) / 2.0f;
            out.y = (h / 2.0f) - (out.y * h) / 2.0f;

            return true;
        }
        return false;
    }

    RECT get_bbox(game::entity_t* entity) {
        RECT rect{};
        auto collideable = entity->get_collideable();

        if (!collideable)
            return rect;

        math::vec3_t min = collideable->get_obb_mins();
        math::vec3_t max = collideable->get_obb_maxs();

        const math::matrix3x4_t& trans = entity->coordinate_frame();

        math::vec3_t points[] = {
             math::vec3_t(min.x, min.y, min.z),
             math::vec3_t(min.x, max.y, min.z),
             math::vec3_t(max.x, max.y, min.z),
             math::vec3_t(max.x, min.y, min.z),
             math::vec3_t(max.x, max.y, max.z),
             math::vec3_t(min.x, max.y, max.z),
             math::vec3_t(min.x, min.y, max.z),
             math::vec3_t(max.x, min.y, max.z)
        };

        math::vec3_t pointsTransformed[8];
        for (int i = 0; i < 8; i++) {
            math::vector_transform(points[i], trans, pointsTransformed[i]);
        }

        math::vec3_t screen_points[8] = {};
        for (int i = 0; i < 8; i++) {
            if (!world_to_screen(pointsTransformed[i], screen_points[i]))
                return rect;
        }

        auto left = screen_points[0].x;
        auto top = screen_points[0].y;
        auto right = screen_points[0].x;
        auto bottom = screen_points[0].y;

        for (int i = 1; i < 8; i++) {
            if (left > screen_points[i].x)
                left = screen_points[i].x;
            if (top < screen_points[i].y)
                top = screen_points[i].y;
            if (right < screen_points[i].x)
                right = screen_points[i].x;
            if (bottom > screen_points[i].y)
                bottom = screen_points[i].y;
        }
        return RECT{(long)left, (long)top, (long)right, (long)bottom};
    }
Тестируй, что ещё могу сказать
у экрана 2 координаты, зачем третья? ( если что все равно vec3 поставил)
А персонаж тоже 2д?
 
Начинающий
Статус
Оффлайн
Регистрация
14 Авг 2020
Сообщения
21
Реакции[?]
1
Поинты[?]
0
1629722536847.png
кажись починил
совместил код с ксго симпла и тот, который был изначально

C++:
RECT get_bbox(game::entity_t* entity) {

        RECT  rect{};

            auto collideable = entity->get_collideable();

            if (!collideable)
                return rect;

            math::vec3_t min = collideable->get_obb_mins();
            math::vec3_t max = collideable->get_obb_maxs();

            const math::matrix3x4_t& trans = entity->coordinate_frame();

            math::vec3_t points[] = {
                math::vec3_t(min.x, min.y, min.z),
                math::vec3_t(min.x, max.y, min.z),
                math::vec3_t(max.x, max.y, min.z),
                math::vec3_t(max.x, min.y, min.z),
                math::vec3_t(max.x, max.y, max.z),
                math::vec3_t(min.x, max.y, max.z),
                math::vec3_t(min.x, min.y, max.z),
                math::vec3_t(max.x, min.y, max.z)
            };

            math::vec3_t pointsTransformed[8];
            math::vec2_t screen_points[8];

            for (int i = 0; i < 8; i++) {
                math::vector_transform(points[i], trans, pointsTransformed[i]);
            }

            for (int i = 0; i < 8; i++) {
                auto screen = world_to_screen(pointsTransformed[i]);
                screen_points[i] = screen.first;
                if (!screen.second)
                    return rect;
            }

            auto left = screen_points[0].x;
            auto top = screen_points[0].y;
            auto right = screen_points[0].x;
            auto bottom = screen_points[0].y;

            for (int i = 1; i < 8; i++) {
                if (left > screen_points[i].x)
                    left = screen_points[i].x;
                if (top < screen_points[i].y)
                    top = screen_points[i].y;
                if (right < screen_points[i].x)
                    right = screen_points[i].x;
                if (bottom > screen_points[i].y)
                    bottom = screen_points[i].y;
            }
            return RECT{(long)left, (long)top, (long)right, (long)bottom};


    }
Siesta пасиба <3
 

Вложения

Последнее редактирование:
Сверху Снизу