Hi i wrote my own model import class (actually the code is nearly completely copied from HelloModelLoading) but for som reason it doesnt work:
public class ModelLoader{
public ModelLoader() {
}
public Node importModel(String location) {
Node model = null;
URL modelURL=ModelLoader.class.getClassLoader().getResource(location);
FormatConverter converter=new ObjToJme();
converter.setProperty("mtllib",modelURL);
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
converter.convert(modelURL.openStream(), BO);
model=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
model.setModelBound(new BoundingSphere());
model.updateModelBound();
} catch (IOException e) { // Just in case anything happens
System.out.println("Modelload faild");
System.exit(0);
}
return model;
}
}
i get a nullpointerexceptionin this line:
converter.convert(modelURL.openStream(), BO);
for somereason the URL isnt created correctly and i suppuse that i made a newbish mistake with the location path so her is my structure:
My Game Folder
-pakage1 // here is the class where model loader is created and importModel is called
-pakage2 // here is my ModelLoader class
-models //in this Folder is the .obj and .mtl file
i call importModel with "models/model.obj"
btw i am using jme 1.0