OGSR / OGSR-Engine

OGSR Project - Evolution of X-Ray Engine for S.T.A.L.K.E.R.: Shadow of Chernobyl
https://discord.gg/Q6QDxbNcfR
Other
470 stars 87 forks source link

Автоматический поиск анимаций как в Anomaly #440

Closed Drakoha4 closed 1 year ago

Drakoha4 commented 1 year ago

Можно по желанию добавить поиск анимаций, замена делается только в SkeletonAnimated.cpp нужно заменить вот это всё

` // Load animation xr_vector omfs; if (pUserData && pUserData->section_exist("omf_override")) { LPCSTR nm, val; for (u32 i = 0; pUserData->r_line("omf_override", i, &nm, &val); ++i) { xr_string s = nm; s += ".omf"; omfs.push_back(s); } } else if (data->find_chunk(OGF_S_MOTION_REFS)) { string_path items_nm; data->r_stringZ(items_nm, sizeof(items_nm)); u32 set_cnt = _GetItemCount(items_nm); for (u32 k = 0; k < set_cnt; ++k) { string_path nm; _GetItem(items_nm, k, nm); xr_strcat(nm, ".omf"); omfs.push_back(nm); } } else if (data->find_chunk(OGF_S_MOTION_REFS2)) { u32 set_cnt = data->r_u32(); for (u32 k = 0; k < set_cnt; ++k) { string_path nm; data->r_stringZ(nm, sizeof(nm)); xr_strcat(nm, ".omf"); omfs.push_back(nm); } }

if (omfs.size())
{
    // R_ASSERT( omfs.size() < MAX_ANIM_SLOT );
    m_Motions.reserve(omfs.size());
    for (const auto& s : omfs)
    {
        auto nm = s.c_str();
        string_path fn;
        if (!FS.exist(fn, "$level$", nm))
        {
            if (!FS.exist(fn, "$game_meshes$", nm))
            {

ifdef _EDITOR

                Msg("!Can't find motion file '%s'.", nm);
                return;

else

                Debug.fatal(DEBUG_INFO, "Can't find motion file '%s'.", nm);

endif

            }
        }
        // Check compatibility
        m_Motions.emplace_back();
        bool create_res = true;
        if (!g_pMotionsContainer->has(nm))
        { // optimize fs operations
            IReader* MS = FS.r_open(fn);
            create_res = m_Motions.back().motions.create(nm, MS, bones);
            FS.r_close(MS);
        }
        if (create_res)
            m_Motions.back().motions.create(nm, NULL, bones);
        else
        {
            m_Motions.pop_back();
            Msg("! error in model [%s]. Unable to load motion file '%s'.", N, nm);
        }
    }
}
else
{
    string_path nm;
    strconcat(sizeof(nm), nm, N, ".ogf");
    m_Motions.emplace_back().motions.create(nm, data, bones);
}`

на вот это

` const auto loadOMF = [&](LPCSTR _path) { string_path fn; if (!FS.exist(fn, "$level$", _path)) { if (!FS.exist(fn, "$game_meshes$", _path)) Debug.fatal(DEBUG_INFO, "Can't find motion file '%s'.", _path); }

    // Check compatibility
    m_Motions.push_back(SMotionsSlot());
    bool create_res = true;
    if (!g_pMotionsContainer->has(_path)) // optimize fs operations
    {
        IReader* MS = FS.r_open(fn);
        create_res = m_Motions.back().motions.create(_path, MS, bones);
        FS.r_close(MS);
    }
    if (create_res)
        m_Motions.back().motions.create(_path, NULL, bones);
    else
    {
        m_Motions.pop_back();
        Msg("! error in model [%s]. Unable to load motion file '%s'.", N, _path);
    }
};

// Load animation
if (data->find_chunk(OGF_S_MOTION_REFS))
{
    string_path items_nm;
    data->r_stringZ(items_nm, sizeof(items_nm));
    u32 set_cnt = _GetItemCount(items_nm);
    R_ASSERT(set_cnt < MAX_ANIM_SLOT);
    m_Motions.reserve(set_cnt);
    string_path nm;
    for (u32 k = 0; k < set_cnt; ++k)
    {
        _GetItem(items_nm, k, nm);
        xr_strcat(nm, ".omf");
        loadOMF(nm);
    }
}
else if (data->find_chunk(OGF_S_MOTION_REFS2))
{
    u32 set_cnt = data->r_u32();
    m_Motions.reserve(set_cnt);
    string_path nm;
    for (u32 k = 0; k < set_cnt; ++k)
    {
        data->r_stringZ(nm, sizeof(nm));

        if (strstr(nm, "\\*.omf"))
        {
            FS_FileSet fset;
            FS.file_list(fset, "$game_meshes$", FS_ListFiles, nm);
            FS.file_list(fset, "$level$", FS_ListFiles, nm);

            m_Motions.reserve(fset.size() - 1);

            for (FS_FileSet::iterator it = fset.begin(); it != fset.end(); it++)
                loadOMF((*it).name.c_str());

            continue;
        }

        xr_strcat(nm, ".omf");
        loadOMF(nm);
    }
}
else
{
    string_path nm;
    strconcat(sizeof(nm), nm, N, ".ogf");
    m_Motions.push_back(SMotionsSlot());
    m_Motions.back().motions.create(nm, data, bones);
}`
I-AmDead commented 1 year ago

Есть такое уже в привате