Loading model


I've tried to replace to deprecated code in the FlagRush tut (which is working fine).

 Node model = null;
         try {
             //This should be updated to the latest BinaryImporter code once the model
             //is converted.
             URL bikeFile = Client.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
         } catch (IOException e) {

By the code snippet ...

Node model = loadModel("jmetest/data/model/bike.3ds");

From Jmonkey site ...

public static Node loadModel (String modelFile){
       Node         loadedModel   = null;
       FormatConverter      formatConverter = null;      
       ByteArrayOutputStream    BO       = new ByteArrayOutputStream();
       String         modelFormat    = modelFile.substring(modelFile.lastIndexOf(".") + 1, modelFile.length());
       String         modelBinary   = modelFile.substring(0, modelFile.lastIndexOf(".") + 1) + "jbin";
       URL         modelURL   = ModelLoader.class.getClassLoader().getResource(modelBinary);
       //verify the presence of the jbin model
       if (modelURL == null){
          modelURL      = ModelLoader.class.getClassLoader().getResource(modelFile);
          //evaluate the format
          if (modelFormat.equals("3ds")){
             formatConverter = new MaxToJme();
          } else if (modelFormat.equals("md2")){
             formatConverter = new Md2ToJme();
          } else if (modelFormat.equals("md3")){
             formatConverter = new Md3ToJme();
          } else if (modelFormat.equals("ms3d")){
             formatConverter = new MilkToJme();
          } else if (modelFormat.equals("ase")){
             formatConverter = new AseToJme();
          } else if (modelFormat.equals("obj")){
             formatConverter = new ObjToJme();
          formatConverter.setProperty("mtllib", modelURL);
          try {
             formatConverter.convert(modelURL.openStream(), BO);
             loadedModel = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
             //save the jbin format
             BinaryExporter.getInstance().save((Savable)loadedModel, new File(modelBinary));
          } catch (IOException e) {            
             return null;
          try {
             //load the jbin format
             loadedModel = (Node) BinaryImporter.getInstance().load(modelURL.openStream());
          } catch (IOException e) {
             return null;
       return loadedModel;

I get the following error ... am I missing something ?

INFO: Child (TDS Scene) attached to this node (Player Node)
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.jme.scene.Node.getChild(Node.java:321)
at jmetest.game.toudg.Vehicle.setModel(Vehicle.java:277)
at jmetest.game.toudg.Vehicle.<init>(Vehicle.java:92)
at jmetest.game.toudg.Client.buildPlayer(Client.java:385)
at jmetest.game.toudg.Client.initGame(Client.java:284)
at com.jme.app.BaseGame.start(BaseGame.java:56)
at jmetest.game.toudg.Client.main(Client.java:142)
2007-05-03 09:48:16 com.jme.app.BaseGame start
INFO: Application ending.

Thanks for your time ! :D

looks like your code is asking for child #2 (index 1 in a 0 based index) in a node that only has 1 child.