OBJ loading from Applet?

Since it is an applet, most likely it does not have permission to access the files directly… instead try using a getResource on the classloader to get a URL.



Another way would be to put your applet in a JAR and sign it to let it access files directly.

Ok, so now that I'm using getResource, which gives me a URL, what am I supposed to do with it to get the file that loadModel asks for?

Take a look at ModelLoader in the com.jmex.model.util package:


URL url; //Initialized any way you want.
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            converter.convert( url.openStream(), bos );
            Savable savable = BinaryImporter.getInstance().load( new ByteArrayInputStream( bos.toByteArray() ) );
            if ( savable instanceof Node ) {
                return (Node) savable;
            } else {
                Node model = new Node( "Imported Model " + file );
                model.attachChild( (Spatial) savable );
                return model;