I have a scene with multiple 3D objects (a simple space shooter) and want to draw those gui rectangles around them to indicate targets / friends / foes etc…
Currently I’m using a node in the gui bucket that holds a simple quad and is updated every frame from the bounding volume of the tracked spatial. Unfortunately I have not been able to get the transparent texture to work, so the only thing i see is a black quad
[java]
q = new Quad(200, 200);
g = new Geometry(“BorderQuad”, q);
Material mat = new Material(am, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Green);
Texture tex = am.loadTexture(“texBorder.png”);
mat.setTexture(“ColorMap”, tex);
g.setMaterial(mat);
[/java]
Additionally, I was wondering if there is a better way to draw a rectangle than to have a quad (or multiple to show health bars etc) for every spatial I want to mark.
You can use 4 simple lines to draw a box, it is easy to scale then and won’t get distorted like a texture will.
To make your texture transparent however, you need to specify it as such:
[java]material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);[/java]
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material
Thank you, that worked. You are right, the lines seem to be the better option.