Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading and writing external mesh data (starfield), writing untested #41

Merged
merged 4 commits into from
Jun 9, 2024

Conversation

Caliente8
Copy link
Contributor

Changes to nifly library to enable import of starfield nifs that use BSGeometry nodes referencing external mesh files.

import is working -- currently scaling mesh vertices by a factor of 64 for them to be appropriately sized for outfit studio.
export is coded, but untested.

@hexabits
Copy link

hexabits commented Oct 1, 2023

@Caliente8 Why 64x? In my comparisons previous games are 32x larger not 64x.

@Caliente8
Copy link
Contributor Author

@Caliente8 Why 64x? In my comparisons previous games are 32x larger not 64x.

In Outfit Studio, it seems that 64x gave a similar size to previous bodies. Honestly, that's a magic number that needs to go away, and the scale should be applied in the library consumer. Thanks for pointing it out, I'll fix that

@hexabits
Copy link

hexabits commented Oct 1, 2023

@Caliente8 Ah ok, also I think ousni already told you this but for posterity/clarity:

I haven't audited the commits so in case you haven't thought about it, the float values will have to be normalized to -1.0, 1.0 in any component and then the scale of the .mesh adjusted by the normalization factor. Or -32.0, 32.0 if you keep the scale in the lib.

So if you keep the .mesh scale separately for transforming in the renderer, and keep the vertices untransformed, then if some vertex component were increased to -64.0 or 64.0 (or -2.0/2.0 if scale is removed from lib), you'd double the scale value associated with the .mesh and then halve all the vertices to keep the SNORM in range after it's packed again.

@hexabits
Copy link

hexabits commented Oct 1, 2023

Also my 32.0x came from comparing files that exist in both games, maybe this comparison is flawed if they also changed their true scale by 2.0x for display in the CK.

image
image

@Caliente8
Copy link
Contributor Author

@Caliente8 Ah ok, also I think ousni already told you this but for posterity/clarity:

I haven't audited the commits so in case you haven't thought about it, the float values will have to be normalized to -1.0, 1.0 in any component and then the scale of the .mesh adjusted by the normalization factor. Or -32.0, 32.0 if you keep the scale in the lib.

So if you keep the .mesh scale separately for transforming in the renderer, and keep the vertices untransformed, then if some vertex component were increased to -64.0 or 64.0 (or -2.0/2.0 if scale is removed from lib), you'd double the scale value associated with the .mesh and then halve all the vertices to keep the SNORM in range after it's packed again.

Right, should be doing the normalization properly -- normalizing uint16_t components to float [0..1] and multiplying by mesh data precision scale value. The 64 (now probably 70) is additional scale on top of that.

…evious games (69.969), plus fix a crash when loading non-skinned meshes
@ousnius ousnius merged commit 2aea8a9 into ousnius:main Jun 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants