-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rmodels] Incorrect animation of glTF model #4055
Comments
@paulmelis Thanks for reporting about the FAQ, just reviewed it. About the different models animations working or not, I don't know the reason but I can guess is related to the bones hierarchy and its transformations. Is it possible to export a GLTF file with the transformations "baked" by bone? |
Were these models exported by blockbench? |
I don't know. They're part of the glTF sample repo, but no idea how they were created. |
Hmm, one difference I see that might be of influence is that CesiumMan.glb only has one mesh with one primitive, while BrainStem.glb also only has one mesh but that mesh has a few dozen primitives (each with their own JOINT_0 and WEIGHTS_0 arrays). And primitives are converted into separate raylib Mesh's during loading. |
Hello, I tested exported models by blockbench of the cobblemon's pokemon. In general, feet and body are placed correctly during animation, but the head and other bones like leaves on a ivysaur go right in the center. I have faced a similar issue with the Fox of the glTF sample repo. |
@paulmelis @Arcod7 thanks for the further investigation of this issue! It seems issue could be related how meshes are exported by |
Here's an illustrated example : The Torterra model in blockbench exported to glb works great in blender, but breaks in raylib (on the latest github dev version).
I'm highly motivated to try to solve the bug, do you have any idea that could help me ? |
@Arcod7 Mmmh... interesting, it seems that node transformations are only considered for the first hierarchy level but not applied down to the other hierarchy levels. |
Okay, do you think you will have time for this soon ? If there's something else I can provide to help, you can tell me ! |
@Arcod7 I'm afraid I don't have time to review it. I neither implemented current loader (only vertex data loading) so it would take me a lot of time that unfortunately I don't have at the moment. |
@VitoTringolo Wow! It looks great!!! |
Can you maybe try this model to? |
Hello @VitoTringolo, you did great, it looks stunning ! Also did you only touched the translation part or you also fixed rotations ? On the model provided by @MrScautHD (and a lot of my models), parts of the body disappear with the rotation applied. Run animation: (only scale and rotation applied, I disabled transformations) Idle animation: (only scale and rotation applied, I disabled transformations) |
@MrScautHD @Arcod7 is this model created with |
yea |
My models are also coming from blockbench (bbmodel exported to glb). They are working great with blender (not a single issue). |
Sure thing! |
Before we were completely not considering the transform matrix when the animation channel was NULL! This was the main issue! So to answer your question, yes I am now considering the translation the rotation and also the scaling factor for each joint |
It looks so nice 😊 ! My models are those from cobblemon If you want a sample of exported models I can provide it. |
This fixes almost everything on the cobblemon models, thanks a lot ! |
I'm not sure I understand what you described, what do you mean with "animation has an animation length of 0 "? Can you share a model with these properties? |
Sure ! Here's a model with a ground_walk working at index 1 (animation length is set to 2 in blockbench) and a ground_idle that's not working as expected at index 0 (animation length is set to 0 in blockbench) https://github.com/raysan5/raylib/assets/77203393/cb7a6135-09f9-4f23-98ae-6356668612f9 Have a good day ! |
I think that is the right solution. Otherwise, it should be checked if the glTF official specs allow other behaviours. |
@MrScautHD What is the license of the |
Its mine, so feel free to use it. 😊 |
@VitoTringolo and @raysan5 What about this error? |
Oh yeah! That's because of this line of code: if (FloatEquals(tend, tstart)) return false; I think I can change to return true, without any problem to avoid flooding! |
Please, before submitting a new issue verify and check:
By the way, the FAQ currently reads:
But there is
LoadModelAnimations()
which supports GLTF? So seems the FAQ entry is out of date?Issue description
While trying to figure out how to make #4037 work well together with animated models, I noticed current support for animations isn't entirely bug-free (hence making the glTF transform work on top of it somewhat challenging).
For example, with https://github.com/KhronosGroup/glTF-Sample-Models/blob/main/2.0/BrainStem/glTF-Binary/BrainStem.glb (which needs #4053 to handle the missing bone names) the initial load of the model, without applying
UpdateModelAnimation()
is okay (which is not surprising, as there's only a single mesh):But when applying
UpdateModelAnimation()
in the render loop, the transforms based on the armature make parts fly all over the place incorrectly:But then a very similar model like https://github.com/KhronosGroup/glTF-Sample-Models/blob/main/2.0/CesiumMan/glTF-Binary/CesiumMan.glb does animate correctly, and I don't immediately see the big difference between the two files causing the issues.
Environment
Arch Linux, GTX TITAN
Code Example
Edit: first linked glb was wrong, should be BrainStem.glb, now fixed
The text was updated successfully, but these errors were encountered: