Light problem - getRenderState(RenderState.RS_LIGHT); loss of attached lights

Hello,



We are not using SimpleGame and such  :D.

I added a function to toggle lights onoff from our root node:



public void toggleLights()

    {

        lightState = (LightState)getRenderState(RenderState.RS_LIGHT);

        lightState.setEnabled(!lightState.isEnabled());

        setRenderState(lightState);  // this class derives from Node - this class serves as our root node

        updateRenderState();

    }



when we toggle the lights back on we loose all the lights!  :?

we have attached a light previously but when debugging this function we do not have any lights in lightState after the call to getRenderState().

what would you suggest?

well it works in simplegame :slight_smile: can you provide a test case where it won't work?



setRenderState() is not needed, because with getRenderState you just retrieve the reference to the Lightstate, there is no need to set it again.

ah… yeah you're right. I found the problem - I was creating a lightState in my init() to be used as an onoff switch… which is silly, now I simply get the current state from my root… GREAT SUCCESS



hopefully my next post will be less n00bish and more proish!  :smiley: