Forum

Author Topic: Application automatically change texture file path when try to import texture  (Read 1119 times)

linshuh

  • Newbie
  • *
  • Posts: 7
    • View Profile
Hi There,
When I try to import texture by
Code: [Select]
texture_absolute_path = '/Users/linshu/Desktop/texture.png'
chunk.model.loadTexture(texture_absolute_path)

I got OSError below
Quote
OSError: Can't open file: No such file or directory (2): /Users/linshu/Desktop/texture1.png
However, as you can see from what I defined before, my file name is 'texture.png' instead of 'texture1.png'. There is an extra '1' at the end.


Furthermore, when I try to use interactive tool, (i.e. GUI) to import the texture, I got the same error.
What I do:
1) select a certain chunk
2) File -> Import -> Import Texture

The difference between two is:
When I run the code with Python, program exit when error occurs.
When I import with GUI, the texture is still applied on mesh even though OSError occurred.
« Last Edit: October 22, 2020, 04:49:50 AM by linshuh »

James

  • Hero Member
  • *****
  • Posts: 736
    • View Profile
This suggests it is expecting to load a multipage texture file.

texture.png is the first page and texture1.png is the second. It may even be expecting more pages after that. You can check in the GUI by going to Tools->Mesh->View Mesh UVs and looking at the page numbers in the bottom left.

But I've had a look through the API documentation and I can't find any good way to determine how many texture pages a model has, other than by specifying it at the point of building it.

A bad way that I may have found was that each face of the model contains a reference to the texture page (tex_index) for that face, so if you loop through each face you could look for the max tex_index to get the count, but that won't help if all the faces relating to 'higher' page numbers have been removed from the model, which may be what has happened in your case, and it won't help if you just don't have the texture page files to load anyway!
« Last Edit: October 22, 2020, 01:26:21 PM by James »