Water and multiple cameras


it seems to me that the speed of water waves depend on the number of viewers. Maybe I did something wrong…

Let me explain:

  • The scene has a water plane with a SimpleWaterProcessor.
  • Several cameras evolve in the environment, each with a specific viewport attached.

-> when viewports are activated, waves seem much quicker than when there is only the main one.

Any idea on how to overcome this? Maybe changing the waves speed ?

Here is a video which shows the trouble :

You add the same scene to multiple viewports? Then it will obviously be updated multiple times.

What do you mean?
update function is called for each viewport ??? I does not make sense to me.

I thought update was the place to update the world. The number of people seeing a scene should no impact on the way it behave. Am I totally wrong?

Thus, to make it correct, you mean I should have 7 different root nodes, all containing the same data at the same place, and updated accordingly? With a different camera/viewport in each?

1 Like

no i guess you are adding the same water processor to the different viewports, right?
try using a separate intsance per viewport

@nehon: Yes you are right:

So I should use a different instance of the processor, with the same geometry attached?
How can I do this? For the moment, I use:
Quad quad = new Quad(800, 800);
quad.scaleTextureCoordinates(new Vector2f(12f, 12f));
Geometry water = new Geometry(“water”, quad);
water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
water.setLocalTranslation(-400, -6, 450);
I think this is from the tutorial.

I don’t see how to change it, because the water geometry can have only one texture…

mhhh true…
Anyway you’re not supposed to add the same processor to different viewports.
A workaround could be to have one scene for everything, and one additional scene per viewport with different water geoms.

pseudo code would be
Node scene = createScene(); //as you do right now but without the water;

Node water1 = createWater(); //create the water plane 1 and add it to a node
waterProcessor1 = createWaterProcessor();

Node water2 = createWater(); //create the water plane 2 and add it to a node
waterProcessor2 = createWaterProcessor();

Node water3 = createWater(); //create the water plane 3 and add it to a node
waterProcessor3 = createWaterProcessor();

Node water4 = createWater(); //create the water plane 4 and add it to a node
waterProcessor4 = createWaterProcessor();


1 Like
@yang71 said: update function is called for each viewport ??? I does not make sense to me.
So whats your suggestion on why you see what you see?

@Nehon : Thanks a lot, I will try this

@Normen : No offense implied; I just try and understand.
I thought that maybe the “update” of the processor was run once per enabled viewport, since it was added several times.

It just so different of what I thought. It means my AI algorithm should not run there, because it will run once per enabled viewport.
It means also that mobile objects should move faster when more viewports are enabled…
I have to look into it for more details!

I think there is a misunderstanding.
Actually “update” is run once per frame and is managed by the simple application.
It’s responsible of calling appstates update and it also updateLogicalState (update on controls) and updateGeometricState (update transforms) on the rootNode, and the GUINode.
If you have additional scene you should call manually updateLogicalState and updateGeometricState (btw i forgot to mention that in my previous example)
However the “render” method is called once per viewport.

Thanks Nehon. This is coherent with what I observed.
And of course, each processor is called viewport per viewport, which is logical. This explains my strange (but normal) wave speed.

All is clear now. Thanks again!