Pavl_G
August 15, 2020, 5:15pm
1
Is there a way to resize the water filter …actually i am getting a shore on Mars
i want that water filter to be only in its lowered part & i cannot find a way to scale it
i want the water filter to be only in this lake:
code :
private void Water_Effect() {
/** A white, directional light source */
DirectionalLight sun = new DirectionalLight();
sun.setDirection(rootNode.getLocalTranslation());
sun.setColor(ColorRGBA.Yellow);
rootNode.addLight(sun);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
WaterFilter water = new WaterFilter(rootNode, sun.getDirection());
water.setWaterHeight(-20);
water.setShapeType(WaterFilter.AreaShape.Circular);
water.setUseFoam(true);
water.setUseRipples(true);
water.setDeepWaterColor(ColorRGBA.Brown);
water.setWaterColor(ColorRGBA.Brown.mult(2.0f));
water.setWaterTransparency(0.2f);
water.setMaxAmplitude(0.3f);
water.setWaveScale(0.008f);
water.setSpeed(0.7f);
water.setShoreHardness(1.0f);
water.setRefractionConstant(0.2f);
water.setShininess(0.3f);
water.setSunScale(1.0f);
water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
water.setRadius(0.1f);
water.setNormalScale(0.1f);
fpp.addFilter(water);
viewPort.addProcessor(fpp);
}
A water filter has no location. You can’t position it. It will be rendered below a certain level and that’s it.
If you want localised water you can use the SimpleWater example.
Simple Water
1 Like
jayfella:
A water filter has no location. You can’t position it. It will be rendered below a certain level and that’s it.
If you want localised water you can use the SimpleWater example.
Simple Water :: jMonkeyEngine Docs
This is wrong. There are methods on the WaterFilter, that limit it to a specified circle or square - This is already possible since a few years. It’s probably not the most performant way (or the intended one) to use the filter, but it’s possible:
waterFilter.setCenter(Vector3f position)
waterFilter.setRadius(float radius)
waterFilter.setShapeType(WaterFilter.AreaShape.Square) <-- Square / Circle
1 Like
My statement is correct. You are describing a radius/extent, not a position.
setCenter specifies an offset position, that will be added. You can position the filter as wished using it.
1 Like
Here is an image I just took from a project where I use this - It isn’t a perfectly visible example, but it shows that you can position the filter at a given place.
(In my example I wanted to cover this “hole” with water - Due to heightmap changes, it currently looks like above, but it at least shows what’s happening^^ And yes, the center of this water is not (0, 0, 0))
2 Likes
This I did not know existed. So you are correct.
2 Likes
pspeed
August 17, 2020, 5:15pm
8
In this case, the javadoc for WaterFilter is reasonably complete.
2 Likes
Pavl_G
August 17, 2020, 10:19pm
9
@destroflyer Awesome ! It works ! thank you, but you must add them after adding the filter to the viewPort
Code:
private void Water_Effect() {
/** A white, directional light source */
DirectionalLight sun = new DirectionalLight();
sun.setDirection(rootNode.getLocalTranslation());
sun.setColor(ColorRGBA.Yellow);
rootNode.addLight(sun);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
WaterFilter water = new WaterFilter(rootNode, sun.getDirection());
water.setWaterHeight(-20);
water.setShapeType(WaterFilter.AreaShape.Circular);
water.setUseFoam(true);
water.setUseRipples(true);
water.setDeepWaterColor(ColorRGBA.Brown);
water.setWaterColor(ColorRGBA.Brown.mult(2.0f));
water.setWaterTransparency(0.2f);
water.setMaxAmplitude(0.3f);
water.setWaveScale(0.008f);
water.setSpeed(0.7f);
water.setShoreHardness(1.0f);
water.setRefractionConstant(0.2f);
water.setShininess(0.3f);
water.setSunScale(1.0f);
water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
water.setRadius(0.1f);
water.setNormalScale(0.1f);
fpp.addFilter(water);
viewPort.addProcessor(fpp);
water.setCenter(new Vector3f(72.81782f,-20f,760.87f));
water.setRadius(500f);
}
the lake :
the base of the scene:
1 Like