hi all,
just started using JME3 to learn Java and I’ve come into my first problem.
I am trying to load a model (which I do in SimpleInitApp() ), and then in the SimpleUpdate, I am trying to make it rotate. I have followed the helloloop tutorial but when I run my java file I get a nullpointerexception which I cannot seem to resolve. I’ll post my code below, any help would be appreciated, thanks a lot!
[java]
package jme3test.helloworld;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.scene.Spatial;
import com.jme3.math.Vector3f;
import com.jme3.util.TangentBinormalGenerator;
import com.jme3.math.ColorRGBA;
public class TestLevel extends SimpleApplication {
public static void main(String[] args){
TestLevel app = new TestLevel();
app.start();
}
protected Spatial pball;
@Override
public void simpleInitApp(){
Spatial pball = assetManager.loadModel("Models/PB.j3o");
TangentBinormalGenerator.generate(pball);
Material PB_def = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
PB_def.setTexture("DiffuseMap", assetManager.loadTexture("Textures/balldiff.jpg"));
PB_def.setTexture("NormalMap", assetManager.loadTexture("Textures/ballnormal.jpg"));
PB_def.setBoolean("UseMaterialColors", true);
PB_def.setColor("Diffuse", ColorRGBA.White);
PB_def.setColor("Specular", ColorRGBA.White);
PB_def.setFloat("Shininess", 64f);
pball.setMaterial(PB_def);
pball.scale(0.3f, 0.3f, 0.3f);
rootNode.attachChild(pball);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f,-0.7f,-1.0f));
rootNode.addLight(sun);
}
@Override
public void simpleUpdate(float tpf) {
pball.rotate(2*tpf,2*tpf,2*tpf);
}
}
[/java]