Jump to content
  • entries
    12
  • comments
    636
  • views
    10,888

The Effin Export/Import Project


Bad Dog

9,046 views

Edit: For the record, this tool is implemented and has its own thread here: 

 

I can't really do what I want to do with FO4 if I can't do proper weight painting and I don't have full control over the nifs I create. So I've decided to have a look at making proper import/export tools between Blender and FO4. I'm using this blog to track thoughts and progress notes along the way.

 

There are two possible routes:

  1. Extend the niftools package. That is currently being actively worked on, tho there was a long hiatus for the past few years, which meant I was stuck with old versions of Blender and a multi-step conversion process. The recent versions support the latest Blender and maybe have better export--I haven't yet seen a version which exports properly but I haven't tested the latest. Upside of this method is it ties into an existing project and extends the tools that have been around forever. Downside is this stack is very complicated--translation generated from XML files, read/write through pyffi, and so forth. I'm told the XML for FO4 has been written but pyffi needs updating to use it. Presumably higher levels of the stack would need work too? Dunno. 
  2. Bodyslide/OS has export/import to all games and they stay up to date all the time. Their nif code is cleanly separated into a package called Nifly, which is used by BS/OS, Cathedral tools, and Nif Optimizer. So it seems like robust code with an active community behind it. Downside is I'd have to access it from a Blender python addon, and I have to figure out how to walk the Blender representation of a model so as to push it at Nifly.

 

I've looked a little bit at both options. My feeling right now is that the hard part of the niftools route is digging into XML, generated code, and pyffi. The hard part of the Nifly route is figuring out how to bolt it into Blender and parse the Blender data model. That seems more straightforward. It's all known stuff--Blender addons and such. So until I hit a roadblock, I'm going to explore that.

 

The biggest issue is whether I can call the C++ Nifly code from a Blender addon. I hunted through other addons and found an import/export addon that does exactly that. So in theory I just copy their method.

 

So here's the project:

  1. Figure out how to make a Blender export/import addon
  2. Figure out how to make a DLL
  3. Make a dummy DLL and call it from a dummy export/import addon. Once that's done I know I can get data into and out of Blender.
  4. Make a DLL encapsulating Nifly
  5. Call that DLL from my Blender addon. 
  6. Keep adding features until done.

 

#1 is mostly done--I have a little script that pretends to be an export/import addon but does nothing. On to #2.

Edited by Bad Dog

175 Comments


Recommended Comments



So your issue, @DocClox, is that the frame has a bunch of transforms on the object itself. The hook, for example, is scaled to (0.18, 0.18, 0.06)--so way down in the Z direction. Which is why it came out tall and skinny.

 

What I've been doing with the object transforms is feeding them through to the nif file without changing them. That results in a nif that looks like what you have in blender, even tho the vertex coordinates are not where they show up visually (because they're moved by the transform). This should be true even if different meshes in the nif have different transforms.

 

*Except* that nifs don't allow for scaling differently in the different directions, so I just take the X scale and apply it to everything. You should have gotten a warning on export saying this. (Arguably I should fail altogether but I'm taking the approach that the export should always do something if it can.) 

 

There's usually no reason to keep the transforms. Bodies do it because seams have to match exactly, but these transforms aren't doing that. They seem to be just an artifact of where the mesh came from. 

 

So what I'd do is just apply all the transforms in blender. Likely the scale doesn't match the game, so import a CBBE body and scale everything so they are the same size, then apply transforms again. (What that does is move the vertex coordinates themselves to match what the transform says, then gets rid of the transform.) That should give you something consistent.

Link to comment

Thanks for looking at that. Normally I move everything around in Edit mode, but this time I was experimenting with object transforms, mainly because it means I can scale things like the cuffs along their local Z axis. Live and learn, I suppose.

 

 

 

 

Link to comment

Gotcha.

 

Incidentally, I have a python file that generates valid HKX XML from Blender armature and pose data. I haven't tried getting an animation in game yet, so there's plenty of scope for things to go sideways... but it's a lot further forward than I was a week ago.

 

