Collision with water

Hi guys, is there a way to add collision to water? i want to make water splash when a physic object comes into contact with water.



is this possible?



Code that i use to create water.

Code:
WaterFilter water = new WaterFilter(rootNode, new Vector3f(-0.5f, -1f, -0.3f)); FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(water);
  
    BloomFilter bloom=new BloomFilter();
    //bloom.getE
    bloom.setExposurePower(50);
    bloom.setBloomIntensity(1.0f);
    fpp.addFilter(bloom);
    LightScatteringFilter lsf = new LightScatteringFilter(new Vector3f(-0.5f, -1f, -0.3f).mult(-300));
    lsf.setLightDensity(1.0f);
    fpp.addFilter(lsf);
    DepthOfFieldFilter dof=new DepthOfFieldFilter();
    dof.setFocusDistance(0);
    dof.setFocusRange(20);     
    fpp.addFilter(dof);
    water.setWaveScale(0.003f);
    water.setMaxAmplitude(.1f);
    water.setFoamExistence(new Vector3f(0f, 0f, 0f));
    water.setFoamTexture((Texture2D) assetManager.loadTexture("Textures/dirttexture.jpg"));
    water.setRefractionStrength(0.2f);
    water.setWaterHeight(2.1f);
    
    app.getViewPort().addProcessor(fpp);  

One of my idea would be to find the height of the water then make a colision annimation at the x,z position of the object when it get smaller or equal to the height of the water!

You’d probably want to use SimpleWater instead of the post water. There is a demo vid somwhere of someone making his boat floating on the water. You can use the same technique to detect the collision with the water. then add some splashy particles and deform the water mesh you’re done. But that won’t work with post processing water.

You can add a quad to the scene, place it at the height of the water and set its cullHint to always. Then just perform a collision check. and emit particles where it collides.



The quad will never be rendered but it’s still in the scene graph

Yeah, but then you will ignore wave heights. That is not so much a problem for lakes with small waves, but when you have bigger waves it will be very noticeable.

True, but if the splash is big enough, i guess it won’t be noticeable much…anyway you won’t have wave at all with SimpleWater…

he/she want only “splash effect” so time when it appear don’t need to be affected by waves :wink:



so simple culled quad is enough for this

ahh i was after nehon :stuck_out_tongue: