WaterFilter setReflectionDisplace after adding to Processor

Hi!
While there is no problem setting the ReflectionDisplace of a WaterFilter before adding it to the scene, doing it afterwards causes an error.
Test-case:
[java]public class Main extends SimpleApplication
{

private FilterPostProcessor fpp;
private WaterFilter wf = new WaterFilter(rootNode, Vector3f.ZERO);

public static void main(String[] args)
{
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp()
{
    fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(wf);
    viewPort.addProcessor(fpp);
}

@Override
public void simpleUpdate(float tpf)
{
    wf.setReflectionDisplace((int) Math.random() * 100);
}

}[/java]

This is what I get:
[java]java.lang.IllegalArgumentException: Material parameter is not defined: m_ReflectionDisplace
at com.jme3.material.Material.checkSetParam(Material.java:446)
at com.jme3.material.Material.setParam(Material.java:462)
at com.jme3.material.Material.setFloat(Material.java:603)
at com.jme3.water.WaterFilter.setReflectionDisplace(WaterFilter.java:1029)
at mygame.Main.simpleUpdate(Main.java:36)
[/java]
Line 36: [java]wf.setReflectionDisplace((int) Math.random() * 100);[/java]
No big deal, just wondering whether it’s simply not possible for a reason or just a small bug?
Cheers.

That’s a bug in WaterFilter. Right, @nehon?

Yes it is, it’s fixed in nightly since September 2013 though.
I you use a stable release, don’t change to nightly just for this though, the workaround is easy.

1 Like