Beginner Question

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!

package jme3test.helloworld;

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();

protected Spatial pball;

public void simpleInitApp(){
    Spatial pball = assetManager.loadModel("Models/PB.j3o");

    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.scale(0.3f, 0.3f, 0.3f);
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f,-0.7f,-1.0f));

public void simpleUpdate(float tpf) {


The SDK is probably giving you a warning on this line:
Spatial pball = assetManager.loadModel(“Models/PB.j3o”);

…pay close attention to it because the warning is your problem. This isn’t really a JME kind of problem but a Java kind of problem.

awesome! thanks a lot, I was thinking the problem might be in the update loop.
got it working now :slight_smile:

1 Like