How To Limit draw of Node to chosen Limit(Solve)

It’s intended to demonstrate rendering to a texture… which you could then use for anything you could use a texture for.

Then i shall say thank you for the help. I had no idea i was working like an idiot there. Then i will generate a normal viewport and clear the color!

Well, you don’t want to clear the color… but I think I know what you mean. :smile:

Rough steps:
-create viewport
-give it a camera with a limited viewport (confusing that camera has viewport settings but there you go)
-manage the viewport with an app state as already described

1 Like

You have no idea how many hours(up to many days and month) i ve been looking for this solution xD(i did so many hack to achieve the same result before haha but this time it wont be a mess)

Note: the one problem with using a regular viewport in a UI is that if you want other UI elements to overlay it then you can’t.

If you require that sort of sorting then you’d have to use render to texture, unfortunately.

Yea i had this comming, but can i stack multiple view port over each other?

Sort of… you can but you can’t change the order as far as I know.

In those cases, you’d be better off with the render to texture and getting alpha to work as I described.

Is it possible the view port is not working as it should when you set a specific camera size. My node are not following correctly the Main Node(the one I m setting at the start of the viewport).

Every tentative to resize and move the viewport have failed. I m using BitMapText and a personnal guiNode. If i leave the viewport at “chatCam.setViewPort(0.0f, 1.0f, 0.0f, 1.0f);” it work as it should. But i would like to move the chat from the left corner if possible but it seem to move the BitMapText Box limit
this=> ( input.setBox(new Rectangle(0, 40, FONT_SIZE * 256, chatCam.getHeight())); )
higher and higher the more i move the viewport and so I can’t see any text anymore. An example will be at the end.
By the way i move the viewport like this, “chatCam.setViewPort(0.0f, 1.0f, 0.5f, 1.5f);” It s the only way i found to make the viewport move.

    private void setupOffscreenView() {

        chatCam = new Camera(500, 300);

        chatViewPort = app.getRenderManager().createMainView("Chat View", chatCam);
        chatViewPort.setClearFlags(false, true, true);

//        chatViewPort.setBackgroundColor(viewPortColor);
        chatCam.setViewPort(0.0f, 1.0f, 0.0f, 1.0f);
        
        // attach the scene to the viewport to be rendered
        chatViewPort.attachScene(guiNode);

    }
    public Chat() {
        guiNode = new Node("Chat");
        guiNode.setQueueBucket(RenderQueue.Bucket.Gui);

        setupOffscreenView();

        input = generateFloatingText("write", ColorRGBA.DarkGray);
        input.setBox(new Rectangle(0, 40, FONT_SIZE * 256, chatCam.getHeight()));
        inputField.attachChild(input);

        inputField.setLocalTranslation(10, 0, 0);

        guiNode.attachChild(inputField);
        guiNode.setLocalTranslation(0, 0, 0);

    }

I have to say everything else is working perfectly, the problem must come from the BitMapText.
Even if i remove the rectangle it still make the text only spawn at the same exact location. Is it possible that the BitMapText is culled? Like it pretend to be at a certain location and it s not? (example out of the screen).
If I m not wrong the GuiNode is culled if it s detected to be out of the screen pixel.

edit: it only happen if i move the viewport.

Hmm… 1.5 for a camera view seems odd to me since that’s off the screen, I thought.

As far as I know, text is not doing anything strange. It’s just a bunch of quads in a mesh.

I guess it’s important to note that things in the GUI bucket are still positioned relative to the lower corner of the screen and not the viewport corner. (At least that’s my recollection.)