ResourceLocatorTool WARNUNG: Unable to locate:

I have don't get whats wrong:

I get several of those warnings when loading a texture for a model, but everything seems to be ok??

I checked it several times now, but I cannot find the problem

Why does he wrote "Unable to locate" also there is a file  /home/tscharn/workspace/jglest/resources/evergreen/models/texture_statue.tg for example ?? And why does everything work then ? ?



13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_statue.tga
13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_bush.tga
13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_grass.tga
13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_flowers.tga
13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_swordman_statue.tga
13.12.2009 01:23:06 com.jme.util.resource.ResourceLocatorTool locateResource
WARNUNG: Unable to locate: /home/tscharn/workspace/jglest/resources/evergreen/models/texture_statue.tga

I suppose you're giving absolute paths while the ResourceLocator expects class-paths…

Thats right, but my resources are not in the classpath. I have to give an URL to locate my textures like this:


FormatConverter converter = new GxmlToJme();
         converter.setProperty(
               "texturedir", file.getParentFile().toURI().toURL());



where GxmlToJme is a converter for the glest(xml) model format.  I wrote this converter and it works similar to the Obj converter ( and I also looked at the  md3 converter for the animations ).

I have to load/clone lots of objects( trees and so on ) and I think this loading takes very long due to these huge amount of warning outputs.

This is the part where the texture is loadd in GxmlToJme

   private TextureState setupTexture(GMesh gmesh, int i)
   {
      try
      {
         TextureState ts;
         URL texdir = (URL) getProperty("texturedir");
         URL texurl = null;
         if (texdir != null)
         {
            //System.out.println("lade von "+texdir+gmesh.getTexturePaths().get(i));
            texurl = new URL(texdir+gmesh.getTexturePaths().get(i));
            //System.out.println("texurl="+texurl.getPath());
         }
         else
         {
            texurl = new File(gmesh.getTexturePaths().get(i)).toURI().toURL();
            //System.out.println("texurl2="+texurl.getPath());
         }
         TextureKey tkey = new TextureKey(texurl, true,
               TextureManager.COMPRESS_BY_DEFAULT
                     ? Image.Format.Guess
                     : Image.Format.GuessNoCompression);
         Texture t = new Texture2D();
         t.setAnisotropicFilterPercent(0.0f);
         t.setMinificationFilter(Texture.MinificationFilter.BilinearNearestMipMap);
         t.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
         t.setTextureKey(tkey);
         t.setWrap(Texture.WrapMode.Repeat);
         t.setImageLocation(texurl.toString());
        

         ts = renderer.createTextureState();
         ts.setTexture(t);
         ts.setEnabled(true);
         return ts;
      }
      catch (MalformedURLException e)
      {
         e.printStackTrace();
      }
      return null;
   }



Create your own ResourceLocator and add it with the ResourceLocatorTool like this:


ResourceLocator myLocator= new ResourceLocator(){
            public URL locateResource(String resourceName){
                //GET THE URL HERE
            }
        });

ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, myLocator);



Thanks, this works!