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
171 stars 16 forks source link

Feature Request: Collision Export #85

Closed 4verage closed 1 year ago

4verage commented 2 years ago

Thank you so much for the great work! This addon works so much easier than the Niftools addon and it actually WORKS without hours of tweaking.

The primary reason I have been working with Niftools is because it has a method to setup a collision object and export it to a Physics collision object in the NIF so my models function as intended. (At least that's the idea - I cannot get it to work.)

Can you please look into implementing this same feature so our custom meshes behave properly once put in the game instead of having the need to try to find "like-shaped / like-sized" items in-game and importing/exporting their physics data? This doesn't work in all cases.

Thanks!

mindflvx commented 2 years ago

By Niftools, do you mean using ChunkMerge or something else? It does work, and while using it does obviously add another step to the workflow so it's not an optimal solution, it's not too bad once you get familiar with it and manage to set up your templates (you can recycle them), it's a quick thing to do and makes it possible to use 100% custom shapes while waiting for a better solution.

4verage commented 2 years ago

Niftools is another import/export addon for Blender. If you properly add a Collision object to your scene it is supposed to export everything in one swoop. (I haven't been successful, though - so I was hoping PyNifly would be my hero!)

http://niftools.sourceforge.net/wiki/Blender/Collision

I did read-up on ChunkMerge yesterday. I saw some posts regarding Skyrim, but nothing on Fallout 4 anywhere. Nonetheless, I did some meager searching, but I could not find a resource to download ChunkMerge anywhere that was obvious. Is there a good site for this somewhere or the developer's page? I did find a Git for it, but it was just source code and nothing compiled.

I wouldn't mind the extra step at all! Creating some of these items in-game is already plenty of steps in Creation Kit. As long as it works, I'll be happy! My son came up with all of these ideas for stuff he wanted in the game and I am just trying to get it done for his birthday.

Again, thanks for any and all help!

mindflvx commented 2 years ago

Sounds great! Anything for the kids here, too.

There's a good write-up on how to use Chunkmerge here:

http://niftools.sourceforge.net/wiki/Skyrim/Adding_Collision_Mesh_using_ChunkMerge

I can verify that the instructions are still legit but you do need to follow them very carefully. It all seems a bit intimidating at first read but it's really pretty simple once you get the grasp of it. What's most important is to have the required nifs (target, collision and template) prepared correctly, and after that it's more or less just a matter of clicking a button. Make sure to make a backup of your template and the target before doing that, though, since you can (and should) indeed recycle them.

Since you're modding for Fallout 4 the process is slightly more involved since Chunkmerge only support Skyrim. I myself need to convert the resulting meshes from Skyrim to SSE and in your case I believe it should be possible to convert them to Fallout 4 as well, possibly using FNV as an interim step.

But of course, being able to export the collision directly from Blender would be wonderful.

4verage commented 2 years ago

@mindflvx thanks for the great link!

The documentation links to the author for ChunkMerge (skyfox69), which is where I found the un-compiled source code previously with no direct download for the compiled runnable software.

However, I did notice that he also offers the NIF scripts to import/export NIF files. I suppose - if one was so inclined - he/she/I could use this to develop our own method to export and re-compile the NIF meshes with a collision object, since we have access to the source code for both the NIF export and ChunkMerge.

Just an idea if the Nifly feature request doesn't come to fruition. :)

Guess I am going to start researching on how to compile the available source code so I can try out ChunkMerge.

Thanks for all of the wonderful help! I'll update if I come up with anything.

mindflvx commented 2 years ago

Sorry, only now realized that it seems to be impossible to find compiled binaries for Chunkmerge anymore.

Here's v0.1.55.0595: https://drive.google.com/file/d/1vyCEzWzohKx0el7G3odsDMeTXI1G35on

4verage commented 2 years ago

@mindflvx you have been so my hero for all of this! I've got it downloaded and I'll try it out tonight when we get back to work.

That was my finding as well. Like I said, it was a meager attempt at searching, though. As popular as it seems in the modding community, you would think there would be more floating around!

BadDogSkyrim commented 2 years ago

I would love to do collisions. I don't know how hard it is or if the nifly code has support for them already. I also don't know what the FO4 situation is--they do a lot of the physics by compiling it into magic buffers, and if that's the case I have no clue.

I'm finishing up a piece on my FFO mod now, and when that's done I'll have a look at collisions.

4verage commented 2 years ago

@BadDogSkyrim I'm honored to have you comment directly on my request! I cannot say that I understand the collision situation with FO4 either - else, I may have made it further in figuring this out by now.

I did notice with exporting some of the existing FO4 models that turning on collisions in NifSkope doesn't actually show anything. I was kind of disappointed by that!

I did read through their nif.xml and learned a lot about the Havok information, but this tells me absolutely nothing about how it should be assembled.

Let me know if there is anything I can do to help or contribute! Thanks for at least considering this!

4verage commented 2 years ago

@mindflvx I have not been very successful with figuring out ChunkMerge. I am fairly sure I have the xml file setup correctly. I have a couple of template scenes ready. I have my model NIF and Collision stripped down to their bare minimums. However, when I plug it all into ChunkMerge it starts the process and then the program just closes. No errors thrown and there is no log file to weigh it against to find out where the failure might be occurring.

I have followed a few different tutorials for ChunkMerge I have found online - each person seems to have their own method of performing this function. I am not sure if it is a FO4 issue or if it is just my pure ineptitude. Despite my searches, I am not finding much information regarding good collision manufacturing directly related to Fallout 4. It is kind of depressing.

There must be a way for we without the resources to own 3D Studio MAX to generate this collision data.

@BadDogSkyrim - That might be something else to assist in development of this. From what I can tell those who develop NIF mesh data in 3D Studio have a plug-in/addon that allows them to insert collision data directly in the mesh data. Perhaps if we can reverse-engineer what that addon does it can be applied in Blender?

I have no clue if that is even feasible, but just another possible resource. Thanks!

mindflvx commented 2 years ago

@4verage That's a bummer. ChunkMerge can be very finicky to use so I'm not overly surprised.

By your description it sounds like Chunkmerge plain crashes. Have you tried with a very simple collision like for example a box to rule out any issues with your mesh data?

Secondly, I assume you are working with Skyrim LE nifs? I haven't tried with anything else but I do know that for example SSE is not supported. So with Skyrim LE nifs, you will be working with NiTriShapes and NiTriShapeDatas instead of anything else, like for example BSTriShape for SSE.

As for the files you need to input, the template can contain only BSFadeNode, BSXFlags and one bhkCollisionObject that you want to use as a base. It's probably best if it comes directly from Skyrim LE but others might work too after a conversion. The collision file is the collision mesh you've exported from Blender in Skyrim LE format. And finally, you need the destination file ("Nif-File (Skyrim") which is the target nif where the collision will be added; it's best to keep this very simple so only BSFadeNode and and NiTriShape with NiTriShapeData will suffice.

4verage commented 2 years ago

@mindflvx Excellent information!

Again, no, FO4 uses BS nodes, not NiTriShapes. My collision mesh IS a simple box! (Object I'm building is a sign, so pretty simple.)

I was not aware of the LE/SSE compatibility issue. I do have the conversion tool, so I can try converting both NIF files to LE and try ChunkMerge again. I will do this tonight after work and dinner and I'll update.

Regards!

4verage commented 1 year ago

@BadDogSkyrim

Howdy! I just started getting to a point where I can start working on my MOD again. Before I jumped in I wanted to see if this was ever looked into or added into your great program? At this point we have so many different custom meshes that it would not make sense for me to even start without being able to produce custom collisions as well.

If not, does anyone know if anything has been developed out there that may help with this now?

Sorry, this has been on the back-burner for quite some time now. My son wanted this done for his birthday, but I procrastinated a bit too much. ...maybe next birthday.

BadDogSkyrim commented 1 year ago

You can use the nifly tools import/exporter. I think they do collisions but I don't know the details. You can also go the 3DS Max route.

I did look at this and still have interest in doing it, but it's a heavy lift. Generating a MOPP tree is significant work and the documentation on it is sketchy. Somebody might have written up the algorithm but right now it looks like I have to re-create it from scratch.

BadDogSkyrim commented 1 year ago

Turns out there's a tool called Elrich that ships with FO4 and cleans up nifs for FO4. One of the things it does is convert collisions into FO4's compiled format.

Since you can build up complex collision shapes with the collision list node, that means you can make a complex collision in Blender and get it into FO4 even without MOPP collisions.

I added a note to the wiki page on collisions with links to some references.