# How do I draw a line using jme3.scene.shape.Line in JMonkeyEngine 3.0?

I can successfully create the object, but it can't be attached to the rootNode. What can I do to make the line appear?

I'll also would like to know how to reverse the effect(making it disappear) shortly after if any special steps are involved.

The solution is actually quite easy.

The .attachChild() method of the rootNode object only accepts Nodes as it's argument. Therfore, a Geometry object must be created with the line object as its second arguement.

In addition, you can also set its material afterwards.

An example:

Line line = new Line(new Vector3f(0, 0, 0), new Vector3f(0, 100, 0));
line.setLineWidth(2);
Geometry geometry = new Geometry("Bullet", line);
Material orange = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
orange.setColor("Color", ColorRGBA.Blue);
geometry.setMaterial(orange);
rootNode.attachChild(geometry);

• to be able to see it all the time, I had to add both of these: mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off); and geometry.setCullHint(Spatial.CullHint.Never); – Aquarius Power Jan 11 '15 at 18:10