I am trying to load a model for my game. I am using a base of the BuildPlayer() function from the Flag Rush tutorials. My code is:
private void buildPlayer() {
Node model = null;
try {
URL bikeFile = Start.class.getClassLoader().getResource("man.jme");
JmeBinaryReader jbr = new JmeBinaryReader();
jbr.setProperty("bound", "box");
model = jbr.loadBinaryFormat(bikeFile.openStream());
// scale it to be MUCH smaller than it is originally
model.setLocalScale(.01f);
} catch (IOException e) {
logger
.throwing(this.getClass().toString(), "buildPlayer()",
e);
}
// model = loadModel("bike.3ds");
// model.setLocalScale(0.01f);
//set the vehicles attributes (these numbers can be thought
//of as Unit/Second).
player = new MPlayer("Player Node", model);
player.setAcceleration(15);
player.setBraking(15);
player.setTurnSpeed(2.5f);
player.setWeight(25);
player.setMaxSpeed(15);
player.setMinSpeed(5);
player.setLocalTranslation(new Vector3f(100,0, 100));
scene.attachChild(player);
scene.updateGeometricState(0, true);
//we now store this initial value, because we are rotating the wheels the bounding box will
//change each frame.
// agl = ((BoundingBox)player.getWorldBound()).yExtent;
player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
}
However, when I run the program, I get the error:
SEVERE: Exception in game loop
java.lang.NullPointerException
at nolifecitygame.Lesson9.buildPlayer(Lesson9.java:677)
at nolifecitygame.Lesson9.initGame(Lesson9.java:372)
at com.jme.app.BaseGame.start(Unknown Source)
at nolifecitygame.Lesson9.main(Lesson9.java:195)
Aug 19, 2007 12:22:09 PM com.jme.app.BaseGame start
INFO: Application ending.
Please help, and thank you! jME rocks! :D