Where is my model?

Hi guys

It seems that i have an error in the init method. Can someone tell what is this error ?

I'm trying to get my model on the map. It seems that there is no error while loading. But can't find the model at all. Is there a way to set defualt model position or something plz ?



Here is the code, just tell me if i'm totally wrong or not :slight_smile:




public class test extends TestIsland {
   public static void main(String[] args)
   {
      test app = new test();
      app.setConfigShowMode(ConfigShowMode.AlwaysShow);
      app.start();
   }
   protected void simpleInitGame()
   {
      try{
      // Point to a URL of the models
      //URL model=TestIsland_K60.class.getClassLoader().getResource("C:/Documents and Settings/Whoami/Bureau/$_IPL/Workspace/K6O/models/tank/3dm-M1_Abrams/M1_Abrams.3DS");
      //URL model = new File("C:/Documents and Settings/Whoami/Bureau/$_IPL/Workspace/K6O/models/new/jonesy.blend").toURL();
      URL model = new File("C:/M1_Abrams.3DS").toURL();
      
      // Create something to convert .obj format to .jme
      FormatConverter converter=new MaxToJme();

      
      // This byte array will hold the .jme files
      ByteArrayOutputStream BO=new ByteArrayOutputStream();
      
      // Use the format converter to convert .obj to .jme
      converter.convert(model.openStream(), BO);
      
      Node pers=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
      
      // shrink the models
      pers.setLocalScale(50);
      pers.setModelBound(new BoundingSphere());
      pers.updateModelBound();
      
      // Put the models on the scene graph
      rootNode.attachChild(pers);
            
      }
      catch (Exception e) {
         // TODO: handle exception
      }
   }
}



Error :

06-d

There's no skybox being built, so you're getting a NullPointerException in the update method when this happens:


skybox.getLocalTranslation().set(cam.getLocation());



You might try making the buildSkybox() method in TestIsland protected and calling it in your init method

Other error happened :


GRAVE: Exception in game loop
java.lang.NullPointerException
   at jmetest.terrain.TestIsland.simpleUpdate(TestIsland.java:95)
   at com.jme.app.SimplePassGame.update(SimplePassGame.java:62)
   at com.jme.app.BaseGame.start(BaseGame.java:84)
   at jmetest.terrain.test.main(test.java:19)

finally working. but still one question : is there a way i can set the default position of the model i just inserted ? cause can't find anything about that :s

Whoami said:

finally working. but still one question : is there a way i can set the default position of the model i just inserted ? cause can't find anything about that :s


great to hear!  I would move the model to somewhere with a close proximity to the camera as such:

pers.setLocalTranslation(cam.getLocation().getX(), cam.getLocation().getY(), cam.getLocation().getZ()+20);



The object should now be sitting right in front of you ;)

any idea why my model doesn't have any texture ? since i've downloaded textured model, it sounds strange to me… (textures are in a seperate .BMP file)

Whoami said:

any idea why my model doesn't have any texture ? since i've downloaded textured model, it sounds strange to me... (textures are in a seperate .BMP file)


you have to tell the obj importer that you wish to process materials from mtl files...  use

converter.setProperty("mtllib", model);



Also check that the mtl file is using a relative filepath to get to the texture