3ds Model loading problem

hi guys





i tried to lad a 3ds model file just like in the tutorial but i always get the following error:



java.lang.NullPointerException

        at spaceshooter.Main.simpleInitGame(Main.java:54)

        at com.jme.app.BaseSimpleGame.initGame(Unknown Source)

        at com.jme.app.BaseGame.start(Unknown Source)

        at spaceshooter.Main.main(Main.java:33)





thats the following line:

conv.convert(new BufferedInputStream(maxFile.openStream()),BO);



i also tested if the file exists and is reachable and it is.





Code:





package spaceshooter;



import com.jme.app.SimpleGame;

import com.jmex.model.XMLparser.Converters.FormatConverter;

import com.jmex.model.XMLparser.BinaryToXML;

import com.jme.scene.Node;

import com.jmex.model.XMLparser.Converters.MaxToJme;

import com.jmex.model.XMLparser.JmeBinaryReader;



import com.jme.util.LoggingSystem;

import java.net.;



import java.io.
;

import java.util.logging.Level;





class Main extends SimpleGame {

    public static void main(String[] args) {

          Main app = new Main();

          app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);

          LoggingSystem.getLogger().setLevel(Level.OFF);

          app.start();

    }

    protected void simpleInitGame()

    {

        System.out.println("bam!");



        // Check File Exists

        File f = new File("graphics/Space.3ds");

        System.out.println

        (f + (f.exists()? " is found " : " is missing "));



        Node model = null;

        try {

          MaxToJme conv = new MaxToJme();

          ByteArrayOutputStream BO = new ByteArrayOutputStream();

         

          URL maxFile = Main.class.getClassLoader().getResource("graphics/Space.3ds");

          conv.convert(new BufferedInputStream(maxFile.openStream()),BO);



          JmeBinaryReader jbr = new JmeBinaryReader();

          jbr.setProperty("bound", "box");

          model = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));

        } catch (IOException e) {

          e.printStackTrace();

        }

       

       

    }

}

hmm even if i try to load from a .jme file it does not work:





        Node model = null;

        try {

            URL bikeFile = Lesson8.class.getClassLoader().getResource("jmetest/data/model/bike.jme");

            JmeBinaryReader jbr = new JmeBinaryReader();

            jbr.setProperty("bound", "box");

            model = jbr.loadBinaryFormat(bikeFile.openStream());

            //scale it to be MUCH smaller than it is originally

            model.setLocalScale(.0025f);

        } catch (IOException e) {

            e.printStackTrace();

        }



java.lang.NullPointerException

        at spaceshooter.Main.simpleInitGame(Main.java:51)

        at com.jme.app.BaseSimpleGame.initGame(Unknown Source)

        at com.jme.app.BaseGame.start(Unknown Source)

        at spaceshooter.Main.main(Main.java:33)

solved

Im having the same problem… but I don't know how to solve it…



Can u tell how did you do? :smiley:

Do not use JmeBinaryReader, use BinaryImporter.



All code in CVS is updated for this. I put a link in the wiki for lesson 8.