[edit]

 

Got it in game. It crashes the CK if I try and register as furniture. If I use a pose mod to play it, the game crashes.

 

Oh well, little bit more work to do :)

 

[edit]

 

I got it as far as doing a t-pose. Turns out something doesn't like white space in between translation vectors and rotation quaternions.

Link to comment

<heavy breathing>

 

In other news, looking over the BodyTalk body I realize dismemberment is a thing and I think that's done with segments. So I guess I have to actually do them, because I want the bodies complete before I start putting furry bits on them. Yuck, phtooey.

Link to comment
2 minutes ago, Bad Dog said:

dismemberment is a thing

It is, but most body mods out there don't support it for... reasons I don't 100% remember right now (IIRC it was something about limited polycount if you want dismemberment to work, and that limit is way below the standard polycount for the current meshes themselves... maybe?).

 

Either way, I guess segment support for the plugin may come in handy, but I wouldn't go crazy about actually adding dismemberment to your bodies since I don't think most body replacers and outfits out there support it anyway (BT3 might, but CBBE and TWB don't and I think Fusion Girl does not either).

Link to comment
6 minutes ago, Blaze69 said:

It is, but most body mods out there don't support it for... reasons I don't 100% remember right now (IIRC it was something about limited polycount if you want dismemberment to work, and that limit is way below the standard polycount for the current meshes themselves... maybe?).

 

Either way, I guess segment support for the plugin may come in handy, but I wouldn't go crazy about actually adding dismemberment to your bodies since I don't think most body replacers and outfits out there support it anyway (BT3 might, but CBBE and TWB don't and I think Fusion Girl does not either).

 

 

I think there are several modified versions of FB and other bodies on the Nexus that support dismemberment.

For example here: https://www.nexusmods.com/fallout4/mods/49923

Link to comment
1 hour ago, Blaze69 said:

It is, but most body mods out there don't support it

 

It's one of the things that the TheBottomhoodOfSteel mentioned as a particular feature of BT. I think I have to give it the good old college try.

Link to comment

I'm writing up the animation export in its own thread, if anyone wants to follow or join in.

 

 

Currently, I think I have it working for pose purposes ... if I can just get the damn rotation right.

 

@Bad Dog- that Scene Root object would make more sense from my perspective as a root bone, with the model and armature parented to the top level Scene Collection. I don't know if that makes sense form your end.

 

[edit]

 

Oh yeah, other thing I was going to ask: I still can't import a skeleton.nif file. I figured if I did that, and then imported all the body meshes onto that armature, it might solve problems like missing root bones and so forth.

 

If it helps, the error in the console is as follows:

 

Import of nif failed
Traceback (most recent call last):
  File "C:\Users\nick\AppData\Roaming\Blender Foundation\Blender\2.92\scripts\addons\io_scene_nifly\__init__.py", line 280, in execute
    import_nif(f)
  File "C:\Users\nick\AppData\Roaming\Blender Foundation\Blender\2.92\scripts\addons\io_scene_nifly\__init__.py", line 259, in import_nif
    bpy.context.view_layer.objects.active = new_objs[0]
IndexError: list index out of range

 

[edit]

 

That probably doesn't make much sense. The scene root is the armature so obviously the bones need to have that as a parent. It's just that the armature itself isn't a bone  (or doesn't show up as one in Python) and I think I need one. What do you think?

Link to comment

To import skeletons I have to teach the import to not expect a shape, I think is all. I'll do that next.

 

For the root bone, happy to change things around but let's look at what's right.

 

There's always a top-level node in a nif parenting everything. I don't think it's right to consider it a bone, because it's there even if the mesh is a static and has no bones. If the nif has bones but no relationship between them (which is most vanilla Skyrim nifs) if I treated the top-level node as a bone I'd likely then want to make it the parent in the armature to the rest of the bones, which would be wrong. I'd have to treat it as a special case. Standard skeletons have a "Root" bone underneath this top-level node and that's what I made root.

 

On the Blender side, I'm getting used to the way blender does things myself. Right now Collection maps to nif file; Armature maps to whatever skeleton I found in the nif, where some bones are actually in the nif and the rest in the reference skeleton; and Object maps to whatever shapes are in the nif, and the objects are children of the armature. This results in the objects kinda being hidden under the armature in the outline.

 

I could link the objects directly to the collection, which would make them more visible in the outline. Let me know if that addresses the issues you're seeing.

Link to comment
44 minutes ago, Bad Dog said:

For the root bone, happy to change things around but let's look at what's right.

 

Always happy to do that :)

 

