Hi all,
Still busy with the shooter. And again I cannot find an answer in the forum past or tutorials.
I use the following code to load my model:
private Node loadModel(String url){
Node model = null;
try {
MaxToJme C1 = new MaxToJme();
ByteArrayOutputStream BO = new ByteArrayOutputStream();
URL maxFile = new URL(url);
C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
model = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
} catch (IOException e) {
e.printStackTrace();
}
return model;
}
This seems to work as the debugger shows it is loading the model, except that It cant find a particular image file but no problems there.
In the Ship class during the constructor phase:
attachChild(model);
updateWorldBound();
And the chasecamera phase, this is where the nullpointer occurs:
private void buildChaseCamera() {
Vector3f targetOffset = new Vector3f();
targetOffset.y = ((BoundingBox) player.getWorldBound()).yExtent * 1.5f;
..
The error is in the second line: targetOffset.y = ((BoundingBox) player.getWorldBound()).yExtent * 1.5f;
Error:
SEVERE: Exception in game loop
java.lang.NullPointerException
What am I doing wrong? If, instead of the model, i produce a simple box it works fine, but a model doesnt.
Regards,
frank