Nullpointer when loading 3ds models since upgrade to nightly build from yesterda

this is the exception i get:

Caused by: java.lang.NullPointerException
   at com.jme.util.TextureManager.loadImage(TextureManager.java:430)
   at com.jme.util.TextureManager.loadImage(TextureManager.java:424)
   at com.jme.util.TextureManager.loadTexture(TextureManager.java:327)
   at com.jme.util.TextureManager.loadTexture(TextureManager.java:296)
   at com.jme.image.Texture.read(Texture.java:977)



in 0.11, i used texturekey.setoverrideLocation to tell the 3ds importer where the textures are (usually the same directory as the 3ds file)

in 1.0rc1, i get the exception above when executing this code:

 private static Spatial asJME(final FormatConverter p_conv,
     final String p_file,
     final Image p_image,
     final DisplaySystem p_display, final int p_cullstate) throws IOException {
    FileInputStream l_stream = null;
    final ByteArrayOutputStream l_baos = new ByteArrayOutputStream();
    try {
      l_stream = new FileInputStream(Utils.getFile(p_file));
      p_conv.convert(l_stream, l_baos);
    } finally {
      if (l_stream != null) {
        l_stream.close();
      }
    }
    final Node l_node = (Node) new BinaryImporter().load(l_baos.toByteArray());
    if (p_image != null) {
      final TextureState ts = p_display.getRenderer().createTextureState();
      ts.setEnabled(true);
      ts.setTexture(
         TextureManager.loadTexture(
            p_image,
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            true));
      l_node.setRenderState(ts);
    }
    final CullState cs = p_display.getRenderer().createCullState();
    cs.setCullMode(p_cullstate);
    l_node.setRenderState(cs);
    return l_node;
  }



notloaded.png is gone. what to do?

also, importing 3ds & ms3d-models seems to be broken for me. all textures are missing. loading cached jme-binaries works.

I'll get rid of the NPE possibility, but you should note that this means no texturestate has been created yet and thus no default texture has been loaded.  This would indicate you have not created a renderer (otherwise the default texturestate would be created) so loading textures could probably have issues as well.

npe: there was no "notloaded.png" anywhere, so when creating a texturestate, the defaulttexture stayed null.

I'm getting a NPE as well with the latest (just updated).  Here's my code:



    URL model = ModelProto.class.getClassLoader().getResource("resources/U-6.3DS");
    FormatConverter converter = new MaxToJme();

    ByteArrayOutputStream BO = new ByteArrayOutputStream();
    converter.convert(model.openStream(), BO);
    Node boat = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));


It's pretty much the same thing the HelloModeling tutorial is doing.  Quite a few nodes were successfully loaded before it hit this.  Another interesting tidbit that's probably related is that it appears some of the texture file names from inside the 3ds file have been chopped off to 8 chars.  Check this out:


Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: OHBOYOBE.DDS
Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: OHBOYOBE.DDS
Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: HYDROPAR.DDS
Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: OHBOYOBE.DDS
Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: WINDSHIE.DDS
Oct 5, 2007 3:53:02 PM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: PROPBLAD.DDS


Those file names are longer than that.

Here's the error at the end:


java.lang.NullPointerException
at java.net.URLDecoder.decode(URLDecoder.java:119)
at com.jme.util.TextureKey.read(TextureKey.java:137)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryInputCapsule.readSavable(BinaryInputCapsule.java:431)
at com.jme.image.Texture.read(Texture.java:976)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:457)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:445)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:549)
at com.jme.scene.state.TextureState.read(TextureState.java:736)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:457)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:445)
at com.jme.scene.SceneElement.read(SceneElement.java:853)
at com.jme.scene.Spatial.read(Spatial.java:822)
at com.jme.scene.Geometry.read(Geometry.java:841)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:457)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:445)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:549)
at com.jme.scene.Node.read(Node.java:649)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:457)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:445)
at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:549)
at com.jme.scene.Node.read(Node.java:649)
at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:247)
at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:156)
at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:86)
at ModelProto.simpleInitGame(ModelProto.java:44)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:503)
at com.jme.app.BaseGame.start(BaseGame.java:69)
at ModelProto.main(ModelProto.java:20)


TextureKey.read() passed a null string into URLDecoder.

Note that I'm new to jMonkey and I've never tried to load models before.  I'm wondering if there is something stupid that I'm doing.  I'll dig deeper and see exactly what's going on inside there.

putting a null check around the ResourceLocatorTool call in textureKey.read() fixes it.  Sort of.  It leaves the location null and loads the default texture.  I'm thinking something may be up with the model file.  Some things are out of place.

HamsterofDeath said:

npe: there was no "notloaded.png" anywhere, so when creating a texturestate, the defaulttexture stayed null.



Hmm, notloaded.png is in com.jme.scene.state (where TextureState is).  Sounds like the nightly build is not properly copying some files.  I suggest using CVS if possible.
bwarren said:

putting a null check around the ResourceLocatorTool call in textureKey.read() fixes it.  Sort of.  It leaves the location null and loads the default texture.  I'm thinking something may be up with the model file.  Some things are out of place.


Would it be at all possible to post this 3ds file?
theprism said:

the .png file is in the jme.jar from the nightly build


Great, then if he is truly using the new nighty builds, this should not be a problem.
renanse said:

HamsterofDeath said:

npe: there was no "notloaded.png" anywhere, so when creating a texturestate, the defaulttexture stayed null.



Hmm, notloaded.png is in com.jme.scene.state (where TextureState is). Sounds like the nightly build is not properly copying some files. I suggest using CVS if possible.


the .png file is in the jme.jar from the nightly build