assimp icon indicating copy to clipboard operation
assimp copied to clipboard

Bug: Convert from FBX to FBX, animation run too slowly

Open Nor-s opened this issue 3 years ago • 0 comments

Describe the bug

When exporting animation in FBX, animation run too slowly

The related issues, I think, are: - #3545 - #3698 - #4197 - #4206

To Reproduce

  • os: win11, mac os
  • compiler: clang, msvc, mingw gcc
  • Assimp: master branch
  • C++, opengl
  • model: vampire (this is mixamo model)

my code:

        Assimp::Importer import;
        unsigned int assimp_read_flag = aiProcess_Triangulate |
                                        aiProcess_SortByPType |
                                        aiProcess_GenUVCoords |
                                        aiProcess_OptimizeMeshes |
                                        aiProcess_ValidateDataStructure |
                                        aiProcess_GenNormals |
                                        aiProcess_CalcTangentSpace |
                                        aiProcess_LimitBoneWeights |
                                        aiProcess_JoinIdenticalVertices|
                                        aiProcess_FlipWindingOrder;
        import.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);
        const aiScene *scene = import.ReadFile(path, assimp_read_flag);
        aiScene* tmp;
        aiCopyScene(scene, &tmp);
        Assimp::Exporter exporter;
        exporter.Export(tmp, "fbx, "./load.fbx");

Result Screenshots(blender)

import fbx export fbx
image image

what i tried to fix this

changed code add function in FBXExporter.cpp

int64_t to_ktime2(double ticks, const aiAnimation* anim) {
    if (anim->mTicksPerSecond <= 0) {
        return static_cast<int64_t>(ticks) * FBX::SECOND;
    }
    return static_cast<int64_t>((ticks / anim->mTicksPerSecond) * FBX::SECOND);
}

and change to_ktime(double time) => to_ktime2

because mTime Formula of FBXConverter.cpp is mTime = ( (double) keytimes[i] / 46186158000LL) * anim_fps

I thought that applying this would restore it.

result

blender my app
image image

The result is a few keyframes overlapping, but not slow.

The approach seems to be similar, how do you go about solving it?

Nor-s avatar Jun 01 '22 18:06 Nor-s