public static void main(String[] args) {
TestModelImport app = new TestModelImport(); //changed name of program
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
Logger.getLogger("").setLevel(Level.SEVERE);
app.start();
}
the converter can't locate the file. make sure the path is right. And can you tell me
what kind of obj-file is called "Shade Mk.I"? PLZPLZ, use a filename without blank and with the right extension (.obj) just to be sure or you will be lost…sooner or later
EDIT: I copied the JMETest file for loading models and it works perfectly with the maggie model on there.... but it will not accept mine....
i exported the model from Blender 2.49 as a Wavefront .obj. The options i selected were Normals, HQ, Edges, Objects, rotate x90. Is this something to do with Blender and a new export "style" or something?
I wonder why java is cutting off the extension of your filename in the exception. This problem is definetly on the java side and has nothing to do with your exporting.
Well…two last options:
Are you using eclipse? If yes, did you refresh your project after creating the file? Otherwise it will not be copied to your binary-directory
Your application searches the file in the classpath-direcotry gameResources. Which means you have to place this directory in your src-directory. Not above…
If both is not working. Pack it as zip and upload it here and I will have a look.
urg… so, i just started up Eclipse again and ran the program and it threw me this:
SEVERE: Exception in game loop
java.lang.ClassCastException: com.jme.scene.TriMesh cannot be cast to com.jme.scene.Node
at game3d.TestModelImport.simpleInitGame(TestModelImport.java:42)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
at com.jme.app.BaseGame.start(BaseGame.java:74)
at game3d.TestModelImport.main(TestModelImport.java:24)
i read the code a little and see that it says that the converter needs to find the .mtl file and not the .obj (both are in the same file…). So i change the path from .obj to .mtl and run the program.
this time it works… well, works as in it doesnt crash. everything is black, so i push f4 to see if anything is happening.
frames are at a steady 450, but the avg. Tex binds is 0 and nothing else is displayed…
private static final Logger logger = Logger
.getLogger(TestModelImport.class.getName());
public static void main(String[] args) {
TestModelImport app = new TestModelImport();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
}
protected void simpleInitGame() {
// Point to a URL of my model
URL model = TestModelImport.class.getClassLoader().getResource(
"gameResources/Shade.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);
TriMesh shade = (TriMesh) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
shade.setLocalScale(1f);
shade.setModelBound(new BoundingSphere());
shade.updateModelBound();
// Put her on the scene graph
rootNode.attachChild(shade);
} catch (IOException e) { // Just in case anything happens
logger.logp(Level.SEVERE, this.getClass().toString(),
"simpleInitGame()", "Exception", e);
System.exit(0);
}
}