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

Import GLTF curves physical skeleton not exact place #39757

Closed
Darkinggq opened this issue Jun 22, 2020 · 11 comments · Fixed by #48310
Closed

Import GLTF curves physical skeleton not exact place #39757

Darkinggq opened this issue Jun 22, 2020 · 11 comments · Fixed by #48310

Comments

@Darkinggq
Copy link

Darkinggq commented Jun 22, 2020

Godot version:
v3.2.1stable/v3.2.2rc2

OS/device including version:
Debian 10.4

Issue description:
Blender 2.83 export import format GLTF/DAE problem miscellaneous left or right
2020-06-22_17-29

already tried godot 3.2.1stable and 3.2.2rc2 anyway it's useless who hasn't fixed physical bones

blender 2.83 the original modeling + skeletons
image

Minimal reproduction project:
_cloth_phys.blend.zip only blender 2.83

@Darkinggq
Copy link
Author

test model took from youtube tutorial https://www.youtube.com/watch?v=mdyRO8_q7lI

@xtremezero
Copy link

This is an issue with the mesh it self

The mesh transformations were not applied before exporting 👌

However, it's true that GLTF importer in godot has an issue with identifying bones orientation when creating physical bones

@Darkinggq Darkinggq changed the title Import model + skeletons gltf/dae format both bad Import GLTF curves physical skeleton not exact place Jun 23, 2020
@fire
Copy link
Member

fire commented Jun 24, 2020

_cloth_phys.blend.zip

I can create a fixed version of this.

Using the gltf2 on 3.2 and the blender option set to "fortune".

Screen Shot 2020-06-24 at 1 38 40 AM

@Darkinggq
Copy link
Author

Darkinggq commented Jun 24, 2020

this i made the result useless nothing has changed physical bones

2020-06-24_17-15

@fire
Copy link
Member

fire commented Jun 24, 2020

I'm not able to dig deeply into [to] find the cause today. However, I can post the scene for my variation if it can help.

editor_screenshot_2020-06-24T080517-0700

I can confirm it fails for rc2.

@fire
Copy link
Member

fire commented Oct 18, 2020

Are you able to retest on latest stable?

@Blackiris
Copy link
Contributor

Still reproducible in Godot 3.2.4 beta 4

@Blackiris
Copy link
Contributor

Blackiris commented Dec 16, 2020

From what I understand, this issue could be from 2 different causes: error from the Create physical skeleton code, or error from the GLTF (parsing, or export from Blender).
Given that GLTF seems to work well for animation, I have looked at the first cause.

In skeleton_editor_plugin.cpp, the code is assuming the bone direction is pointing to -Z, hence the physical bone body offset to put it in the middle:

body_transform.origin = Vector3(0, 0, -half_height);

But, when using GLTF model, it could point to completely another direction
By setting the body offset using the bone rest vector instead, it partially fixes the issue:

Vector3 bone_rest_origin = skeleton->get_bone_rest(bone_child_id).origin;
body_transform.origin = bone_rest_origin * 0.5;

bone_origin_ok_dir_ko

However, the physical bone rotation is not set along the bone, and for this, I had to use:

body_transform = body_transform.looking_at(Vector3(0, 0, 0), Vector3(0, 0, 1));

bone_origin_ok_dir_ok

It is my first look at Godot's code so I don't know if it is the proper way to do the rotation...

@Blackiris
Copy link
Contributor

It was not a good idea to rotate the physical bones since it creates issues with the physic engine. Instead, rotation the collision shape is much safer.

@Blackiris
Copy link
Contributor

I have just created a PR for the Godot 4.0 version #48310.
Please find here a reproduction project for Godot 4.0 containing 3 models, using DAE and GLTF (total 6 cases):

testSkeleton-godot4-0.zip

Just open one of the 6 scene, select the skeleton and click on Create physical skeleton.

@akien-mga
Copy link
Member

Fixed by #48310.

@akien-mga akien-mga modified the milestones: 4.0, 3.5 Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants