All my models are white

I'm trying to figure out how to use FixedLogicrateGame in jME 2.0, but all the models I load in the scene are plain monocolor-white. There isn't even any shading. My model importer code worked fine for SimpleGame (it even loads the texture). I thought maybe I just had to add a light:

      //Create a Basic Directional Light
      DirectionalLight dl = new DirectionalLight();
      dl.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dl.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));

      LightState ls = display.getRenderer().createLightState();

But it's still not working. Is there something wrong with my lighting code, or am I missing something else? How are you supposed to add lights?

You need to apply a MaterialState to you models for light to have an effect.

That's not true… that usually results from a missing updateRenderState on the models…

I think often its white when a LightState is missing at all :), but you have that one obviously.

So there are a few pitfalls to double check.

That's not very helpful guys. Here's my attempt to reproduce the problem as simply as possible:

import java.util.prefs.BackingStoreException;

import java.util.prefs.Preferences;


import com.jme.input.KeyBindingManager;

import com.jme.input.KeyInput;

import com.jme.light.DirectionalLight;

import com.jme.math.Vector3f;

import com.jme.renderer.Camera;

import com.jme.renderer.ColorRGBA;

import com.jme.scene.CameraNode;

import com.jme.scene.Node;

import com.jme.scene.shape.Box;

import com.jme.scene.state.LightState;

import com.jme.scene.state.MaterialState;

import com.jme.scene.state.ZBufferState;

import com.jme.system.DisplaySystem;

import com.jme.system.GameSettings;

import com.jme.system.JmeException;

import com.jme.system.PreferencesGameSettings;

public class HelloAgainWorld extends FixedLogicrateGame{

   public static void main(String[] args) {

      HelloAgainWorld app = new HelloAgainWorld();




   private CameraNode camNode;

   private Camera cam;

   private Node rootNode;

   private int width, height, depth, freq;

   private boolean fullscreen;

   private ZBufferState buf;

   private MaterialState mat;

   private void buildOverheadCamera()   {

      camNode = new CameraNode("Camera Node", cam);


      camNode.setLocalTranslation(new Vector3f(0, 0, -100));



   private void initZBuf() {

      buf = display.getRenderer().createZBufferState();






   private void initMat() {

      // add a material state?

      mat = display.getRenderer().createMaterialState();





   private void initLight() {

      //Create a Basic Directional Light?

      DirectionalLight dl = new DirectionalLight();


      dl.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));

      dl.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));


      // add a light state?

      LightState ls = display.getRenderer().createLightState();






   private void initialize() {

      rootNode = new Node();



      // private helper methods




      // apply the render states





   protected void cleanup() {

      // so far, not needed?



   protected void initGame() {


      // generate a box and set name, initial position, and scale

      Box box1 = new Box("box1", new Vector3f(0,1,0),1,2,3);

      // attach it to the scene graph


      // rotate a little

      box1.getLocalRotation().fromAngleAxis(1, Vector3f.UNIT_XYZ);



   protected void initSystem() {   

      //store the properties information

      width = this.settings.getWidth();

      height = this.settings.getHeight();

      depth = this.settings.getDepth();

      freq = this.settings.getFrequency();

      fullscreen = this.settings.isFullscreen();         

      //cam init

      try {

         display = DisplaySystem.getDisplaySystem(


         display.createWindow(width, height, depth, freq, fullscreen);

         cam = display.getRenderer().createCamera(width, height);

      } catch (JmeException e) {




      //set the background to black





            1, 1000);


            new Vector3f(0,12,0),










   protected void reinit() {

      display.recreateWindow(width, height, depth, freq, fullscreen);



   protected void render(float arg0) {

      // Clear the screen


      // Draw the scene




   protected void update(float interpolation) {

      //check for keyboard input

      if (KeyBindingManager.getKeyBindingManager(

            ).isValidCommand("exit")) {

         finished = true;


      rootNode.updateGeometricState(interpolation, true);

      //update Overhead Camera




   protected GameSettings getNewSettings() {

      boolean newNode = true;

      Preferences userPrefsRoot = Preferences.userRoot();

      try {

         newNode = !userPrefsRoot.nodeExists("");

      } catch (BackingStoreException bse) {



      return new PreferencesGameSettings(userPrefsRoot.node(""), newNode,




It extends FixedLogicrateGame and renders a box. Still no shading. I really don't understand how renderstates are supposed to work, so I don't know if I'm doing it wrong.

You added the Box to the rootNode without updating the RenderState afterwards.

Add a rootNode.updateRenderState(); at the end of initGame()

Trussell.setScore(Trussell.getScore() + 1);

lol, thanks it's working now.