Water and multiple cameras

Hi.

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 :
http://laurent.jeanpierre1.free.fr/extract.ogv
http://laurent.jeanpierre1.free.fr/extract.avi

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:
[java]
view.addProcessor(waterProcessor);
[/java]

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:
[java]
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);
water.setShadowMode(RenderQueue.ShadowMode.Receive);
water.setMaterial(waterProcessor.getMaterial());
[/java]
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
[java]
Node scene = createScene(); //as you do right now but without the water;
viewport1.addScene(scene);
viewport2.addScene(scene);
viewport3.addScene(scene);
viewport4.addScene(scene);

Node water1 = createWater(); //create the water plane 1 and add it to a node
waterProcessor1 = createWaterProcessor();
waterProcessor1.setReflectionScene(scene)
water1.setMaterial(waterProcessor1.getMaterial);
viewport1.addScene(water1);
viewport1.addProcessor(waterProcessor1);

Node water2 = createWater(); //create the water plane 2 and add it to a node
waterProcessor2 = createWaterProcessor();
waterProcessor2.setReflectionScene(scene)
water2.setMaterial(waterProcessor2.getMaterial);
viewport2.addScene(water2);
viewport2.addProcessor(waterProcessor2);

Node water3 = createWater(); //create the water plane 3 and add it to a node
waterProcessor3 = createWaterProcessor();
waterProcessor3.setReflectionScene(scene)
water3.setMaterial(waterProcessor3.getMaterial);
viewport3.addScene(water3);
viewport3.addProcessor(waterProcessor3);

Node water4 = createWater(); //create the water plane 4 and add it to a node
waterProcessor4 = createWaterProcessor();
waterProcessor4.setReflectionScene(scene)
water4.setMaterial(waterProcessor4.getMaterial);
viewport4.addScene(water4);
viewport4.addProcessor(waterProcessor4);

[/java]

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!