1
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

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);
\$\endgroup\$
1
  • \$\begingroup\$ 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); \$\endgroup\$ Commented Jan 11, 2015 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .