When running my game I get a NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at com.jmex.model.converters.ObjToJme$MaterialGrouping.<init>(Unknown Source)
at com.jmex.model.converters.ObjToJme.convert(Unknown Source)
at fyrestonev05.ModelConverter.convertModel(ModelConverter.java:47)
at fyrestonev05.Fyrestone.getChar(Fyrestone.java:520)
at fyrestonev05.FyrestoneServer.<init>(FyrestoneServer.java:58)
at fyrestonev05.FyrestoneServer.main(FyrestoneServer.java:69)
At the same time, the game runs and my model loads... I know I shouldn't be complaining but I think that this error is leading to other errors that I am having.
ModelConverter: (Problem "bolded" and commented)
public class ModelConverter
{
private static final String ninjaDir = "models/ninja.obj";
private static Quaternion pitch90 = new Quaternion();
public static Spatial convertModel()
{
// Point to a URL of my model
URL model = Fyrestone.class.getClassLoader().getResource(ninjaDir);
// Create something to convert .obj format to .jme
FormatConverter converter = new ObjToJme();
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
[BOLDBOLDBOLD] converter.convert(model.openStream(), BO);[BOLDBOLDBOLD]//This is where the error points.
Spatial myModel = (Spatial) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
// shrink this baby down some
myModel.setLocalScale(10f);
pitch90.fromAngleNormalAxis(FastMath.PI * 1.5f, Vector3f.UNIT_X);
myModel.setLocalRotation(pitch90);
myModel.setModelBound(new BoundingBox());
myModel.updateModelBound();
myModel.updateRenderState();
// Put her on the scene graph
return myModel;
} catch (IOException e) { // Just in case anything happens
System.out.println("Damn exceptions!" + e);
e.printStackTrace();
System.exit(0);
}
return null;
}
}
Anyone see a problem?
Thank you so much.
:D