ousnius / nifly Goto Github PK
View Code? Open in Web Editor NEWC++ NIF library for the Gamebryo/NetImmerse File Format
License: GNU General Public License v3.0
C++ NIF library for the Gamebryo/NetImmerse File Format
License: GNU General Public License v3.0
nif file version is 20.6.0.0, nifly check failed in NifFile::Load()
For OptimizeFor
and SSE NIF Optimizer, add a new option to find mismatching external emittance flags between BSXFlags and shaders and env map shader type without the env map shader flag.
See https://gitlab.com/G_ka/Cathedral_Assets_Optimizer/-/issues/116
As the title suggests, I'm having issues with the resulting nif file after running NifFile.Save(). I'm attempting to create a program which modifies a single header string and a few blocks in Fallout 4 nifs, but I'm stuck on the header.
From what I gather, the process for setting a header string is like so (please correct me if this is wrong):
nifly::NifFile nif;
nif.Load("some_nif.nif");
nif.GetHeader().SetStringById(some_id, some_string);
nif.Save("some_dst_nif.nif");
I've also tried applying save settings:
nifly::NifSaveOptions opts = {false, false};
nif.Save("some_dst_nif.nif", opts);
Note: In the actual code I use if/ofstreams, but strings are used here for brevity.
'some_dst_nif.nif' not only doesn't contain the updated string, but somewhere in NifFile.Save() the header is being modified (Debugging is proving difficult because a lot of vars, especially hdr, are optimized out despite compiling both the lib and my binary with -O0).
In my current test, the original Nif has 87 strings, and the target string has an ID of 13. While debugging, after executing nif.GetHeader().SetStringByID(13, "A_New_String");
, the header shows as having the correctly updated string in position 13 of the NiString vector.
However, after nif.Save("some_dst_nif.nif")
, the header in memory shows as having only 38 strings. The target string is moved to position 22 and contains the contents of the target string before SetStringById(). The remaining strings were reordered as well. This is confirmed by opening the file in NifSkope, which also shows only 38 strings and does not reflect the change to the target string.
I'm new to the nif format so there may be some nuance I'm missing, but shouldn't this work, or is this to be expected? Opening and saving this nif without modifying the string results in the same output. Am I doing something wrong?
I'll attach the input and output nifs here:
8Grids.zip
bulk convert nif static meshes to fbx?
Hey, I have a small thing to report:
For FO4, if you define a set of, say, 7 segments and assign all the tris to the 4th (so 5-7 are empty) then nifly will assign all those tris to the last segment, not the 4th.
Arguably, this is a case where if you do stupid things, stupid things happen. I found it because all the body parts in FO4 use the same segmentation scheme: 7 segments representing nothing, head, right arm, torso, left arm, right leg, left leg, in that order. So I just defined all the segments and assigned faces as needed. Some of the armors only needed a torso segment, leaving segments 5-7 empty. Took me quite a while to figure out what was going on.
I dug into the nifly code and the issue is below, in geometry.cpp, SetSegmentation(). The original code is commented out below. It was searching for the last filled part, but the trailing empty segments were confusing it. Capturing lastFilledPart during the first loop fixed the problem. (I can submit this as a pull req if you'd prefer, but I wasn't sure you'd even consider it a real bug.)
size_t lastFilledPart = 0;
for (int i = 0; i < static_cast<int>(triInds.size()); ++i)
while (triParts[triInds[i]] >= j) {
lastFilledPart = j;
partTriInds[j++] = i;
};
//for (size_t i = 0; i < partTriInds.size(); i++)
// if (partTriInds[i] > 0)
// lastFilledPart = i;
Hello!
I know Fallout 76 isn't fully supported as of now, but I did some testing with a modified version of PyNifly and found most models, skeletons, and etc seem to load perfectly. The only issue I've come across so far is that texture are not populated correctly it seems. I'd be willing to toss a PR your way if you could give me some pointers on where to get started. ๐
It works in Skyrim SE, it probably works in other games that use a NiSkinPartition too, it works in NifSkope, it works in the NifTools Blender NIF Plugin.
But it doesn't work properly in any program based on Nifly.
Almost all "Get/Set...ForShape" methods of NifFile class identify the shape by its pointer:
const std::vector<Vector3>* GetVertsForShape(NiShape* shape);
const std::vector<Vector3>* GetNormalsForShape(NiShape* shape);
and so on
But a couple of "Colors" methods go with the name of the shape instead:
const std::vector<Color4>* GetColorsForShape(const std::string& shapeName);
void SetColorsForShape(const std::string& shapeName, const std::vector<Color4>& colors);
And this is a bit confusing. I would suggest adding NiShape* shape
overloads of these two for consistency and predictability.
Hi,
I've been using this library in ParallaxGen (thank you by the way!).
In some people's Skyrim load order they have the SMIM mod which includes a mesh that has an invalid target on it (ie. when I try to open it in nifskope, do nothing, and save it, I get an error about that). The mesh in particular in SMIM if you wanted to take a look is meshes\traps\whiterundragontrap\whiterundragontrap01.nif
.
When this mesh goes through parallaxgen (and therefore nifly), it gets saved successfully with no issues. The result mesh instead of having an invalid target at that same block, it just has no target. This causes game crashes in Skyrim. Don't ask me why but an invalid link pointing to nothing seems to work, while removing that link causes crashes on that specific block.
So my question is, can I control that with nifly? ie. can I tell nifly to keep the invalid link in place? Or, is there a mechanism I can figure out if an invalid link exists in the original mesh through nifly? I don't think this a bug with nifly, it's an issue with the original mod.
I have sortblocks
set to true in this case.
Thank you!
This is more a question than an definite bug report or PR.
In OptimizeFor, shouldn't the normals, if they exist, be copied to the particleNorms before particleNorms is resized? Or is the intention that if the number of normals and vertices differ then all of the particleNorms are populated with <1, 0, 0>?
You can see what I mean on this branch, renngar@db550f2.
My expectation was that if there were more vertices than normals, the particleNorms would be extended using <1, 0, 0> and if there were fewer vertices, then normals would be copied to particleNorms, which would be truncated to match the length of vertices. I don't know if my assumption is correct or not, so I thought I would ask.
Hello!
When I'm building nifly DLL as a static library, it's size is 18 mb(in Release mode). Is this normal or am I doing something wrong?
I previously used cmake-gui to build the .sln project. This is my first time building dependencies on other libraries so I'd appreciate help with this.
Hey, I have made a fork of this for use as a git submodule in a separate repository that adds C# adaptation via SWIG. I want to use that SWIG repository to output a Nuget package in support of a planned Synthesis patcher that updates NIF files. I'd like to include a DLL built from my fork, and credit you, in my Nuget package. Is this OK? Thanks for the library.
NifFile::SetVertsForShape calls BSTriShape::Create if shape
is a BSTriShape and the size of verts
does not match the old number of vertices. And the first thing BSTriShape::Create does is flags = 14;
So in my case it resulted in the flags switching to 14 seemingly out of nowhere when I added a vertex here, deleted a vertex there in already existing files/shapes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.