45 minutes ago, Bad Dog said:

Standard skeletons have a "Root" bone underneath this top-level node and that's what I made root.

 

That's what's been doing my head in. I don't see a bone called "Root" or "Root [NPC Root]" or what have you. I've tried pasting one in from Anton's dummy blend file, but I'm by no means that the result is aligned properly.

 

47 minutes ago, Bad Dog said:

This results in the objects kinda being hidden under the armature in the outline.

 

Yeah, I noticed there were some unexpected things there. Probably why it too me so long to realize it was an armature.

 

 

48 minutes ago, Bad Dog said:

I could link the objects directly to the collection, which would make them more visible in the outline. Let me know if that addresses the issues you're seeing.

 

OK, cool. Thanks :)

 

Link to comment
3 hours ago, DocClox said:

I don't see a bone called "Root" or "Root [NPC Root]" or what have you

That ain't right. You should always get a chain of bones all the way back to the root--as long as the bones in the nif are bones I recognize from the reference skeleton. If you're using an extended skeleton they might not be? 

Link to comment

This is what I get:

 

image.png

 

There's a node there called "Scene Root", but it's not actually a bone, or at least doesn't report as one when I iterate over the armature.

 

22 minutes ago, Bad Dog said:

If you're using an extended skeleton they might not be? 

 

The skeleton is just what nifly finds in Fusion Girl. Which does admittedly have some non-standard bones.

 

I can test this. Give me a tick.

 

 

Link to comment

OK. This is the vanilla female body, complete with no nipples and an some ugly seams. It's skeleton is presumably as vanilla as it gets

 

image.png

 

Still no root bone.

 

There isn't something I should be doing at my end to specify a reference skeleton, is there. Like maybe you told me and I wasn't paying full attention or something?

Link to comment

Ya, okay, so I somehow skipped the root bone on the FO4 skeleton. It should be right above the COM bone.

 

As for what you're seeing:

  1. FemaleBody.nif - collection, named after the file
  2. BASE Meshes/Actor/Character... - Blender Armature object, named after the top-level node in the file. That's the stupid name they gave it. In other files this is "Scene Root".
  3. Pose - Armature cruft, I think if you define a bunch of poses they go under here
  4. BASE Meshes/Actor/Character... again - This is the data block for the armature. All interesting Blender objects keep the important stuff in a data block that is a child of the blender object. Meshes often have the same name as their parent object and that's what I did here.
  5. COM - This is the top-level bone of your skeleton. Like I say, it should be "Root" but I left that out somehow.
Link to comment

X0.0.24 is up with the ability to import skeletons.

 

Have a look and tell me what you think. Issue here is, I don't know what's a bone and what isn't. If it's a NiNode and there's no actual mesh in the nif, I just import it. So there may be a few extra "bones" up at the root level. I could filter them out by checking against the reference skeleton, but I think part of the point is to import unknown bones. (If you're importing an extended skeleton.) So I left it like this until we come up with something better.

 

Edit: And I got the root bone into the FO4 skeleton.

Link to comment

Fantastic. I'll give that a whirl right now.

 

I know Anton had a lot of "ignore this bone" code in his original scripts, and I've never understood why, since I didn't see any matches for them. Maybe this is why.

 

Downloading :)

Link to comment

Updated it ok, but I couldn't seem to import anything. So I tried disabling and re-enabling the imported, only to find it wouldn't re-enable

 

image.png

 

image.png

 

I did a quick grep of your .py files , and there doesn't seem to be either a definition or an import for TripFile

 

