Problems with model

Hey guys, I'm trying to load a model wth jME (it's an .OBJ).  I followed the Starter's Guide on model loading, but when I run the program, I get the jME start screen, click Ok, get a black screen, and about .5 seconds later the app closes.



I have the model in the same directory as the .java file, and the .MTL file also.



This is my code (after the imports):


public class BloomTest extends SimpleGame {
    public static void main(String[] args) {
        BloomTest app = new BloomTest();
        app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
        // Turn the logger off so we can see the XML later on
        app.start();
    }
 
    protected void simpleInitGame() {
        // Point to a URL of my model
        URL model= BloomTest.class.getClassLoader().getResource("bloomtest.obj");
 
        // Create something to convert .obj format to .jme
        FormatConverter converter=new ObjToJme();
        // Point the converter to where it will find the .mtl file from
        converter.setProperty("mtllib",model);
 
        // This byte array will hold my .jme file
        ByteArrayOutputStream BO=new ByteArrayOutputStream();
        try {
       
            // Use the format converter to convert .obj to .jme
            converter.convert(model.openStream(), BO);
            Node sphere=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
                     
            // Put her on the scene graph
            rootNode.attachChild(sphere);
        } catch (IOException e) {   // Just in case anything happens
            System.out.println("Damn exceptions!" + e);
            e.printStackTrace();
            System.exit(0);
        }
    }
}



Any ideas what I did?

Thanks in advance!

(BTW, I just copied the code from the Starter Guide, and took out a few lines that were giving me trouble, so if the comments look funny...)

If your model is not in your class directory, try putting it there and reference it in the URL as such…

Something else I've noticed:



I pulled in a .obj file and created a node from it.  All that works fine.  I wrote it back out to JME format using BinaryExporter.save().



When I use BinaryImporter.load() to read it back in, I'm getting "not in GZIP format."



It appears I'm doing something wrong or BinaryExporter and BinaryImporter are not on the same page.

Found my problem.  No worries, I'm a retard.  It helps to try opening the correct file.

Ah ha, found the problem.  Now, it ALMOST works.



Except I get an exception.


java.lang.OutOfMemoryError: Java heap space
   at com.jme.util.geom.GeometryTool.minimizeVerts(Unknown Source)
   at com.jme.util.geom.GeometryTool.minimizeVerts(Unknown Source)
   at com.jmex.model.converters.ObjToJme.buildStructure(Unknown Source)
   at com.jmex.model.converters.ObjToJme.convert(Unknown Source)
   at BloomTest.simpleInitGame(BloomTest.java:35)
   at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at BloomTest.main(BloomTest.java:18)

:confused:



ObjToJme should skip optimizing mesh if there's too many vertexes, otherwise it overflows. You can also try to increase memory available to java, something like 256mb would probably fix it.

What he said… to do that, if you are running from command line, use:


java -Xms128m -Xmx512m -cp <your_class_path> <your_program_class>



Or, if you use Netbeans, there is a VM arguments in the project properties... Eclipse should do this automatically, or you could edit the eclipse.ini with this values.

I added those arguments to Eclipse's Run Dialog, and I still can't see the model.  I'm going to take a look at the Maggie model, because I have a feeling it's a problem with mine.