XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Thu Oct 19, 2017 3:24 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Loading texture files in Noesis (possible bug?)
PostPosted: Sun Jun 12, 2016 1:25 am 
Offline
n00b

Joined: Sun Oct 05, 2014 12:08 am
Posts: 12
Has thanked: 22 times
Have thanks: 2 times

So I just learned about the method loadExternalTex, which according to Noesis readme file: "returns a NoeTexture, or None if the texture could not be found." And for its arguments it says it accepts a string as "name/path of texture, without extension."

I'm not sure if I found a bug or something but the only way I can get this function to work is if the texture file is in the same folder as the main file registered with Noesis for previewing (usually a mesh file).

For example, if I'm using Noesis to load some model/mesh at "c:\dir1\dir2\polygon.mesh", and this model requires two textures which are located at "c:\dir1\dir2\tex1.dds", and "c:\dir1\dirA\dirB\tex2.dds",
  • The following call works and returns a NoeTexture object:
    rapi.loadExternalTex("c:\\dir1\\dir2\\tex1")
  • But the following call mysteriously fails and returns None:
    rapi.loadExternalTex("c:\\dir1\\dirA\\dirB\\tex2")

Both files exist, the only difference is that the latter is not in the same folder as the mesh file. If this function can only accept files in the same folder then why does it say it can accept a path in the readme file? Is this a bug or am I missing something here? Can somebody maybe double-check this?

Edit: I forgot to mention I'm of course using the latest version of Noesis (v4.177)

You can make the ads go away by registering



Last edited by errno on Sun Jun 12, 2016 10:36 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Loading texture files in Noesis (possible bug?)
PostPosted: Sun Jun 12, 2016 7:44 pm 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2433
Has thanked: 56 times
Have thanks: 1185 times
there is an example of using this correctly in my star wars scripts.
viewtopic.php?f=16&t=8714


Top
 Profile  
 
 Post subject: Re: Loading texture files in Noesis (possible bug?)
PostPosted: Sun Jun 12, 2016 10:46 pm 
Offline
n00b

Joined: Sun Oct 05, 2014 12:08 am
Posts: 12
Has thanked: 22 times
Have thanks: 2 times
That's a great example, which I might have to use if loadExternalTex is in fact broken (as far as I know, loadExternalTex was added to avoid having to parse texture file headers manually). If I'm correct, in that example you are parsing the texture's header to then construct your NoeTexture object? I was hoping I could avoid parsing the texture file's header by just using loadExternalTex. It works fantastic for textures in the same directory but I just can't figure out why it is failing to work with other paths.


Top
 Profile  
 
 Post subject: Re: Loading texture files in Noesis (possible bug?)
PostPosted: Mon Jun 13, 2016 8:18 pm 
Offline
n00b

Joined: Sun Oct 05, 2014 12:08 am
Posts: 12
Has thanked: 22 times
Have thanks: 2 times
I seem to have found a solution for this so I thought I would share it just in case someone else gets the same problem. Apparently loadExternalTex is picky with the path string it receives. I was constructing the path string using '\\' as the directory separator character, and then I was obtaining the absolute path by using os.path.abspath(texPath). I'm not sure which of the two was the problem but I got it to work by using '/' instead of '\\' (works fine under Windows OS's), and also stopped using absolute path and instead made relative paths. I think the latter was the problem.

So for example, if I'm using Noesis to load some model/mesh at "c:\dir1\dir2\polygon.mesh", and this model requires two textures which are located at "c:\dir1\dir2\tex1.dds", and "c:\dir1\dirA\dirB\tex2.dds", then the following calls will work and returns a NoeTexture object:
  • rapi.loadExternalTex("tex1")
  • rapi.loadExternalTex("../dirA/dirB/tex2")

Now back to trying to get my key-framed animations to work (sigh)


Top
 Profile  
 
 Post subject: Re: Loading texture files in Noesis (possible bug?)
PostPosted: Mon Jun 13, 2016 10:37 pm 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2433
Has thanked: 56 times
Have thanks: 1185 times
yeah you can see in the script
texName = texName.replace("\\","/")
also you can use load by handler

Code:
   def load_textureFile(self, texName):
      folderName = rapi.getDirForFilePath(rapi.getInputName())
      folderName = folderName.replace('\\', '/')
      folderName = (folderName + "../../../../")
      if (rapi.checkFileExists(folderName + texName)):
         texData = rapi.loadIntoByteArray(folderName + texName)
         texture = rapi.loadTexByHandler(texData, ".dds")
         texture.name = rapi.getExtensionlessName(rapi.getLocalFileName(texName))
         self.texList.append(texture)




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group