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);
mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
and geometry.setCullHint(Spatial.CullHint.Never);
\$\endgroup\$
Commented
Jan 11, 2015 at 18:10