BadDogSkyrim / PyNifly

Export/Import tools between Blender and the Nif format, using Bodyslide/Outfit Studio's Nifly layer. Supports Skyrim LE, Skyrim SE, Fallout 4, Fallout New Vegas, Fallout 76, and Fallout 3.
GNU General Public License v3.0
179 stars 16 forks source link

[Feature Request] Option to batch export .nif files #241

Open VessperiaS opened 2 months ago

VessperiaS commented 2 months ago

I'm doing Fallout 4 modding, at the moment I'm making a blender scene with a lot of meshes inside to customize their appearance relative to each other. There are now 50 meshes in my scene that need to be exported separately each time. It would be convenient to add a button that allows you to export each selected mesh separately into separate .nif files, instead of creating one .nif file with 50 meshes.

Thank you so much for your great invaluable work on the plugin!

BadDogSkyrim commented 2 months ago

Currently an imported mesh is always the child of a node that represents the root node in the nif. Could create a separate mesh if you are exporting separate root nodes.

Is that a reasonable solution for you? If you don't need the root node for the export, it would be a hassle to create 50 of them.

VessperiaS commented 2 months ago

Yes, there will still be additional actions slowing down the work. I work with simple models, but absolutely original ones, I work on their topology with different modifiers and so on. Therefore, in the process, I move them in different ways in the outliner to simplify work on a large file with many objects. After a long time, everything is already mixed up, the rest of the roots have long been deleted, except for one so as not to get confused. Otherwise, they would have clogged the outliner with a bunch of duplicated roots with a numeric suffix. After all, it would be easier to just select the meshes and batch export them through one button than to create 50 roots in one scene again. However it's almost the same as pressing the save button 50 times, only now you need to create a lot of roots and parent all the meshes manually.

BadDogSkyrim commented 2 months ago

Adding a setting to export each mesh in its own nif is easy enough. There might be some horsing around with parent/child relationships--if a mesh is child to another node, they should go to the same nif, probably. Children of a root node should probably go to the same nif regardless of the setting. Selecting several roots should probably go to separate nifs regardless of the setting.

Names would have to come from the mesh names in Blender.

VessperiaS commented 2 months ago

Well, actually I tried to import 6 nifs in the scene and export them right after. All of them got their root, but with the same name + numeric suffix (eg "Scene Root:ROOT.002" ). In this situation, I tried to:

No matter what I choose to export I am ending up with only one file, containing few meshes. Also, I tried to simply rename the roots in different patterns similar to how vanilla game meshes names their root and export again with different selection sets > sadly nothing worked...

But I have to say — these meshes are hairstyles. I imported them in scene, but not their _faceBones versions (!). They are using only default skeleton, not faceBones one. And somehow on export no matter what I do, they are creating a duplicate file with _faceBones suffix. So everytime I end up with 2 files after trying to export them.

Maybe this is happening, I mean the unavailability of saving multiple files, because the exporter prioritizes the routine of exporting base and _faceBones versions of file. Even if no mesh in scene is using _faceBones skeleton...

Also, about faceBones — I create them absolutely seperately and adding "_faceBones" suffix to them in the end. They are using _faceBones skeleton for sure. On export they also give me 2 files: one contains usual skeleton (why...) and second with duplicate "_faceBones" suffix and the right skeleton. That would be really cool if exporter would check if the suffix is already present and decide to not add another one on export.

Thank you for attention, once again! 😊

BadDogSkyrim commented 2 months ago

Yeah, right now everything exports to one nif. (Or several, if you have facebones or shape keys with "_".)

You can have a facebones armature and a normal armature, with an armature modifier for each. Then you'll get only the regular bones in one and the facebones in the other.

VessperiaS commented 2 months ago

I am very sorry, but English is not my first language. Sometimes it is a little bit hard to interpret specificaly what do you mean or it just puzzles my mind as a 3d artist. But I have to ask - do you mean I should assign faceBones skeleton to the same mesh that already has default one? If I do so, I am going to end up with messed up bone weights on export, since vertex groups for some bones are the same in both of skeletons. If I do my work with basic human skeleton and create a quality skinning for bones manually, it is going to have, for example, bone groups "HEAD" and "Head_skin". If I assign faceBones skeleton as second modifier and create skinning for it manually again, I am going to end up with changed skinning for basic skeleton since it has the same bones. And head bones are not the only ones, for example both of the skeletons has Collarbones and few bones for neck. If I do all of this work with skinning on the same mesh with 2 armatures, it is going to result in a very awful mistake. By mistake I mean that technically bone weights assigned to one vertex should have the sum of their weights of 1 strictly. If I work with one skeleton and create weights, they are going to be partially reset or even erased if I am going to paint other weights for other skeleton on top of them. In the end, some groups from basic skeleton are going to be changed the way some vertexes might left completely unnasigned to any group, which results in a stretched mesh ingame. In short, to assign both skeletons to the same mesh is incorrect, because, for example, I need to have absolutely different areas affected by the same bone in different skeletons.

BadDogSkyrim commented 2 months ago

Thing is, either a bone is in one skeleton or the other or both. If it's in both, the weights should be the same in both. And don't worry about the weights adding up to 1--the exporter will take care of that. For a head, make sure the weights around the neck match the weights on the body EXACTLY, then weight the skin_bone facebones bones however you like. You can manipulate each armature in pose mode to make sure you're getting the result you want. Then export once and you'll get both the head file and the head_facebones file. And the weights of both files will match as they should.