How to outline a cube?

Hi all,

You know how in Google Sketchup you draw a cube or some other shape, and the edges are outlined in black? And how when you zoom in and out, the thickness of those outlines don’t change? How would that work in jMonkeyEngine? Sadly, I’m a total newb at 3D…




Material myMaterial = new Material(manager, “Common/MatDefs/Misc/WireColor.j3md”);

myMaterial.setColor(“m_Color”, ColorRGBA.Blue);





Edit: Or you mean a toon shader? Then look at the Toon Shader test.

Hmm, adding a WireColor material didn’t seem to work. It removed the color of the cube, and replaced it with lines that did not outline the cube, but rather added lines between the vertices like Z and X:

[java] public void simpleInitApp() {

Box b = new Box(Vector3f.ZERO, 1, 1, 1); // take a cube shape

Geometry geom = new Geometry(“Box”, b); // create a Spatial from it

Material mat = new Material(assetManager,

“Common/MatDefs/Misc/SolidColor.j3md”); // load a solid color material

mat.setColor(“m_Color”, ColorRGBA.Blue); // make the solid color blue

geom.setMaterial(mat); // give the box the solid blue material

Material myMaterial = new Material(assetManager, “Common/MatDefs/Misc/WireColor.j3md”);

myMaterial.setColor(“m_Color”, ColorRGBA.Black);


rootNode.attachChild(geom); // make the blue box appear in the scene




I suppose probably what I mean would be a toon shader, if that does outline shapes with lines that don’t change thickness with zoom level.

Cell shading? Take a look at the test case, I think something similar was there

The CartoonEdgeFilter does something similar.

try to add this in your scene

FilterPostProcessor fpp=new FilterPostProcessor(assetManager);

fpp.addFilter(new CartoonEdgeFilter());


The toon shader test does both the cartoon edge and cel-shading.

That worked. I think that will do what I need, thanks!