How to draw edges (with colors) on Box

Hi guys, I am new in JME and trying to draw a Treemap with many Boxes. In some cases there will be boxes with same colors and I want to separate them with lines (or borders or color edges) on Box… I try WireBox but then I lost color filling and I need color for mapping atributes… Can anybody help with that?
Now I have got left side pic… and want something like on right side


It will be great if that lines will be there… color of that lines isnt so important…
Thanks if you answer me! :slight_smile:

Clone the geometry make it wireframe and attach it to a different viewport or scene, this is how bullet shows the debug wireframe for collision shapes.
You can of course use the same scene for both of them and just add the new wireframe geometry to your simpleApp.rootNode if having them mixed together is not an issue for your design.

Or, you can draw the border in the fragment shader.

It depends on the reason why you want the border, if it’s for the end user and you have control over the materials: use the shader, if you need it just for you during development or you can’t know which material will be set to the boxes: use the wireframe approach.

1 Like

Everyone always suggests this, but wouldn’t wireframe look like this?

I’m pretty sure that’s not what he needs, but I don’t really know any alternatives besides using shaders. Actually wouldn’t the default toon filter look kind of like that?

1 Like

Yeah, you are right, then a wirebox can be used instead.
But this is not the only issue, the wirebox must be slightly bigger to be properly visible, i agree that the shader way is much more cleaner.

Actually I just had an idea. You know those debug shapes? I remember the arrow geometry supports line width and color. Perhaps this could be adapted slightly to display a box instead…

1 Like

Or use the wire box… because that’s what it’s for. Then set the line width on it.

4 Likes

Thanks all for tips, maybe I see possible solution here using that debug shapes or fragment shader. I am going to try it today or tomorow then give you update which was the best. :slight_smile:

Oh. Right. Lol. :smile:

Finally, I used new WireBox with the same x,y,z sizes as my boxes, on material I set color to RGBA.Black and on wirebox I set .setLineWidth(2)… worked awesome! thanks all for help :slight_smile:

2 Likes

I ended up testing it out in my game too the other day to display part bounding boxes and it looks alright so I’m keeping it.

Used the same line width I think.

2 Likes