-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Gltf importer doesn't import skeleton(s) correctly #15181
Comments
|
Trialing a8a3d5c |
https://www.youtube.com/watch?v=_OWce6kJRJ0 I had to rescale xyz to 0.1 and have a 90 deg rotation, but the bones animation seems correct. |
@RandomShaper https://github.com/KhronosGroup/glTF-Blender-Exporter/tree/master/polly This model fails to be imported in gltf2. Reduz said to ping you. To see the failure, play the animation. |
@reduz Seems to be related to KhronosGroup/glTF-Sample-Models#83 (comment) |
Here's a sample project. It is based on mrdoob/three.js#11644 |
I'm investigating skeleton issues. At this point I have a solid clue to follow. |
I noticed that doing this for the above Test Gltf2 project it gives the correct animation. Although the entire scene is shrunk by 100.
This line should be getting the parent's global transform but I ran into a problem getting it. Hope this helps. |
https://drive.google.com/a/chibifire.com/uc?id=1iS5JUv5SkuMltYxtluWteBH7tgD6bWl_ This is the dae scene of the above project if it helps for comparison. |
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -2069,6 +2069,16 @@ Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_f
for (Map<Node *, Skeleton *>::Element *E = state.paths_to_skeleton.front(); E; E = E->next()) {
MeshInstance *mi = Object::cast_to<MeshInstance>(E->key());
ERR_CONTINUE(!mi);
+ for (int i = 0; i < skeletons.size(); i++) {
+ //get global transform
+ Spatial *node = Object::cast_to<Spatial>(skeletons[i]);
+ Transform global = Transform();
+ while (node != nullptr) {
+ global = global * Object::cast_to<Spatial>(node)->get_transform();
+ node = Object::cast_to<Spatial>(node->get_parent());
+ }
+ mi->set_transform(global);
+ }
mi->set_skeleton_path(mi->get_path_to(E->get()));
} This code works for the above project and the ladder project on sketchfab. https://sketchfab.com/models/7ece1ee1b602436dbcfb77e4f58ba8e5# The scale is a 100 on the sample project initially, but playing the anim shrinks the model. |
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -2069,6 +2069,13 @@ Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_f
for (Map<Node *, Skeleton *>::Element *E = state.paths_to_skeleton.front(); E; E = E->next()) {
MeshInstance *mi = Object::cast_to<MeshInstance>(E->key());
ERR_CONTINUE(!mi);
+ Spatial *node = Object::cast_to<Spatial>(E->value());
+ Transform global = Transform();
+ while (node != nullptr) {
+ global = global * Object::cast_to<Spatial>(node)->get_transform();
+ node = Object::cast_to<Spatial>(node->get_parent());
+ }
+ mi->set_transform(global);
mi->set_skeleton_path(mi->get_path_to(E->get()));
}
Better version of the code. |
Could you try your solution with this one, please? |
It doesn't work. Note the gltf doesn't open in https://github.com/pissang/clay-viewer though. |
Trying to take raw dae and reexporting it as gltf2. https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/sourceModels/RiggedFigure/RiggedFigure.dae I tried opening the dae in modo and exporting it as gltf2. Noticed that the animations don't play in modo and the exported scene lacks anims. I tried opening the dae in blender and hit animate. The animation played, but exporting as fbx and opening it in modo or clay viewer failed with animations. |
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/RiggedSimple Works in both patched and master. |
No idea what is happening. Have to do something else now. |
Thanks. So RiggedFigure doesn't work in Godot even with your patch. Am I right? |
@RandomShaper Tried with EmaSimpleSkin.dae converted to gltf2 using modo. https://i.imgur.com/JUvd5bz.png Sample model was from mrdoob/three.js#11644 |
This issue hasn't changed after #18032, right? |
Let me try it on master. |
The skeleton is still scaled 100 times bigger and the animation is scaled 100 times smaller on ca1312d |
Thanks. It was just to be sure there's still an issue to investigate. |
Works as of 5b70ad9 |
Godot version:
Patched version of 99960d9
OS/device including version:
gtx 1080. I don't think driver versions are related.
Issue description:
Gltf2 skeletons don't import correctly. It also breaks my gltf2fbx workflow.
License: Creative Commons Attribution
stepladder.zip
TheDrone (https://sketchfab.com/thedrone)
https://sketchfab.com/models/7ece1ee1b602436dbcfb77e4f58ba8e5# (See the animation playback online)
Steps to reproduce:
The text was updated successfully, but these errors were encountered: