LineSegs

class LineSegs

Bases: Namable

Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays. This class doesn’t attempt to be the smartest it could possibly be; it’s intended primarily as a visualization and editing tool.

Inheritance diagram

Inheritance diagram of LineSegs

explicit LineSegs(std::string const &name = "lines")
LineSegs(LineSegs const&) = default

Constructs a LineSegs object, which can be used to create any number of disconnected lines or points of various thicknesses and colors through the visible scene. After creating the object, call move_to() and draw_to() repeatedly to describe the path, then call create() to create a GeomNode which will render the described path.

GeomNode *create(bool dynamic = false)
GeomNode *create(GeomNode *previous, bool dynamic = false)

Creates a new GeomNode that will render the series of line segments and points described via calls to move_to() and draw_to(). The lines and points are created with the color and thickness established by calls to set_color() and set_thickness().

If dynamic is true, the line segments will be created with the dynamic Geom setting, optimizing them for runtime vertex animation.

Appends to an existing GeomNode a new Geom that will render the series of line segments and points described via calls to move_to() and draw_to(). The lines and points are created with the color and thickness established by calls to set_color() and set_thickness().

If dynamic is true, the line segments will be created with the dynamic Geom setting, optimizing them for runtime vertex animation.

void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
void draw_to(LVecBase3 const &v)

Draws a line segment from the pen’s last position (the last call to move_to() or draw_to) to the indicated point. move_to() and draw_to() only update tables; the actual drawing is performed when create() is called.

LVertex const &get_current_position(void)

Returns the pen’s current position. The next call to draw_to() will draw a line segment from this point.

int get_num_vertices(void) const

Functions to move the line vertices after they have been created.

Functions to move the line vertices after they have been created.

Functions to move the line vertices after they have been created.

Returns the total number of line segment and point vertices generated by the last call to create(). The positions of these vertices may be read and adjusted through get_vertex() and set_vertex().

LVertex get_vertex(int n) const

Returns the nth point or vertex of the line segment sequence generated by the last call to create(). The first move_to() generates vertex 0; subsequent move_to() and draw_to() calls generate consecutively higher vertex numbers.

LColor get_vertex_color(int vertex) const

Returns the color of the nth point or vertex.

bool is_empty(void)

Returns true if move_to() or draw_to() have not been called since the last reset() or create(), false otherwise.

void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
void move_to(LVecBase3 const &v)

Moves the pen to the given point without drawing a line. When followed by draw_to(), this marks the first point of a line segment; when followed by move_to() or create(), this creates a single point.

void reset(void)

Removes any lines in progress and resets to the initial empty state.

void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0)
void set_color(LColor const &color)

Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to().

void set_thickness(PN_stdfloat thick)

Establishes the line thickness or point size in pixels that will be assigned to all lines and points created by future calls to create().

void set_vertex(int n, LVertex const &vert)
void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)

Moves the nth point or vertex of the line segment sequence generated by the last call to create(). The first move_to() generates vertex 0; subsequent move_to() and draw_to() calls generate consecutively higher vertex numbers.

void set_vertex_color(int vertex, LColor const &c)
void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0)

Changes the vertex color of the nth point or vertex. See set_vertex().