Skip to content

[models] glTF animations not working properly, bones transform related #1799

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

Closed
3 tasks done
object71 opened this issue May 30, 2021 · 9 comments
Closed
3 tasks done

Comments

@object71
Copy link
Contributor

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • My code has no errors or misuse of raylib

Issue description

Animated models loaded through Raylib by using GLTF format are broken.
I am also attaching the model for reference:

girl.zip

I will try and fix the issue when I can but if someone else is faster to it I won't mind :)

Environment

I tested on Windows.

Issue Screenshot

You can see how it is in the provided example here:

error

And how it should be when viewed through Windows 3D Viewer:

correct

Code Example

Minimal reproduction is to use the samples code for GLTF animations in Raylib and just set the model for loading and animations to use the girl.glb file that I am providing with this issue. There are two animations on that model - idle and run and both seem to be broken.

@object71
Copy link
Contributor Author

object71 commented Jun 5, 2021

When drawing the dots for the bones' position (translated for each animation) the bones' positions seem to be in the right places. This leads me to believe there is no problem with the translation but the problem might be more in the bone weights or rotation values... Or how they are applied in the end.
bones_visualized

PS: There are some static bones in the GIF - they are just IK and are useful in blender. They should have no weight over the model.

@object71
Copy link
Contributor Author

I strongly suspect that the issue is related to the skin inverseBoneMatrix not being taken into account on the GLTF model.

More info about the skinning of the mesh: https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_020_Skins.md

What we need to achieve is to still process animation on all nodes (no matter that not all of them are considered bones - in raylib they are all translated to bones because bones have the Transformation fields related to them). But also check which nodes are part of a skin and take into account that skin's array of inverseBoneMatrix.

Because it is a matrix though we would need a matrix decomposition function so that we can apply its transformations to the bone transformations. I've opened an issue for that: #1850

@raysan5
Copy link
Owner

raysan5 commented Jul 28, 2021

@object71 Any news on this issue?

@object71
Copy link
Contributor Author

Nothing new that I found out. I just don't have the time to work on it.

@raysan5 raysan5 changed the title [models] Animated models loaded through Raylib by using GLTF format are broken [models] glTF animations not working properly, bones transform related Aug 27, 2021
@MrDiver
Copy link
Contributor

MrDiver commented Aug 30, 2021

Note: The LoadModelAnimations function needs an extra check if the file exists to not segfault. Or at least a controlled exception that shuts down the program.

@rcorre
Copy link
Contributor

rcorre commented Oct 6, 2021

Because it is a matrix though we would need a matrix decomposition function so that we can apply its transformations to the bone transformations.

Maybe this is a silly question, as I just started looking at the animation code, but why do we need a Transform type at all for bones? Could we just use Matrix for bindPose and framePoses?

@raysan5
Copy link
Owner

raysan5 commented Oct 21, 2021

I'm closing this issue because glTF animation system has been removed for now. It will be redesigned in the future.

@raysan5 raysan5 closed this as completed Oct 21, 2021
@redthing1
Copy link
Contributor

I'm closing this issue because glTF animation system has been removed for now. It will be redesigned in the future.

@raysan5, out of curiosity, why was glTF anim support removed?

@raysan5
Copy link
Owner

raysan5 commented Nov 28, 2021

@redthing1 I removed it because it was not working properly, it requires a complete rework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants