• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Вопрос Bug skeleton

  • Автор темы Автор темы chubak8
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
16 Сен 2024
Сообщения
44
Реакции
5
когда типы на базе и идут куда то, кость правой или какой то ноги коннектится к полу и тянется огромная полоса но если игрок близко то все пропадает

C++:
Expand Collapse Copy
enum class BoneId
{
    WAIS = 0,
    NECK = 5,
    HEAD = 6,
    SHOULDERLEFT = 8,
    FORELEFT = 9,
    HANDLEFT = 11,
    SHOULDERIGHT = 13,
    FORERIGHT = 14,
    HANDRIGHT = 16,
    KNEELEFT = 23,
    FEETLEFT = 24,
    KNEERIGHT = 26,
    FEETRIGHT = 27
};


std::vector<vector3> read_bones(uintptr_t scene_node)
{
    std::vector<vector3> bones;
    if (!scene_node) return bones;
    uintptr_t bone_matrix = *reinterpret_cast<uintptr_t*>(scene_node + offsets::model_state + 0x80);
    if (!bone_matrix) return bones;

    uint8_t bone_data[28 * 32];
    if (!ReadProcessMemory(GetCurrentProcess(), (LPCVOID)bone_matrix, bone_data, sizeof(bone_data), nullptr)) return bones;

    int bone_indices[] = { 0, 5, 6, 8, 9, 11, 13, 14, 16, 23, 24, 26, 27 };
    for (int id : bone_indices)
    {
        float x = *reinterpret_cast<float*>(bone_data + id * 32 + 0);
        float y = *reinterpret_cast<float*>(bone_data + id * 32 + 4);
        float z = *reinterpret_cast<float*>(bone_data + id * 32 + 8);
        if (std::isfinite(x) && std::isfinite(y) && std::isfinite(z))
            bones.push_back(vector3(x, y, z));
        else
            bones.push_back(vector3(0, 0, 0));
    }
    return bones;
}

std::vector<vector2> bones_to_2d(const std::vector<vector3>& bones, float (*view_matrix)[4][4])
{
    std::vector<vector2> bones_2d;
    for (const auto& bone : bones)
    {
        vector2 screen_pos;
        if (bone.wts(screen_pos, view_matrix) && screen_pos.x > 0 && screen_pos.x < screen_width && screen_pos.y > 0 && screen_pos.y < screen_height)
        {
            bones_2d.push_back(screen_pos);
        }
        else
        {
            bones_2d.push_back(vector2(-99, -99));
        }
    }
    return bones_2d;
}

void draw_skeleton(const entities::entity& entity, ImDrawList* draw_list, const vector3& local_pos, bool is_teammate)
{
    if (is_teammate && !render::teammate_enable_skeleton) return;
    if (!is_teammate && !render::enemy_enable_skeleton) return;

    uintptr_t scene_node = *reinterpret_cast<uintptr_t*>(entity.base + offsets::scene_node);
    if (!scene_node) return;

    auto bones = read_bones(scene_node);
    if (bones.size() < 13) return;

    float (*view_matrix)[4][4] = reinterpret_cast<float(*)[4][4]>(entities::client + offsets::view_matrix);
    if (!view_matrix) return;

    auto bones_2d = bones_to_2d(bones, view_matrix);
    if (bones_2d.size() < 13) return;

    bool is_scoped = *reinterpret_cast<bool*>(entity.base + offsets::m_bIsScoped);
    float thickness = is_scoped ? 2.0f : 1.0f;

    ImU32 color = is_teammate ?
        ImGui::ColorConvertFloat4ToU32(ImVec4(render::teammate_skeleton_color[0], render::teammate_skeleton_color[1], render::teammate_skeleton_color[2], render::teammate_skeleton_color[3])) :
        ImGui::ColorConvertFloat4ToU32(ImVec4(render::enemy_skeleton_color[0], render::enemy_skeleton_color[1], render::enemy_skeleton_color[2], render::enemy_skeleton_color[3]));

    auto draw_bone_line = [&](int from, int to)
        {
            if (bones_2d[from].x > 0 && bones_2d[from].y > 0 && bones_2d[to].x > 0 && bones_2d[to].y > 0)
            {
                draw_list->AddLine(ImVec2(bones_2d[from].x, bones_2d[from].y), ImVec2(bones_2d[to].x, bones_2d[to].y), color, thickness);
            }
        };

    draw_bone_line(1, 2);
    draw_bone_line(1, 3);
    draw_bone_line(1, 6);
    draw_bone_line(3, 4);
    draw_bone_line(6, 7);
    draw_bone_line(4, 5);
    draw_bone_line(7, 8);
    draw_bone_line(1, 0);
    draw_bone_line(0, 9);
    draw_bone_line(0, 11);
    draw_bone_line(9, 10);
    draw_bone_line(11, 12);
    if (bones_2d[2].x > 0 && bones_2d[2].y > 0)
    {
        float height = entity.feet_pos.y - entity.head_pos.y;
        float radius = height / 8.5f;
        draw_list->AddCircle(ImVec2(bones_2d[2].x, bones_2d[2].y), radius, color, 0, thickness);
    }
}
 
Последнее редактирование:
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
когда типы на базе и идут куда то, кость правой или какой то ноги коннектится к полу и тянется огромная полоса но если игрок близко то все пропадает

C++:
Expand Collapse Copy
enum class BoneId
{
    WAIS = 0,
    NECK = 5,
    HEAD = 6,
    SHOULDERLEFT = 8,
    FORELEFT = 9,
    HANDLEFT = 11,
    SHOULDERIGHT = 13,
    FORERIGHT = 14,
    HANDRIGHT = 16,
    KNEELEFT = 23,
    FEETLEFT = 24,
    KNEERIGHT = 26,
    FEETRIGHT = 27
};


