Viewports: Frames overlap

Dear everybody,
I’ve got a (probably really simple) question concerning viewports:
I’ve got a viewport, which is separate from the one that is shown on screen.
I’ve got my scene. What I do is:

Node scene;
Node copyOfScene = scene.clone();
//Doingsomeweirdstufftocopy commences.
//create camera
//create viewport
Viewport portyMcPortface = renderManager.createMainView(blabla);
// attach the scene, enableviewport, setoutputframebuffer
portyMcPortface.attach(copyOfScene);

Then I can see what I want to see using this viewport. So far, so good.
I need to update things while the game is running, because I want to make changes to copyOfScene.
So I have an update medthod like this:

Node anothercopy = copyOfScene.clone();
//do stuff to another copy
//attach to the Viewport
portyMcPortface.attach(anothercopy);

This I call from update.
What happens is that I get exactly what I want, (the scene with my changes made), BUT:
Several frames of the scene are rendered to the same image, meaning that several frames are “layed on top of each other”.

I am fairly certain that not detaching the scene is the problem, because the sceneList in the viewport just grows larger every update.
I tried to detach the “old” scene from the viewport, I tried to clean the viewport.
This works (no overlayed frames), BUT some of the stuff that I’ve done to the scene (to the non moving parts of the scene) is gone.(I am painting parts of the scenery in a certain way)

Can anyone point me into the right direction here? (Without giving me code, just a high level explanation where my understanding is wrong.)

please provide some screenshots or a video of the problem. I don’t fully understand your problem.

1 Like

Sorry. I’ll illustrate using mad paint skills. ( :wink: )
Consider a scene.


I want to point out that the boxes are not directly attached to the sceneNode, but are attached to their own node(s), which is attached to the sceneNode.

I copy the scene, I modify the copy, for example by painting yellow circles on the boxes.


This is what I want to see all the time.

Then, when the scene is loaded, “dynamic objects” (stuff that moves) are added, like this purple ball:


The ball moves to the right, so it’ll end here:

This is what I want to see in the viewport.
What I get instead is this:


Observe that both positions of the ball are rendered to the same image.

When I detach the old scene from the viewport (I copied the scene, right?), I’ll get what I want, but the yellow circles are gone, where they should still be there. I just want to understand why that happens.

Because what you are describing that you are doing is not what you are actually doing.

The view is showing what it has in it. It’s not manufacturing nodes.

For example, if your non-circle objects come back then it’s because they were still in the viewport. They might have been sorted behind the ones with circles but they were still there.

2-5 minutes of code to dump the contents of your nodes to logging/printlns or 5 minutes in the debugger should sort this out for you.

1 Like