Shadow problem

When I first start the game shadows are working, but when I restart the game (hitting a "restart" button in the game, not stopping/starting the application)

it crashes with a nullpointer exception:

Exception in thread "OpenGL" java.lang.NullPointerException

at com.jme.scene.shadow.MeshShadows.createGeometry(

at com.jme.renderer.pass.ShadowedRenderPass.generateVolumes(

at com.jme.renderer.pass.ShadowedRenderPass.doRender(

at com.jme.renderer.pass.Pass.renderPass(

at com.jme.renderer.pass.BasicPassManager.renderPasses(

at net.ob3d.states.BasicState.render(

at net.ob3d.multiplayer.FightState.render(

at net.ob3d.multiplayer.FightStateSinglePlayer.render(


at net.ob3d.OBStandardGame.render(



Anyone has an idea of what this might be ?

I use gamestates and standardgame:

public abstract class BasicState extends GameState implements INodeReceiver,
      IUniverseFactory, IGraphicsSettings {
   boolean lightShadow1Enabled = true;
   boolean lightShadow2enabled = false;
   boolean lightShadow3enabled = true;
   boolean lightShadow4enabled = true;
   protected Node nonShadow;
   Node shadowNode;
   BasicPassManager passManager = new BasicPassManager();
   private static ShadowedRenderPass shadowPass = new ShadowedRenderPass();
   public void addNode(INode node) {
      GraphicsAttributes g = node.getGraphicsAttributes();
      //nonShadow.attachChild((Spatial) node);
      if(g!=null) {
         if(g.castShadows) {
            shadowNode.attachChild((Spatial) node);
         }else {
            nonShadow.attachChild((Spatial) node);
      nonShadow.attachChild((Spatial) node);

   public Node createNode(String name) {
      Node node= new Node(name);
      ZBufferState buf = DisplaySystem.getDisplaySystem().getRenderer()
      return node;

   public void init() {
      nonShadow = createNode("nonShadow");
      shadowNode = createNode("shadow");
        RenderPass renderPass = new RenderPass();
   public void update(float tpf) {
      if(!isActive()) return;
      shadowNode.updateGeometricState(tpf, true);
      nonShadow.updateGeometricState(tpf, true);

   public void render(float tpf) {


Well, StandardGame and NPE are basically always related to Threading problems… Are you restarting your application in the GL thread?

It is restarted same way as started…I create a gamestate and the gamestate checks if it was "inited". If not, it inits, I suppose that would be in the GL thread ?

If that is not the right way, how do I init correctly in the GL thread ?

What I do now is something like

public void update() {

  if(!inited) {

  inited = true;

  //init stuff



What fails is while rendering… so I don't think this is the actual problem…  :expressionless: So I think we need more info about your problem… if you could create a small test-case, I could have a look at it.

One or more meshes are empty while the shadow volumes are being computed…