I am able to create and mount .mf files successfully (look here). I can even load models with textures applied to them from those multifiles (by that I mean the textures that are originally on the model when loaded). but whenever I try a direct call like loader.loadTexture(‘texture.png’) I get:
:gobj(error): Texture::read() - couldn’t read: images/texture.png
:gobj(error): Unable to read texture “images/texture.png” (using vfs) on texture_path .;/c/Panda3D-1.0.5b/etc/…;/c/Panda3D-1.0.5b/etc/…/models or model_path models;.;/c/Panda3D-1.0.5b/etc/…;/c/Panda3D-1.0.5b/etc/…/models
This then throws an error when I try to set a model with a texture that is really a None type object
File “C:\Panda3D-1.0.5b\pandac\NodePath.py”, line 11582, in setTexture
raise TypeError, 'Invalid argument 0, expected one of: <TextureStage.TextureStage> <Texture.Texture> ’
TypeError: Invalid argument 0, expected one of: <TextureStage.TextureStage> <Texture.Texture>
multify was used on the images folder with texture.png in that folder as well as a models folder containing .bam files.
no compression or encryption (no -z or -e options) were used when creating the .mf file. Just -c -f and -v. Everything worked fine on that end.
I have tried mounting the .mf file through a config variable and in code. Both had the same result.
I have also tried specifying texture-path images and model-path images in the config file. no help there either
the .mf file is in the same directory as the sample code I used. It seems to mount properly since I can load and display models from it.
Since the models load with textures, why can’t I load new textures directly? what am I missing?
Thank you for any help
There’s nothing magic about loading textures as opposed to models. Both operations go through the same low-level I/O calls, and either should work without troubles.
(1) Don’t mess with texture-path. Just use the model-path, since textures are searched first on the model-path anyway. I don’t even know why we have a texture-path variable; all it does is cause problems.
(2) Are you sure you’re referencing the texture with the correct case? The multifile is case-sensitive, whereas the Windows filesystem is not.
(3) Are you absolutely sure that’s the right pathname to the texture?
ok thanks, thats a good tip. maybe it should be renamed to loader-path and just keep it to one config variable (or does sound-path matter?). I have also tried using the current directory and referencing the images folder in the code ( loader.loadTexture(‘images/texture.png’) ) thats why the error I copied printed out the way it did. Again, no result.
I have typed and re-typed and copied the texture name directly to make sure that everything matches exactly. I will try again…
the path name I use is relative to the code if that matters. Mentioned above, I have tried using specified relative paths in the config file and tried using the current directory while referencing the relative path in the code.
so .py file and .mf file are in the same directory.
the .mf file contains 2 folders:
images which contains:
and models which contains:
I load the texture with loader.loadTexture(‘images/texture.png’)
in the config file and use:
Thanks for the help, maybe I am just doing the same dumb thing over and over and over again. I’ll stop looking at it for now and try fresh later.
oh, and now that you mention it, I think I remember at one point Josh Yelon took out the texture-path and I sent him and email saying “what happened to the texture path?” and he put it back in.
Hmm, well, still, loader.loadTexture() works fine for me, loading from a .mf file. Can you post your .mf file and a sample .py file that demonstrates the problem somewhere where I can download them?
Well, I tried it again and was able to load a texture through the texuture loader. However, the way I got it to work is not what I wanted to do. What I was doing wrong was creating the .mf file in a different location ( I made a copy of some of the art asset folders and placed them in a new directory), copied the .mf file back to the original directory, and mounted it from that location. It seems I have to create the .mf file in the directory that it will be mounted. Correct?
Ok, I think I got it. I am able to create and copy like I wanted. Not sure what I was doing wrong before, but thanks for the help.
OK, good to hear. It sounds like some of the paths within your .mf file may not have ended up where you expected them to be. For the record, you can list the complete contents of your .mf file with a command like:
mutify -tvf mymultifile.mf
Doing a sanity inspection like this can be useful to ensure that your texture is in the subdirectory within the mf file that you think it is.