Drawing lines

Hi, Is there a way to draw a line between two 3d points? I would also possibly like to vary the thickness of the lines


Yup, here you go.

lines = LineSegs()
node = lines.create()
np = NodePath(node)

Ahhh… thanks that works.
Is there a way to change the line color? I could not find anything about what you mentioned in the docs.

Yes, there are ways.

The manual is not the only piece of documentation. It’s just for getting you started, and to explain a few concepts. Much more important if the API reference. Look at the documentation of the class LineSegs, and look there for methods which have “color” or “thickness” in their name:



You can also just do a setColor on the node.

I draw lots of lines in my game and they are slow. I am wondering if it would be faster to create a geom with say 1000 vertexes and just use vertex rewriter and if have extra just draw 0 length lines?

But that is more advanced feature not recommended for newbies.

I tried this code but it seems that the line thickness only goes so far. I need to get it thicker. Any suggestions?

No its a hardware limit. If you want lines generated with real geometry (rectangles that look like lines) you might have to wait till 1.6.0 and then use MeshDrawer