Model loading problems

I'm having problems getting a .obj model to load from a file. Whenever the model added to the scene, the screen won't display anything except for the background color. I copied the code from the HelloModelLoading tutorial (into a FixedLogicrateGame), but the copied code doesn't work, even though the tutorial itself does. I think that the model is imported and converted correctly, it seems to be that the model can't render correctly.



Here's the code that loads the model:


URL whiteboardURL = null;
try
{
    File f = new File("resources\game\main_menu\whiteboard_bak.obj");
    whiteboardURL = new URL("file:/" + f.getAbsolutePath());
}
catch(Exception e)
{
    System.err.println("Failed to load main menu whiteboard model at location "resources\game\main_menu\whiteboard_bak.obj." (Wavefront .obj model)");
    e.printStackTrace();
    whiteboardURL = null;
    System.exit(1);
}
FormatConverter converter = new ObjToJme();
converter.setProperty("mtllib", whiteboardURL);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try
{
    converter.convert(whiteboardURL.openStream(), BO);
    Node whiteboard = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

    whiteboard.setLocalScale(.01f);
    whiteboard.setLocalTranslation(new Vector3f(0, 0, -50));

    rootNode.attachChild(whiteboard);
}
catch(IOException e)
{
    System.out.println("Failed to convert whiteboard Wavefront .obj model to .jme model.");
    e.printStackTrace();
    System.exit(0);
}



I've already searched for topics like this, but they haven't really helped...

Hi, i use following code to load .obj models:




   public static TriMesh LoadOBJ(String str_model, float scale)
   {
      TriMesh mesh = null;
      
   
      // try block for IO / model import exceptions:
      try {
         
          // try to get model:
          URL modelFile = GameData.GetURL(str_model + ".obj");
         
          // Point the converter to where it will find the .mtl file from
          FormatConverter converter = new ObjToJme();
          //converter.setProperty("mtllib", modelFile);
          
          // This byte array will hold my .jme file
          ByteArrayOutputStream bo = new ByteArrayOutputStream();
         
         converter.convert(new BufferedInputStream(modelFile.openStream()), bo);
         ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
   
         // create new TriMesh:
         mesh = (TriMesh)BinaryImporter.getInstance().load(bi);
         
         // local rotation correction:
         //mesh.rotateUpTo(new Vector3f(1,-1,0));
         mesh.setLocalScale(scale);
          
           // add a bounding sphere:
           mesh.setModelBound(new BoundingSphere());
           mesh.updateModelBound();
           //mesh.setNormalsMode(0);
   
      }
      catch (IOException e)
      {
         e.printStackTrace();
         System.out.println("EXIT with Error!");
      }
      
      return mesh;
   }





...but seems to be similar to yours. Did you set (and enable) lighting/material states to your render-node?

Best Regards
woidl

Maybe your model is not on 0,0,0 and you can't see it because it is so far  or it is to small.