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

Feature: Export models with skeleton #8

Merged
merged 8 commits into from
Jun 2, 2024
Merged

Conversation

ryanjsims
Copy link
Contributor

This change adds support for exporting skeletons from unit files.

Currently the bones' local transforms are not correctly converted from Stingray global coordinates to gltf local coordinates, but resetting the pose in Blender will get the skeleton into the correct orientation. This isn't a big deal right now, but once we start exporting animations as well it will be more important to have the bones oriented correctly.

To enable skeleton export, there is a new unit config option bones that can either be disabled (default) or enabled.

Here's an example of a bile titan with all its bones visible (after resetting the pose)

image

and an example animation using only a couple of IK constraints on the exported bones

bile_titan_leg_stab.mp4

ryanjsims added 7 commits June 1, 2024 12:17
Still needs the rotations and translations and bone indices to be fixed up.
Bone indices appear to be offset from the actual values, maybe there's something in the vertex groups that indicates this?
Rotations and translations need to be adjusted to gltf relative coordinates.
Finally, <file>.bones need to be used to map the bone hashes to names
@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Wow! Your results look great so far!

Can you tell me more about how you managed to create the animation you shared? When I load the model into blender, the bones are just huge spheres. I'd like to merge this PR once I can understand how it's directly useful to non-technical people using the app. But maybe I'm just missing something since I'm not very educated in terms of 3D art / blender.

Also, you mentioned creating IK constraints yourself. If you pass -c "enable:all", you can see all the file types (including raw). One of them is ìk_skeleton (e.g. content/fac_bugs/cha_strider/cha_strider.ik_skeleton for the bile titan). Did you look into parsing it yet?

In any case, nice work so far! I love seeing this project move forward although I don't have a lot of time to dedicate to it right now.

@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Don't worry about the conflicts I created with my last commit, I'll resolve them before merging.

@ryanjsims
Copy link
Contributor Author

ryanjsims commented Jun 2, 2024

One of them is ìk_skeleton (e.g. content/fac_bugs/cha_strider/cha_strider.ik_skeleton for the bile titan). Did you look into parsing it yet?

Yes, if you look at the research/hex-patterns branch on my fork, in the patterns folder I have an ik_skeleton hex pattern for use with ImHex. I have parsed the very broad strokes of that file type, but I haven't gotten into the actual details of it yet

As for the huge spheres, that sounds like something with how blender is configured to display bones? Could you add a screenshot?

@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Yes, if you look at the research/hex-patterns branch on my fork, in the patterns folder I have an ik_skeleton hex pattern for use with ImHex. I have parsed the very broad strokes of that file type, but I haven't gotten into the actual details of it yet

Great to hear! Let me know if you find anything interesting.

As for the huge spheres, that sounds like something with how blender is configured to display bones? Could you add a screenshot?

Sure, here are the spheres...
grafik
... and the bile titan at the same zoom level
grafik

Blender version is 4.0. I didn't change any blender settings AFAIK. Are you using a different version?

@ryanjsims
Copy link
Contributor Author

Found this video about it: https://www.youtube.com/watch?v=U5XboSEw7-o

Looks like it has to do with viewport display -> shapes being selected? I've never seen that happen with gltf skeletons before in blender. I also saw some people saying there is a setting in the import menu about "Bone Shape" that can be set to default to prevent it from happening, but I don't see that option when importing gltf files

@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Thanks! Setting Bone Dir to Temperance did the trick!
grafik

It looks like your screenshot now
grafik

@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Well, I guess that's good enough to merge into main for now. I'm very excited to see how this will continue to improve with IK and proper pose positioning.

Thanks again for your work on this!

@xypwn xypwn merged commit 6b84295 into xypwn:master Jun 2, 2024
1 check was pending
@ryanjsims
Copy link
Contributor Author

ryanjsims commented Jun 2, 2024

I'm not sure if we'll be able to implement IK on export to gltf since I don't think the format supports it - we may need to add a second format if we want to have IK exported. Maybe direct to .blend?

Either way the IK skeleton should have some interesting data, which will probably be useful even if we don't export it immediately

@xypwn
Copy link
Owner

xypwn commented Jun 2, 2024

Hmm, I guess that's true. I just assumed without knowing that there'd be a standard for IK, allowing for exports/imports, but apparently there's nothing like that. While it might have some interesting data, I think focusing on animations and getting the pose to work correctly is probably more important right now.

@ryanjsims ryanjsims deleted the feature/bones branch June 3, 2024 02:03
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

Successfully merging this pull request may close these issues.

2 participants