PrismaticFlower / SWBF-msh-Blender-IO

.msh (SWBF toolchain version) exporter for Blender
Apache License 2.0
19 stars 6 forks source link

Add Animation Import(s) to NLA Track List #8

Closed maximstewart closed 1 year ago

maximstewart commented 1 year ago

I wish github had an ignore white space changes as part of the change view. =/

Anyway, this is a WIP patch to enhance importing multiple animations in 2.82+. I noticed that selecting multiple animation files and importing still only showed one animation as brought in the Track list. This patch additionally pushes the animation(s) to the NLA Tracks whereas before it was just getting setup in:

bpy.data.actions.new

Besides just bulk importing of animations, my use case is for exporting to glTF and importing to Godot. Adding these to the NLA Tracks list fixes glTF exports such that Godot sees and can play the given animations automagically.

maximstewart commented 1 year ago

When I say WIP Patch I mean that I'm curious if there are any concerns/issues that y'all would know that need ironing out. As far as I can discern, this works for me without issue. But, maybe my approach is bad or y'all know something about the track lists that I don't.

PrismaticFlower commented 1 year ago

It looks good to me but I didn't write any of the animation stuff and don't know much about how Blender works in this regard. If @WHSnyder is able to quickly look at this and sign off on it that'd be great.

maximstewart commented 1 year ago

I'll admit I'm a bit confused in this regard. The code pushes it to the Animations Data list and I see imported animations there. But, I'm surprised/confused on why it doesn't add to the NLA Tracks list too. This doesn't touch export or anything. It still adds to the Animations Data list too. The thing is is you can manually push those to the Track List when an animation is loaded but it's tedious. So, really, I'm just making the process user friendly in that regard and convenient to export to Godot. =P

Based on my research of the Blender API it looks like you can actually pull the animation data from the NLA Tracks List. Maybe it might be worth moving the code to use it from there at some point. Again, still getting my feet wet so I might be off.

WHSnyder commented 1 year ago

Ah yea when I wrote this I just never bothered to even figure out what NLA tracks were for since I wrote it for reverse engineering purposes. But yeah this seems super useful so I'll have a closer look this week. Thanks so much for your interest in the project!

maximstewart commented 1 year ago

I look forward to your review and I want to thank the both of you for your work! At one point I was working on trying to convert the XSIZETools to Python 3 and then wrap around that the Blender APIs and only got up to the point of meshes importing without textures when at some point someone on the Gametoast forums mentioned your project.

Honestly, I'm stoked by this project given it's easier to follow logic wise. And, I love Blender and having msh support is wonderful. I'm hoping to pick through this project further but am certain if y'all gave up maintaining it that I could still work with it/patch it as Bender updates.

maximstewart commented 1 year ago

Removed arma.animation_data.action assignment b/c after checking we can still play animations and they still added to the arma.animation_data.actions list. Tested by exporting imported animations and just importing back the exported animation.

maximstewart commented 1 year ago

Nvm, forgot Active animation export still needs it. 🫣

maximstewart commented 1 year ago

Any progress on confirming this PR?

PrismaticFlower commented 1 year ago

I'm happy for it to be merged if @WHSnyder is.