Clipping Node - for a window

Is there function to be able to clip inside a node.

Or maybe someone can tell me how to do it in JME

I’m looking to create a window that has text and want to clip the text to be inside the parent NODE, instead of the parent node grow to match the size.

Basically just want a window to scroll.
Not using nifty or any other gui libraries. Just doing it myself, my windows are basic and didn’t need all that over head.

I am not sure if i understood the question clearly, but do you want to create a TextView with a frame boundaries, don’t you ? ,

If so then, if you are using a BitmapText then try setting its width & height to the scale.x & scale.y of your frame respectively or less than them by a particular padding value, but i have no idea how specifically in your situation since you haven’t showed a photo or a code, may be showing a glance of them would give insights to help.
So, something like :

float padding = 0.5f; // or insets
bitmapText.setBox(new Rectangle(frame.getLocalTranslation().x, frame.getLocalTranslation().y, frame.getLocalScale().x - padding, frame.getLocalScale().y - padding));

where frame is your frame quad or image.

image

So I hope this helps. I have a viewport for the total render area. I want to create a panel and attach Children to the panel. Want to define panel to a certain size, not have it grow to the size of the total children. And then only the children within the area are rendered.

This is super easy using glScissors() function, but with JME, the render process is taken out of the hands of the programmer, atleast I can’t find anything (still new), appears to be high level access only and the entire lower function calls of opengl are hidden and removed from being accessed and use them correctly.

Like being able to turn on glScissor only when a certain node is rendered, appears impossible because there are not post/pre render functions to a node so you could do things like this.

Does anyone have any other ideas how to do this.

Thanks ahead of time,

1 Like

The best way to do this would be to create a second viewport with the dimensions and position of your blue panel box, and then when you translate the yellow collection of nodes the parts outside of the viewport will be clipped.

I know you said you don’t want any extra overhead, but the easiest way to do this would probably be to use the Lemur GUI library’s ViewportPanel object. Otherwise you’ll likely be rewriting a lot of your own overhead code to achieve the same thing, but I’m no expert in this field and just chose to use Lemur when I needed scroll boxes for my project.

There’s also this other thread discussing how to do scrollable areas with Lemur, and this specific post has a good code example showing how to do it

3 Likes

Actually, I wouldn’t be writing very much new code. This is not a new project. I’m converting my game from my own engine into JME3. So far it is a bunch of copy/paste to get it into JME format. Like creating a Node and Control or AppState and then copying code from old engine into correction function and change minor stuff.

I basically create new lower level classes that my engine uses and extended a JME3 class that matches it functions. This way I don’t have to rewrite a ton of code. It takes about 2 - 3 mins. to get the entire new gui working.

Just came across an issue with the Help Gui that basically has a panel that can scroll. I have all the features of the scroll, just needed a way to clip content outside of viewing area.

I’ll look at doing it through a new viewport and attach it to my FrameBuffer Gui Node where everything is rendered to.
I don’t render to live Nodes, only to textures and alter them with many filters to get the final texture and attach that to the gui to render.

Thanks for the idea.

1 Like