std::vector<vector3> read_bones(uintptr_t scene_node)
{
    std::vector<vector3> bones;
    if (!scene_node) return bones;
    uintptr_t bone_matrix = *reinterpret_cast<uintptr_t*>(scene_node + offsets::model_state + 0x80);
    if (!bone_matrix) return bones;

    uint8_t bone_data[28 * 32];
    if (!ReadProcessMemory(GetCurrentProcess(), (LPCVOID)bone_matrix, bone_data, sizeof(bone_data), nullptr)) return bones;

    int bone_indices[] = { 0, 5, 6, 8, 9, 11, 13, 14, 16, 23, 24, 26, 27 };
    for (int id : bone_indices)
    {
        float x = *reinterpret_cast<float*>(bone_data + id * 32 + 0);
        float y = *reinterpret_cast<float*>(bone_data + id * 32 + 4);
        float z = *reinterpret_cast<float*>(bone_data + id * 32 + 8);
        if (std::isfinite(x) && std::isfinite(y) && std::isfinite(z))
            bones.push_back(vector3(x, y, z));
        else
            bones.push_back(vector3(0, 0, 0));
    }
    return bones;
}

std::vector<vector2> bones_to_2d(const std::vector<vector3>& bones, float (*view_matrix)[4][4])
{
    std::vector<vector2> bones_2d;
    for (const auto& bone : bones)
    {
        vector2 screen_pos;
        if (bone.wts(screen_pos, view_matrix) && screen_pos.x > 0 && screen_pos.x < screen_width && screen_pos.y > 0 && screen_pos.y < screen_height)
        {
            bones_2d.push_back(screen_pos);
        }
        else
        {
            bones_2d.push_back(vector2(-99, -99));
        }
    }
    return bones_2d;
}

void draw_skeleton(const entities::entity& entity, ImDrawList* draw_list, const vector3& local_pos, bool is_teammate)
{
    if (is_teammate && !render::teammate_enable_skeleton) return;
    if (!is_teammate && !render::enemy_enable_skeleton) return;

    uintptr_t scene_node = *reinterpret_cast<uintptr_t*>(entity.base + offsets::scene_node);
    if (!scene_node) return;

    auto bones = read_bones(scene_node);
    if (bones.size() < 13) return;

    float (*view_matrix)[4][4] = reinterpret_cast<float(*)[4][4]>(entities::client + offsets::view_matrix);
    if (!view_matrix) return;

    auto bones_2d = bones_to_2d(bones, view_matrix);
    if (bones_2d.size() < 13) return;

    bool is_scoped = *reinterpret_cast<bool*>(entity.base + offsets::m_bIsScoped);
    float thickness = is_scoped ? 2.0f : 1.0f;

    ImU32 color = is_teammate ?
        ImGui::ColorConvertFloat4ToU32(ImVec4(render::teammate_skeleton_color[0], render::teammate_skeleton_color[1], render::teammate_skeleton_color[2], render::teammate_skeleton_color[3])) :
        ImGui::ColorConvertFloat4ToU32(ImVec4(render::enemy_skeleton_color[0], render::enemy_skeleton_color[1], render::enemy_skeleton_color[2], render::enemy_skeleton_color[3]));

    auto draw_bone_line = [&](int from, int to)
        {
            if (bones_2d[from].x > 0 && bones_2d[from].y > 0 && bones_2d[to].x > 0 && bones_2d[to].y > 0)
            {
                draw_list->AddLine(ImVec2(bones_2d[from].x, bones_2d[from].y), ImVec2(bones_2d[to].x, bones_2d[to].y), color, thickness);
            }
        };

    draw_bone_line(1, 2);
    draw_bone_line(1, 3);
    draw_bone_line(1, 6);
    draw_bone_line(3, 4);
    draw_bone_line(6, 7);
    draw_bone_line(4, 5);
    draw_bone_line(7, 8);
    draw_bone_line(1, 0);
    draw_bone_line(0, 9);
    draw_bone_line(0, 11);
    draw_bone_line(9, 10);
    draw_bone_line(11, 12);
    if (bones_2d[2].x > 0 && bones_2d[2].y > 0)
    {
        float height = entity.feet_pos.y - entity.head_pos.y;
        float radius = height / 8.5f;
        draw_list->AddCircle(ImVec2(bones_2d[2].x, bones_2d[2].y), radius, color, 0, thickness);
    }
}
какие координаты у костей когда возникает баг?
 
fix:
Expand Collapse Copy
if (MenuVars::Visuals::skeleton) {
    BodyPart bodyParts[13];
    bool allBonesValid = true;
    
    for (int i = 0; i < 13; i++) {
        int boneIndex = boneMapping[i];
        bodyParts[i].position = M::R<Vec3>(boneMatrix + boneIndex * 32);
        
        // Validate bone position is reasonable
        if (!bodyParts[i].position.x ||
            bodyParts[i].position.x < -50000 || bodyParts[i].position.x > 50000 ||
            bodyParts[i].position.y < -50000 || bodyParts[i].position.y > 50000 ||
            bodyParts[i].position.z < -50000 || bodyParts[i].position.z > 50000) {
            allBonesValid = false;
            break;
        }
        
        bodyParts[i].isValid = bodyParts[i].position.WorldToScreen(bodyParts[i].screenPos, viewMatrix);
    }
    
    // Only draw skeleton if all bones are valid
    if (allBonesValid) {
        // Your existing drawing code here...
    }
}
 
draw bones tuesday
 
Назад
Сверху Снизу