Panda3D
Public Member Functions | List of all members
LineSegs Class Reference

Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays. More...

Inheritance diagram for LineSegs:
Namable

Public Member Functions

 __init__ (const LineSegs)
 
 __init__ (str name)
 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. More...
 
GeomNode create (GeomNode previous, bool dynamic)
 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(). More...
 
GeomNode create (bool dynamic)
 Creates a new GeomNode that will render the series of line segments and points described via calls to move_to() and draw_to(). More...
 
 drawTo (const LVecBase3 v)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point. More...
 
 drawTo (float x, float y, float z)
 Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indicated point. More...
 
const LVertex getCurrentPosition ()
 Returns the pen's current position. More...
 
int getNumVertices ()
 Returns the total number of line segment and point vertices generated by the last call to create(). More...
 
LVertex getVertex (int n)
 Returns the nth point or vertex of the line segment sequence generated by the last call to create(). More...
 
LColor getVertexColor (int vertex)
 Returns the color of the nth point or vertex. More...
 
list getVertexColors ()
 
list getVertices ()
 
bool isEmpty ()
 Returns true if move_to() or draw_to() have not been called since the last reset() or create(), false otherwise. More...
 
 moveTo (const LVecBase3 v)
 Moves the pen to the given point without drawing a line. More...
 
 moveTo (float x, float y, float z)
 Moves the pen to the given point without drawing a line. More...
 
 reset ()
 Removes any lines in progress and resets to the initial empty state. More...
 
 setColor (const LColor color)
 Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to(). More...
 
 setColor (float r, float g, float b, float a)
 Establishes the color that will be assigned to all vertices created by future calls to move_to() and draw_to(). More...
 
 setThickness (float 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(). More...
 
 setVertex (int n, const LVertex vert)
 Moves the nth point or vertex of the line segment sequence generated by the last call to create(). More...
 
 setVertex (int vertex, float x, float y, float z)
 Moves the nth point or vertex of the line segment sequence generated by the last call to create(). More...
 
 setVertexColor (int vertex, const LColor c)
 Changes the vertex color of the nth point or vertex. More...
 
 setVertexColor (int vertex, float r, float g, float b, float a)
 Changes the vertex color of the nth point or vertex. More...
 
- Public Member Functions inherited from Namable
 __init__ (const Namable)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
 output (Ostream out)
 Outputs the Namable. More...
 
 setName (str name)
 

Additional Inherited Members

- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 
- Public Attributes inherited from Namable
const String name
 

Detailed Description

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const  LineSegs)

◆ __init__() [2/2]

__init__ ( str  name)

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.

◆ create() [1/2]

GeomNode create ( GeomNode  previous,
bool  dynamic 
)

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_thick().

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

◆ create() [2/2]

GeomNode create ( bool  dynamic)

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_thick().

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

◆ drawTo() [1/2]

drawTo ( const LVecBase3  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.

◆ drawTo() [2/2]

drawTo ( float  x,
float  y,
float  z 
)

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.

◆ getCurrentPosition()

const LVertex getCurrentPosition ( )

Returns the pen's current position.

The next call to draw_to() will draw a line segment from this point.

◆ getNumVertices()

int getNumVertices ( )

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().

◆ getVertex()

LVertex getVertex ( int  n)

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.

◆ getVertexColor()

LColor getVertexColor ( int  vertex)

Returns the color of the nth point or vertex.

◆ getVertexColors()

list getVertexColors ( )

◆ getVertices()

list getVertices ( )

◆ isEmpty()

bool isEmpty ( )

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

◆ moveTo() [1/2]

moveTo ( const LVecBase3  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.

◆ moveTo() [2/2]

moveTo ( float  x,
float  y,
float  z 
)

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.

◆ reset()

reset ( )

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

◆ setColor() [1/2]

setColor ( const LColor  color)

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

◆ setColor() [2/2]

setColor ( float  r,
float  g,
float  b,
float  a 
)

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

◆ setThickness()

setThickness ( float  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().

◆ setVertex() [1/2]

setVertex ( int  n,
const LVertex  vert 
)

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.

◆ setVertex() [2/2]

setVertex ( int  vertex,
float  x,
float  y,
float  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.

◆ setVertexColor() [1/2]

setVertexColor ( int  vertex,
const LColor  c 
)

Changes the vertex color of the nth point or vertex.

See set_vertex().

◆ setVertexColor() [2/2]

setVertexColor ( int  vertex,
float  r,
float  g,
float  b,
float  a 
)

Changes the vertex color of the nth point or vertex.

See set_vertex().