Question about lightstates in this example

I changed lex's StrategicHandler example SimpleGame code to make it work with StandardGame. I made a couple of mistakes there and would like some help to sort them out, if possible. The original version of the code is visible under this link in the WiKi.



cbratton asked me a fair question in the StrategicHandler's thread:


I believe you forgot to set the lightState in the example on the wiki.  Shouldn't this be added to the bottom of setupTerrain()?

terrainNode.setRenderState(lightState);
terrainNode.updateRenderState();



I checked my code and sure enough I seemed to handle the light states incorrectly. At first it looked to me that I set a lightstate in the init() method and later clear it and set a new lightstate in the setupTerrain method. However as I experimented with the code a bit, it seemed to me that even if I remove all the lightstate declarations from the scene, it will still be lighted. It looks like the lighting has no effect on the world at all. Could someone please comment on this? What am I missing?

Yeah, I was playing with the code myself for quite a while.  I'll post if I figure out whats going on…  Hopefully we can get some magical "Dark" Fro…err, force to come help us out.  :stuck_out_tongue:

i think you don't see much difference because there are only textured objects in the scene.

if you put a simple shaded Box into the scene it becomes clearly visible if there is a light active or not.

With light the box is shaded, without Light the box is plain white.

With:


terrainNode.setRenderState(lightState);
terrainNode.updateRenderState();




...and without...



Could be I need newer versions of everything...haven't checked out CVS in awhile.



I could reproduce what you see when i commented out terrainNode.lock(), it never happend when the terrain was locked.

This can be fixed by adding an rootNode.updateRenderstate() call in the GameTask.



        GameTaskQueueManager.getManager().update(new Callable<Object>() {
            public Object call() throws Exception {
                setupTerrain();
                rootNode.updateRenderState();
                return null;
            }
        });


Note that the GameTask is executed after the Gamestate has been constructed and activated.

An updateRenderstate call at the end of the Constructor wouldn't hurt also i think. :)


For whatever reason I have never been able to use terrainNode.lock() etc in any example.  My JVM crashes hard…  Latest jME build, Java 6u10, Catalyst 8.3.

Core-Dump said:

I could reproduce what you see when i commented out terrainNode.lock(), it never happend when the terrain was locked.
This can be fixed by adding an rootNode.updateRenderstate() call in the GameTask.


        GameTaskQueueManager.getManager().update(new Callable<Object>() {
            public Object call() throws Exception {
                setupTerrain();
                rootNode.updateRenderState();
                return null;
            }
        });



Note that the GameTask is executed after the Gamestate has been constructed and activated.

An updateRenderstate call at the end of the Constructor wouldn't hurt also i think. :)

I have added the suggested changes to the WiKi page. Thank you for helping out with this.

My own problem of not seeing the effects of lighting correctly was caused by (lol) Eclipse not re-building the project after changes as I had errors in another part of the project. Adding a box to the scene really helped :)

Alright, after trying different configurations for quite some time…I'm sure that my normal setup can't run anything that locks the mesh to create a display list.



I have now tried every Catalyst version from 7.3 to 8.3.  I even checked the problematic frame to see if it matches the previous, and it does.  Different versions of atioglx2.dll with every install.



I also tried the three JRE's I have installed…each with the same result which I expected.



Nothing. 



HOWEVER, same exact hardware in linux and it runs fine.  Same system, just a dual boot.  Weird.  I'm going to blame it all on ATI's drivers and my exact card.



Tomorrow I am going to borrow a friends x1650 (similar to my card) and try it in my system.  On my friends hardware, my test runs fine.  I just want to see if its simply my card that is flaking out.