Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: FBX export gives wrong animation duration #4698

Closed
TwnKey opened this issue Aug 19, 2022 · 3 comments · Fixed by #5355
Closed

Bug: FBX export gives wrong animation duration #4698

TwnKey opened this issue Aug 19, 2022 · 3 comments · Fixed by #5355
Labels
Bug Global flag to mark a deviation from expected behaviour FBX Bugs related to the FBX format

Comments

@TwnKey
Copy link

TwnKey commented Aug 19, 2022

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

@TwnKey TwnKey added the Bug Global flag to mark a deviation from expected behaviour label Aug 19, 2022
@kimkulling kimkulling added the FBX Bugs related to the FBX format label Aug 20, 2022
@Nor-s
Copy link
Contributor

Nor-s commented Aug 21, 2022

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.

@TwnKey
Copy link
Author

TwnKey commented Aug 21, 2022

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.

@Nor-s
Copy link
Contributor

Nor-s commented Aug 21, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Global flag to mark a deviation from expected behaviour FBX Bugs related to the FBX format
Projects
Development

Successfully merging a pull request may close this issue.

3 participants