(SOLVED) And ... I saw no light. :(

Sorry for asking a probably stupid question, but for some reason I can't get lights to work in my little experiment. Here is what I am doing:



I create a StandardGame:

this.game = new StandardGame("MyGame");



I then create a custom extension of GameState:

this.gameState = new RenderSectorGameState("Sector",this.sector);



I then attach the gameState:

GameStateManager.getInstance().attachChild(gameState);



(though it escapes my understanding so far, at which point it gets connected with the this.game, but magically it happens.)



In the RenderSectorGameState in the init I do the following:



PointLight light = new PointLight();

light.setDiffuse( new ColorRGBA( 0.75f, 0.0f, 0.0f, 0.5f ) );

light.setAmbient( new ColorRGBA( 0.5f, 0.0f, 0.0f, 1.0f ) );

light.setLocation( new Vector3f( 100, 100, 100 ) );

light.setEnabled( true );

lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState();

lightState.setEnabled( true );

lightState.attach( light );

rootNode.setRenderState( lightState );

rootNode.updateRenderState();



And all is working, except I don't have the light I just added. In theory my testmodel should be lighted reddish or something. (It is located at 0,0,0)

But I see it perfectly white (which is default if no light exists).



So, what is it that I missed?

Hmm,…try a


rootNode.updateRenderState()

after everything is attached.

If that does not work you should post some code where and how you attach your objects so we can have a deeper look

Do you see the model or is everything just black? Because you have an ambient color set there so even if the light was placed incorrectly you should see something. Make sure the LightCombineMode is set properly on the model as well.

ttrocha said:

Hmm,..try a

rootNode.updateRenderState()

after everything is attached.

If that does not work you should post some code where and how you attach your objects so we can have a deeper look


Ah, that was the problem. I called updateRenderState after I attached all the initialization stuff, but *before* I added my model. Now that I call it after whenever I add a new model, it's working.

Thanks for the quick help - really appreciated!