Load .obj(blender) in jme nullpointerException

JME WIki Example:



Does anyone know what cause there is for this NullP?


INFO: setup fbo tex with id 3: 1.152,216
java.lang.NullPointerException
   at jmetest.effects.water.TestObjJmeWrite.simpleInitGame(TestObjJmeWrite.java:31)
   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
   at com.jme.app.BaseGame.start(BaseGame.java:74)
   at jmetest.effects.water.TestObjJmeWrite.main(TestObjJmeWrite.java:22)
1-mrt-2010 16:15:48 com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
1-mrt-2010 16:15:48 com.jme.app.BaseGame start
INFO: Application ending.



Line 31 is:

         converter.setProperty("mtllib", objFile);





package jmetest.effects.water;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;

import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.app.AbstractGame.ConfigShowMode;
import com.jme.bounding.BoundingSphere;
import com.jme.input.FirstPersonHandler;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.TriMesh;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.ObjToJme;

public class TestObjJmeWrite extends SimpleGame {

   public static void main(String[] args) {
      TestObjJmeWrite app = new TestObjJmeWrite();
      app.setConfigShowMode(ConfigShowMode.NeverShow);
      app.start();
   }

   protected void simpleInitGame() {

      
      ObjToJme converter = new ObjToJme();
      try {
         URL objFile = TestObjJmeWrite.class.getClassLoader().getResource("VIKINGBOAT.obj");
         converter.setProperty("mtllib", objFile);
            converter.setProperty("texdir",objFile);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
System.out.println("Starting to convert .obj to .jme");
converter.convert(objFile.openStream(), BO);
            //load as a TriMesh if single object
TriMesh model = (TriMesh) BinaryImporter.getInstance().load(
      new ByteArrayInputStream(BO.toByteArray()));
            //load as a node if multiple objects
            //Node model=(Node)BinaryImporter.getInstance().load(
            //                new ByteArrayInputStream(BO.toByteArray()));
model.setModelBound(new BoundingSphere());
model.updateModelBound();
rootNode.attachChild(model);

      }catch (Exception e) {
            e.printStackTrace();
         }
         



      
      display.getRenderer().setBackgroundColor(ColorRGBA.gray);
      input = new FirstPersonHandler(cam, 3, 1);

      //needed for specular lighting(reflective light)
      lightState.setSeparateSpecular(true);
   
   }
}

normen said:

is your VIKINGBOAT.obj really in the the classpath? If its a file in the system, try

URL objFile = new File("VIKINGBOAT.obj").toURL();




Using toURL from a file is actually deprecated now...  the 'proper'  method is

URL objFile = new File("MyAwesomeVikingBoat.obj").toURI().toURL();


Also take note that my viking boat is awesome, where yours is not  :P

URL objFile = TestObjJmeWrite.class.getClassLoader().getResource("VIKINGBOAT.obj");



is your VIKINGBOAT.obj really in the the classpath? If its a file in the system, try

URL objFile = new File("VIKINGBOAT.obj").toURL();



Cheers,
Normen