Link to comment

Fukkit I keep forgetting anytime I add a file I have to add it to the release build by hand.

Link to comment

It was there but not updated so I'll have to figure out what TF the build process is doing. It's updated now--pull down the kit again and it should be ok.

Link to comment

I sawx the raiders outfits mod and installed it...

It's good, except we can't use the spieks one for female player... and we need a more sexy versions !

Link to comment

I've been hassling with Skyrim partitions and FO4 segments. Partitions are straightforward. Segments are whack-a-doodle. But I have something working that matches pretty closely to what you see in OS.

 

I'm going to build a kit for it and run with that all week. (On Furry Fallout modding. I haven't forgotten that's what I'm supposed to be doing.) If I don't see any issues after a few days, I'm call it a beta and make it publicly available.

 

There's more to be done with it, but I've covered the most important stuff, at least for the things I've been doing. Things I still don't have:

  • Shaders. Don't care, copying them around in nifskope is fine.
  • Vertex colors and alpha. Really should do these, but I don't use them much. 
  • Collisions. I'd like to do those.
  • Animated nifs. A lot of skyrim objects like the chests have animations built into the nif. Also I seem to remember there were a bunch of animated startup screens involving... dragons? It would be nice to be able to make those.
  • Real animations. I'm hoping DocClox has the answer here.

Really, I think that's the list.

Link to comment
6 hours ago, Bad Dog said:

I've been hassling with Skyrim partitions and FO4 segments. Partitions are straightforward. Segments are whack-a-doodle. But I have something working that matches pretty closely to what you see in OS.

I'm guessing you're doing vertex groups? Or is there some other way to do that?

 

Quote

(On Furry Fallout modding. I haven't forgotten that's what I'm supposed to be doing.)

Looking forward to seeing progress there, lol. :classic_shy:

 

Quote

There's more to be done with it, but I've covered the most important stuff, at least for the things I've been doing. Things I still don't have:

  • Shaders. Don't care, copying them around in nifskope is fine.

Still be nice to have them if possible, but I guess for Skyrim you can just copy the settings over from another existing Nif and for FO4 it's materials that take care of that in the first place. So as long as exported nifs end up with a proper base/generic shader property to paste the data on, it'd probably be okay.

 

Quote
  • Vertex colors and alpha. Really should do these, but I don't use them much.

Are those used anywhere relevant tho? I remember seeing vertex alpha used in some vanilla hairline/scalp meshes in Skyrim, but I don't think I've seen them in FO4 yet.

 

Quote
  • Collisions. I'd like to do those.

That'd be nice considering so far only Max can do those and I've had to reuse literally the exact same base collision for all my ground/inventory meshes, and doing collision for statics is not possible. Which sucks because for Skyrim you could just use NifSkope itself for the former and ChunkMerge for the latter.

 

Quote
  • Also I seem to remember there were a bunch of animated startup screens involving... dragons? It would be nice to be able to make those.

That would be @MadMansGun's work on animated load screens. Mostly with dragons, but he also made a handful Selachii ones for the race mod.

 

I don't think Skyrim load screens were ever meant to have animation in them, but they still worked, so FO4 might be the same.

Link to comment

I think the Skyrim animated load screens did it by making a video clip and then wrapping it in swf and using it as a replacement for the loading menu. That's going by the animated wench loading screen anyway.

 

You could try disassembling one of those.  There'll be a bit more to it than just replacing the menu with a swf video file I imagine, but it might be possible to change the image resource and recompile. It's not something I ever tried, mainly because Scaleform had a rep for being really tricky unless you used the right version of Adobe flash, but it's possible that we know a bit more about the format than we did back then.

 

[edit]

 

 

On the other hand, it could be exactly that simple. I took a quick peek and there's nothing there but the movie, that I can see.

 

image.png

 

According to the mod author, you should be able to make new animated loading screens by using the replace button to change the images.

 

That said, I can't get the SE version of the wench screen to work, so how applicable it will be to Fo4 is anyone's guess.

 

Link to comment

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use