Hi,
i have a strange problem: I try to load an .obj mesh an show it on a scene, using the following code:
private void buildShip() {
URL source = space.class.getClassLoader().getResource("spaceproject/mesh/firstShip.obj");
URL sourceTex = space.class.getClassLoader().getResource("spaceproject/mesh/");
loadObjMesh(source, sourceTex);
}
private void loadObjMesh(URL meshSource, URL texSource) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjToJme conv = new ObjToJme();
conv.setProperty("mtllib",meshSource);
conv.convert(new BufferedInputStream(meshSource.openStream()), baos);
JmeBinaryReader jbr = new JmeBinaryReader();
jbr.setProperty("bound","box");
jbr.setProperty("texurl", texSource);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ship = jbr.loadBinaryFormat(bais);
//groesse skalieren
ship.setLocalScale(.0025f);
ship.setLocalTranslation(new Vector3f(100,0, 100));
ship.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
} catch (IOException e) {
System.out.println("Exception: " + e);
e.printStackTrace();
System.exit(0);
}
}
It compiles without any warnings or errors, but when I start the program, i get this exception:
Exceptions: java.io.IOException: Binary Header doesn't match. Maybe wrong file?
java.io.IOException: Binary Header doesn't match. Maybe wrong file?
at com.jmex.model.XMLparser.JmeBinaryReader.readHeader(Unknown Source)
at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at spaceproject.gameSurface.loadObjMesh(gameSurface.java:169)
at spaceproject.gameSurface.buildShip(gameSurface.java:153)
at spaceproject.gameSurface.initGame(gameSurface.java:130)
at com.jme.app.BaseGame.start(Unknown Source)
at spaceproject.Main.main(Main.java:28)
I am sure about the path (if i print out the buffer size of "baos" i get a proper value). I also tried different .obj/.mtl files: Some created by my own with wings3D, some downloaded from the internet.
Has anyone a suggestion, please?