io_scene_mw icon indicating copy to clipboard operation
io_scene_mw copied to clipboard

Addon for improving Blender workflow when using this

Open josephbburg opened this issue 3 years ago • 5 comments

Hello! Sorry to open an issue for this, as I can't find another way to send a message. I just want to point you to a quick addon I wrote which, used in combination with yours, is designed to make the Blender side of things easier for animators.

https://gitlab.com/josephbburg/blender_makemorrowindanimationeasier

It can:
Process Import:
chops up Morrowind's animations into Blender Actions for easily editing.
Prepare Export:
This takes the Actions from their easily editable form and puts them back into the form your Morrowind exporter expects.
Swap Morrowind Animation:
This sets the objects in the scene to use the editable actions made with Process Import, so that the animator can easily edit all the objects that are animated.

If you want to bake this into your own addon, I'd be happy to help or maybe I could just make a pull request. If not, I'd like to let you know about it since I think it can help people to get even more use out of your addon.

If you want, you can call this Issue a feature request with a working prototype :slightly_smiling_face:

Thanks!

josephbburg avatar Oct 03 '21 00:10 josephbburg

Nice work! Splitting animation groups into separate actions has long been a desperately needed feature.

I gave your script a try and from some brief testing it seemed to work fine! 👍

I did noticed it left behind some unnecessary markers like idle: start frame and idle: end frame. It also lowercased the markers which is a bit undesirable. I did not check if it splits all types of animations (e.g. animated material colors and such).

I have wanted to add such a feature for awhile but got held up on some edge cases (overlapping groups/etc) and my own unfamiliarity with blender animation workflow. I suspect an ideal implementation would integrate with Blender's NLA Editor interface, but defining the precise export rules / naming conventions seemed a lot of a work and I haven't had the time to commit to it.

Greatness7 avatar Oct 04 '21 19:10 Greatness7

Thanks, and thanks for making this IO addon so I can finally use a modern Blender to toy around with Morrowind! I have done a bit more work on it since I posted the initial comment... I found more vexing edge cases! It enforces lower-case because I found several different cases. I also kept finding weird edge cases like trailing whitespace... As for the overlapping groups, well, that's why I added the 'start frame' and 'end frame' markers, although I don't mean for them to be turned into pose markers so I should fix that when I get around to it. Anyhow, I needed a consistent way of tracking start and end frame and I couldn't rely on the 'Start' tag being there as it doesn't exist for the weapon and spell casting animations! I did play with the NLA at first, but I donno if it's necesary -- you can do any NLA stuff from the chopped-up actions, and the addon has a feature for combining them back into the format your addon expects for export.

animated material colors

I didn't know that was a thing. Which .nif uses this? I can probably hack that in pretty easily. Oh, and if you would happen to have a full list of the soundgen strings that are out there, I'd be thankful if you could point me too it.

josephbburg avatar Oct 07 '21 01:10 josephbburg

There are lots of different kinds of animations, see the NiTimeController heirarchy. At the moment the plugin only supports the following:

NiAlphaController
NiGeomMorpherController
NiKeyframeController
NiMaterialColorController
NiUVController
NiVisController

You can search for these strings in your meshes folder to find examples.

There are some other subtleties to consider. For instance, keyframes at the end of one animation group can potentially end up influencing the animations of the following group due to interpolation tangents not having enough time to even out. To avoid this it might be a good idea to double up the keyframes at the start/end of each group. Groups can also sometimes be entirely contained within other groups, or overlap with each other arbitrarily. I'm not totally sure what kind of side effects that might entail...


Regarding soundgens, you can view the allowed types in the TESCS:

Land
Left
Moan
Right
Roar
Scream
SwimLeft
SwimRight

Which keys an animation group starts/ends with is not always obvious. From my experimenting, the following logic should be reliable:

An animation group always starts with the suffix " Start".

Once you have the start key, you can calculate the stop key as so:

group_name = start_text.removesuffix(" start")
if group_name.endswith(("chop", "slash", "thrust")):
    stop_text = f"{group_name} small follow stop"
elif group_name.endswith("shoot"):
    stop_text = f"{group_name} follow stop"
else:
    stop_text = f"{group_name} stop"

So, the stop text for Idle: Start is simply Idle: Stop. For WeaponOneHand: Chop Start it is WeaponOneHand: Chop Small Follow Stop. And so on.

It's important that once the program hits an animation group's start key it keeps looping over subsequent keys until it hits the appropriate stop key. "Subgroups" inside the animation group should all be collected under the parent group.

For instance, these are all part of the same group:

WeaponOneHand: Chop Start
WeaponOneHand: Chop Min Attack
WeaponOneHand: Chop Max Attack
WeaponOneHand: Chop Min Hit
WeaponOneHand: Chop Hit
WeaponOneHand: Chop Large Follow Start
WeaponOneHand: Chop Large Follow Stop
WeaponOneHand: Chop Medium Follow Start
WeaponOneHand: Chop Medium Follow Stop
WeaponOneHand: Chop Small Follow Start
WeaponOneHand: Chop Small Follow Stop

Grouping in this manner allows "standalone" animation replacers to work. You could export only this chop group to its own file and assign that to an NPC in the editor, or load it dynamically from lua with the loadAnimation function, and have it work fine in-game. Trying to do the same with one of the interior subgroups would not work.

Here is a list of all text keys used in base_anim.nif, for reference.


One other thing that might not be obvious: The exporter allows combining multiple text keys into a single marker via a hardcoded separator string ; . For example, Idle: Start; Idle: Stop in a single marker is allowed and often useful to avoid marker text overlapping in the timeline interface.

Greatness7 avatar Oct 07 '21 07:10 Greatness7

Bless you for your help. It looks like the only animation I haven't included is material stuff. Keyframes, Visibility, and shape keys work (Although visibility seems to be handles a little differently by .Nif. It's not inherited in Blender). I suppose all the others are in the material nodes, unless Blender has some way to animate UV's directly that I'm not aware of (the AnimAll addon waaaaay back in the 2.7 days was supposed to be able to do this). They shouldn't be difficult to deal with.

To avoid this it might be a good idea to double up the keyframes at the start/end of each group. Groups can also sometimes be entirely contained within other groups, or overlap with each other arbitrarily. I'm not totally sure what kind of side effects that might entail...

This is actually something I am well aware of due to the many, many times I've screwed up my animation in my own work :P I accounted for this by calculating the start/end positions of animations. It might not be 100% perfect, but it should be fine.

Grouping in this manner allows "standalone" animation replacers to work. You could export only this chop group to its own file and assign that to an NPC in the editor, or load it dynamically from lua with the loadAnimation function, and have it work fine in-game. Trying to do the same with one of the interior subgroups would not work.

Very interesting :thinking: . Currently I'm just chopping the whole group into an action, and in many cases it looks like the Morrowind animators animated the whole thing in one go and then chopped it into subgroups, anyway (See bow and arrow animation). I suppose I could manage sub-groups, thought. I didn't know about them before, so I didn't try. I'll have another look sometime soon. The semicolon thing with multiple keys is something I didn't know and I haven't supported it.

josephbburg avatar Oct 07 '21 22:10 josephbburg

FINALLY !1!!11!! Nif format IO w/ animation export support for Blender from current age :D I wanna try it immediately, and if it works for me (I need it for Oblivion rather than Morrowind) - I owe you a beer or two :)

Vedamir avatar Nov 04 '22 23:11 Vedamir