ross-g / io_pdx_mesh

Import/Export files for the Clausewitz game engine
GNU General Public License v3.0
85 stars 11 forks source link

Enhancement Request: Object-specific animation loading. #28

Open Tetrino opened 3 years ago

Tetrino commented 3 years ago

I tried to add this myself but I'm frankly still crap at Python. Hoping it's not too bad a job...

As expected by me - and correct for the code as written - you cannot import multiple animations into one scene if there are more than one rigs available.

So, for example (it's me, so Stellaris):

https://github.com/ross-g/io_pdx_mesh/blob/7b41ef0a791ad5675ba6c266993bcd851541a0f4/pdx_blender/blender_import_export.py#L1344

My request is that this area of code is changed such that it attempts to apply to the current actively selected rig/armature (if any) before searching the whole scene for them. I'm a realist so not asking for any kind of UI for it, documented functionality would do plenty!

Thus my workflow would be:

I'm working around it right now by scene linking (applying the animation separately and importing them to the scene I need them to be). Functionally I don't think there is any direct limitation for this, just searching the selection before scene in get_rig_from_bone?

https://github.com/ross-g/io_pdx_mesh/blob/7b41ef0a791ad5675ba6c266993bcd851541a0f4/pdx_blender/blender_import_export.py#L92

I figure if someone tries to apply the wrong animation to the wrong rig they should expect busted behaviour. Don't need to error check it too much.

Thanks Ross!

Tetrino commented 3 years ago

Huh, I worked it out pretty quickly once I had the right headspace and reference. I've submitted a PR against the bugfix branch (which is what I was using) for your consideration. https://github.com/ross-g/io_pdx_mesh/pull/29

Cheers.

ElTyranos commented 3 years ago

Hey Tetrino,

This is unrelated but I can't mention you. Over there.

I'm working on CK3, I have no python background so I'm barely able to read the exporter. Maybe you could find the culprit "easily" on #16 ?

Regards, El Tyranos

Tetrino commented 3 years ago

I'm afraid not without trying to import myself, and I don't own CK3, sorry.

ross-g commented 3 years ago

Hey @Tetrino, this sounds like a good improvement 😄 but might need a bit more work to support multiple assets in a single scene like you've described.

For example - you mention working in a single scene with the space whale and the dragon from Stellaris. Currently you can't actually import both of those assets into a Blender scene correctly because the second import will try to use the "io_pdx_rig" that already exists in the scene... and so will fail in other places because the expect bones don't exist. This is all solvable of course (!) with a bit more thought about how it should work and throwing out the current assumptions about 1 asset per scene.

Thanks for the PR for this, I'll take a proper look during the week though I am inclined to say that the "apply anim to selected" behaviour should be an explicit option in the import UI. Which is easy enough to add. I'm a little unwilling to just take the PR directly as it would break feature parity between Maya and Blender... and it took me quite a lot of work to get to that point in the first place. But it's not a difficult thing to implement, so I am sure I can get this in for the next release.

Tetrino commented 3 years ago

Hey @ross-g, happy new year!

If I'm honest I hadn't considered importing into the same scene, as my workflow (like many) involves handling each asset in its own file and dynamic linking. That's on me! I also agree it would need feature parity with Maya and I figured that ultimately the PR would be used as a basis for what I mean rather than pulled in directly.

I also agree it should be an explicit option in the UI. Admittedly what I supplied was more my workaround hack to meet my needs at the time.

If I may make a suggestion, perhaps a way to differentiate each rig would be to name the rig after the file it's imported from (after sanity checking the string), with a numbered iterator in cases where users import multiples of the same file (e.g. importing spider.mesh twice will give spider_rig and spider_rig_2)? Would keep things nice and clear for the user.

Please do what you think is best and it's almost certainly not an urgent requirement! I did manage to do exactly what I needed for this myself, however, and future things coming.