Skip to content

Bug: FBX export gives wrong animation duration  #4698

Closed

Description

@TwnKey

Hello,
I noticed the animations in my exported fbx files were stopping before the actual end of the animation, leaving some keys behind.
I believe this is due to this specific part of the code here in code/AssetLib/FBX/FBXExporter.cpp:
image
which causes the duration to be floored right before converting to k time units (if I understood correctly), losing the fractional part.

I changed it to this to make it work for my project:
image

Activity

  1. added
    Bug
    on Aug 19, 2022
  2. added
    FBX
    on Aug 20, 2022
  3. Nor-s commented on Aug 21, 2022

    @Nor-s
    Contributor

    Did you change the transformation key times too?

    // position/translation
                for (size_t ki = 0; ki < na->mNumPositionKeys; ++ki) {
                    const aiVectorKey& k = na->mPositionKeys[ki];
                    times.push_back(to_ktime(k.mTime));

    to_ktime(k.mTime) => to_ktime(k.mTime, anim)

    It work for my project.

    Also, i did some testing and found that it only exports 24fps(FileGlobalSettings::FrameRate_CINEMA).

    So the duration can be unstable, If it is an animation such as 30fps.

  4. TwnKey commented on Aug 21, 2022

    @TwnKey
    Author

    Ah no, I didn't, I actually didn't even think about doing it. I know the k_time function with only the time as argument works too.
    But now I'm wondering if I really should, I was under the impression that k_time is only used for fbx, so if I wanted to change the export format to dae (or make the user able to change it to dae), would it make sense to use k_time before the export function is called?
    I believe the conversion itself is harmless but if the k_time is only intended for fbx I would prefer to keep the key time agnostic of any format if possible.

  5. Nor-s commented on Aug 21, 2022

    @Nor-s
    Contributor

    What I meant was the conversion inside the fbx export function. not before the export function.

    FBXExporter.cpp

    If you use the ktime(time) function in FBXExporter.cpp, you can see that the scale is different from the duration.
    (my case is fbx to fbx. In other cases, I don't know.)

    The problem seems to occur because the FBX importer uses the same formula for duration and ktime, but the FBX exporter uses different formulas.

  6. moved this from 🆕 New to ✅ Done in The Asset-Importer-Lib DevOps Boardon Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFBX

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions