I wanted to try out this wonderful water from Mr. Coder but having some trouble with (I THINK it’s the reason - I do not KNOW it) the ChaseCamera…
Don’t know how to explain so I show you a pic…
First pic shows you my terrain with a projectedgrid for my water surface with wthe waterrenderpass effect on it. Though there is no reflection and refraction everything seems fine. (Reflection and Refraction is working on other machines.)
But if I walk towards the water the water seems to “run away from me”…precisely from the ChaseCam (pic 2 and 3)
When I’m in the water but not under its surface, nearly up to the half of my screen the water is clipped away…
please help me Mr. Coder… (Miss Dakota?? )
I think it has something to do with the ChaseCamera or with the amount of units my cam keeps above the terrain… I don’t know
This is how I set up my waterrenderpass:
private void setupWaterRenderPass() {
Ground ground = new Ground("ground", 0.8f);
rootNode.attachChild(ground);
Node reflectedNode = new Node("reflectNode");
reflectedNode.attachChild(skybox);
rootNode.attachChild(reflectedNode);
We use chasecamera and water pass without this problem. That said, to me it looks like grid generation is starting too far from your camera. Perhaps it's the camera matrix you've setup?
/*Vector3f loc = new Vector3f( 0.0f, 0.0f, 25.0f );
Vector3f left = new Vector3f( -1.0f, 0.0f, 0.0f );
Vector3f up = new Vector3f( 0.0f, 1.0f, 0.0f );
Vector3f dir = new Vector3f( 0.0f, 0f, -1.0f );
// Move our camera to a correct place and orientation.
cam.setFrame(loc, left, up, dir);
// Signal that we've changed our camera's location/frustum.
cam.update();*/
// Weise Camera diesem Renderer zu
display.getRenderer().setCamera(cam);
hmm… does it matter if you are moving or not? Some of the values the projectedgrid uses rely on the camera's projection matrix, which is only updated when apply() is called. This would mean it could lag behind a frame if you are moving.
in that case, it's definitely your near-plane. you are using very "unique" scale on your stuff and hence a special near/far distances of 1 to 200. (instead of usual 1 to 20000 or so). should be fixed by setting the near distance to 0.01f or so…
But there's another problem. If I translate the whole terrain, getHeight() returns the original value.
Ok I can solve this by translating the terrainPage by a static value and adding this to the result of every getHeight() in my whole code, but I don't think this is the right way to do it…
The need of translating is because of my raw terrain file. The lowest value in there is zero and thats the same height of the projectedGrid which I'm not allowed to translate.
if you translate the water, you need to update the waterPlane variable too.
waterEffectRenderPass.setWaterPlane( new Plane( new Vector3f( 0.0f, 1.0f, 0.0f ), 0.0f ) ); // first param = normal, second = translation through normal