Hey,
I have a problem with a j3o file.
I have read the Tutorial in the locally Help, but i don’t understand it.
I would animate the model to walk, but if i start the application, it print the error:
Schwerwiegend: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main.simpleInitApp(Main.java:46)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
Here ist the Code:
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication implements AnimEventListener {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
/** A white, spot light source. */
PointLight lamp = new PointLight();
lamp.setPosition(Vector3f.ZERO);
lamp.setColor(ColorRGBA.White);
rootNode.addLight(lamp);
Node monster = new Node("Monsters");
Spatial monster1;
monster1 = assetManager.loadModel("Models/Monster1/Monster1.j3o");
monster1.setName("Monster1");
monster1.setLocalScale(0.1f);
Material monster1_mat = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
monster1_mat.setTexture("DiffuseMap", assetManager.loadTexture("Models/Monster1/Monster1.png"));
monster1_mat.setFloat("DiffuseMap_0_scale",1f);
monster1.setMaterial(monster1_mat);
AnimControl monster1Control;
monster.attachChild(monster1);
monster1Control = monster.getChild("Monster1").getControl(AnimControl.class);
monster1Control.addListener(this);
AnimChannel channel = monster1Control.createChannel();
channel.setLoopMode(LoopMode.Loop);
channel.setAnim("Walk",1f);
rootNode.attachChild(monster);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
And here the Model:
http://freeuploader.ml/data/Monster.zip
I hope, you can help me
Thanks.