Skip to content
New issue

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

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

Already on GitHub? # to your account

NIF Import Embedded Texture Limit #510

Closed
7 tasks
CCrashCup opened this issue Apr 15, 2022 · 1 comment
Closed
7 tasks

NIF Import Embedded Texture Limit #510

CCrashCup opened this issue Apr 15, 2022 · 1 comment
Assignees
Labels
Bug Issue with specific functionality not working as intended but overall plugin is working.

Comments

@CCrashCup
Copy link

CCrashCup commented Apr 15, 2022

@niftools/blender-niftools-addon-reviewer -

Before creating a new issue, ensure that

  • Read the user documentation.
  • Check that the issue hasn't already been reported.
  • Read through the list of Helpful resources links on the right-hand side.
  • Talk with the developers to ensure its a valid issue

The issue will get closed off immediately as invalid if

  • Looking for support where the forums, chat or documentation is more appropriate.
  • Goes off topic, loses focus or turns into a discussion.
  • Removing parts of the template the issue.

Fill out the template below to the best of your ability, including .blend files, nifs, logs; help us to help you.

Issue Overview

Importing NIF files with the "Use Embedded Texture" Option checked. When the image files created exceeds 999, the import does not handle it.

Version Information

Blender Niftools Addon Version Info

All known versions.

Blender Version Info

All versions the importer works in.

Platform information

Windows 10 x64, but all versions would be the same result.

Context

I know it is a low percentage occurrence, but there is no valid reason to restrict the file names to a 3 digit sequence number.

Steps to Reproduce

Import a NIF file with more than 500 embedded textures.
Check the "Use Embedded Texture" import option.
#.

Expected Result

Create DDS files with names from image0000.dds to image1001.dds.

Actual Result

Creates DDS files with names from image000.dds to image999.dds. Does not create DDS files for any of the files beyond the current limit.

Possible Fix

Code change to two lines in the file "io_scene_niftools\modules\nif_import\property\texture\loader.py" commented below.

def generate_image_name():
    """Find a file name (but avoid overwriting)"""
    n = 0
    while n < 10000:                                                                          # Up from 1000
        fn = "image{:0>4d}.dds".format(n)                                                     # Up from 3 digits
        tex = os.path.join(os.path.dirname(NifOp.props.filepath), fn)
        if not os.path.exists(tex):
            break
        n += 1
    return fn, tex

Screenshot

[If relevant, include a screenshot]

Logs and Files

[Provide logs file generated during the error as well as the blend and nif files are related to the issue]

Info Bar Output

[Output from the Info View, available at top of Blender viewport, drag to expand]

Console Output

[Set the logging level to 'Debug' and attach the output of the console. Enable via Window -> Toggle Console]

Blend File

[Attach the blend file if the issue is reproducible]

Nif File

[Attach input or output files, samples of what the expected output should be and reproducing the issue]

Similar Known Issues

[Reference any known issues - https://github.com/niftools/blender_niftools_addon/issues]

Additional Information

I do not know why two image files get created for each embedded texture, one is the actual diffuse texture, the other is zero bytes long and is used as an "Overlay". I decided not to address that, and went instead for the simple fix of increasing the limit, since that creates no adverse effect on the code. The same number of iterations will be executed regardless of the limit.

@CCrashCup CCrashCup added the Bug Issue with specific functionality not working as intended but overall plugin is working. label Apr 15, 2022
@HENDRIX-ZT2
Copy link
Contributor

grafik

grafik

Embedded textures now check for proper file name before using generated file name.

HENDRIX-ZT2 added a commit to HENDRIX-ZT2/blender_niftools_addon that referenced this issue May 26, 2022
- use file name instead of generated name if possible
- only extract once per run
- fix too long value error for big images
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Issue with specific functionality not working as intended but overall plugin is working.
Projects
None yet
Development

No branches or pull requests

3 participants