3ds importing

Hi, I'm just the ordinary jMonkey newb, trying to import a model in the scene and it doesn't work… Don't think it's the model itself since I've also tried with bike.3ds from jmetest package and still nothing…

Here's my code, I'm basically at helloModelLoader tutorial trying to change it to import my own model, so far I've only been able to get Maggie in;


      String res = "com/jmedemos/3dm-Anita.3ds";

      URL model = HelloModelLoadingV2.class.getClassLoader().getResource(res);

       FormatConverter converter = new MaxToJme();

       converter.setProperty("mtllib", model); //Not so sure what happens if I remove this, the texture is in the 3ds anyways.

       ByteArrayOutputStream bo = new ByteArrayOutputStream();
       try {
          converter.convert(model.openStream(), bo); //NPE location.
          Node mymesh = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(bo.toByteArray()));
          //micsorarea meshului
          mymesh.setLocalScale(.1f);
          mymesh.setModelBound(new BoundingSphere());
          mymesh.updateModelBound();
          //rootnode
          rootNode.attachChild(mymesh);
       } catch (IOException e) {
              logger.logp(Level.SEVERE, this.getClass().toString(),"simpleInitGame()", "Exception", e);
               System.exit(0);
       }


It gives NPE pointing at the line first line below try "converter.convert(model.openStream()...";

Thanks in advance!!
Arbaces

Hello Arbaces


converter.convert(model.openStream(), bo); //NPE location.


So the problem is that model is null, and you can't open a stream on a nothing.

URL model = HelloModelLoadingV2.class.getClassLoader().getResource(res);


..and that's the line that is causing model to be null.

Make sure the 3ds file is actually at the location you are specifying.

If you are still stuck for inspiration then you can try replacing the above line with this one instead:

URL model = getClass().getResource( "/com/jmedemos/3dm-Anita.3ds" );


Thanks m_s_h!! :slight_smile: Had it solved in the meantime, managed to load the jME bike.3ds, my model I think was bugged or something, though I could load it in 3ds Max without problems, I can't find any other explanation for it not loading, the path was right and it was decently low-poly  :expressionless: