Hello, I think this is the one houndred and one thread for importing models to JME2. But I’m very new to the engine and I have not a clue. I fellowed the wiki: http://www.jmonkeyengine.com/wiki/doku.php?id=howto_jme2_and_blender2.48 but I can’t load the materials. Loading the model works but it is without any materials. I have downloaded a nice model of a MacOS Computer from http://www.katorlegaz.com/3d_models/electronics_computers/0065/index.php. In blender I changed the coordinates to right hand side and export it to the Wavefront Obj format.
This is my code to load the model:
try {
URL url = new File(filename).toURI().toURL();
FormatConverter converter = new ObjToJme();
converter.setProperty("mtllib", new File(
"resources/models/obj/apple-mac-plus/").toURI().toURL());
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
converter.convert(url.openStream(), ostream);
Spatial spatial = (Spatial) BinaryImporter.getInstance().load(
new ByteArrayInputStream(ostream.toByteArray()));
spatial.setLocalScale(2f);
spatial.setModelBound(new BoundingSphere());
spatial.updateModelBound();
return spatial;
} catch (IOException e) {
throw new ModelsLoadException(e);
}
It's from the wiki site with the exception that my ordner where to find the materials is not in the jar file as a resource. Is there anything wrong either with the format of the material file or with my code?