[Solved] FengGUI + Water


I fixed the problem in the test.  The problem was that I did not call the “addReflectedScene” method on the WaterEffectRenderPass object.  In the source code, this method creates an Enumeration I think.  When the render method is called, it treats the reference to the collection as an existing object even if it was never initialized which is why I was getting the null pointer. 

Perhaps a future fix is to not require the addReflectedScene method in WaterRenderPass … probably would only take a few lines of code to fix.

Also note, I’ve updated the latest working source of the test program here (1.8MB)


I am trying to get water to work within JME 2 using GameStates with FenGUI.  In a different project, the water is all black.  So I’m trying to duplicate this in a test program (for easy debugging).  I’ve extended a test program that another user (on this site) created for testing out FengGUI and the render pass stuff.

So now I have combined this test with the TestSimpleQuadWater example. 

However, I am doing something wrong because the program will no longer start giving the following error:

     [java] java.lang.NullPointerException
     [java]    at com.jmex.effects.water.WaterRenderPass.renderRefraction(WaterRenderPass.java:543)
     [java]    at com.jmex.effects.water.WaterRenderPass.doRender(WaterRenderPass.java:360)
     [java]    at com.jme.renderer.pass.Pass.renderPass(Pass.java:92)
     [java]    at com.jme.renderer.pass.BasicPassManager.renderPasses(BasicPassManager.java:90)
     [java]    at PassManagerGameState.render(TestFengGUIPass.java:89)
     [java]    at com.jmex.game.state.GameStateNode.render(GameStateNode.java:83)
     [java]    at com.jmex.game.StandardGame.render(StandardGame.java:399)
     [java]    at com.jmex.game.StandardGame.run(StandardGame.java:251)
     [java]    at java.lang.Thread.run(Thread.java:619)

Full source can be found here (1.8MB)

Relevant code snips

From SimpleQuadWater

    private void init(BasicPassManager pManager, Camera cam) {
        rootNode = new Node();
        waterEffectRenderPass = new WaterRenderPass(cam, 4, false, true);
        waterEffectRenderPass.setWaterPlane(new Plane(new Vector3f(0.0f, 0.0f, 1.0f), 0.0f));
        waterEffectRenderPass.setTangent(new Vector3f(1.0f, 0.0f, 0.0f));
        waterEffectRenderPass.setBinormal(new Vector3f(0.0f, 1.0f, 0.0f));
        waterQuad = new Quad("waterQuad", 100, 100);
        RenderPass rootPass = new RenderPass();

From TestFengGUIPass

               try {
                        GameTaskQueueManager.getManager().update(new Callable<Object>() {
                                public Object call() throws Exception {
                                        state = new FengGUIGameState();
                                        water = new SimpleQuadWater(pManagerGS.getManager(),game.getCamera());
                                        return null;
                } catch (Exception e) {

Anyone see what I'm doing wrong?