Panda3D
lineSegs.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file lineSegs.I
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 /**
15  *
16  */
17 INLINE LineSegs::Point::
18 Point() {
19 }
20 
21 /**
22  *
23  */
24 INLINE LineSegs::Point::
25 Point(const LVecBase3 &point, const LColor &color) :
26  _point(point[0], point[1], point[2]),
27  _color(color)
28 {
29 }
30 
31 /**
32  *
33  */
34 INLINE LineSegs::Point::
35 Point(const LineSegs::Point &copy) :
36  _point(copy._point),
37  _color(copy._color)
38 {
39 }
40 
41 /**
42  *
43  */
44 INLINE void LineSegs::Point::
45 operator = (const LineSegs::Point &copy) {
46  _point = copy._point;
47  _color = copy._color;
48 }
49 
50 
51 /**
52  * Establishes the color that will be assigned to all vertices created by
53  * future calls to move_to() and draw_to().
54  */
55 INLINE void LineSegs::
56 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
57  _color.set(r, g, b, a);
58 }
59 
60 /**
61  * Establishes the color that will be assigned to all vertices created by
62  * future calls to move_to() and draw_to().
63  */
64 INLINE void LineSegs::
65 set_color(const LColor &color) {
66  _color = color;
67 }
68 
69 /**
70  * Establishes the line thickness or point size in pixels that will be
71  * assigned to all lines and points created by future calls to create().
72  */
73 INLINE void LineSegs::
74 set_thickness(PN_stdfloat thick) {
75  _thick = thick;
76 }
77 
78 /**
79  * Moves the pen to the given point without drawing a line. When followed by
80  * draw_to(), this marks the first point of a line segment; when followed by
81  * move_to() or create(), this creates a single point.
82  */
83 INLINE void LineSegs::
84 move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
85  move_to(LVertex(x, y, z));
86 }
87 
88 /**
89  * Draws a line segment from the pen's last position (the last call to move_to
90  * or draw_to) to the indicated point. move_to() and draw_to() only update
91  * tables; the actual drawing is performed when create() is called.
92  */
93 INLINE void LineSegs::
94 draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
95  draw_to(LVertex(x, y, z));
96 }
97 
98 /**
99  * Creates a new GeomNode that will render the series of line segments and
100  * points described via calls to move_to() and draw_to(). The lines and
101  * points are created with the color and thickness established by calls to
102  * set_color() and set_thick().
103  *
104  * If dynamic is true, the line segments will be created with the dynamic Geom
105  * setting, optimizing them for runtime vertex animation.
106  */
107 INLINE GeomNode *LineSegs::
108 create(bool dynamic) {
109  GeomNode *gnode = new GeomNode(get_name());
110  return create(gnode, dynamic);
111 }
112 
113 /**
114  * Returns the total number of line segment and point vertices generated by
115  * the last call to create(). The positions of these vertices may be read and
116  * adjusted through get_vertex() and set_vertex().
117  */
118 INLINE int LineSegs::
119 get_num_vertices() const {
120  if (_created_data == nullptr) {
121  return 0;
122  }
123  return _created_data->get_num_rows();
124 }
125 
126 /**
127  * Moves the nth point or vertex of the line segment sequence generated by the
128  * last call to create(). The first move_to() generates vertex 0; subsequent
129  * move_to() and draw_to() calls generate consecutively higher vertex numbers.
130  */
131 INLINE void LineSegs::
132 set_vertex(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
133  set_vertex(n, LVertex(x, y, z));
134 }
135 
136 /**
137  * Changes the vertex color of the nth point or vertex. See set_vertex().
138  */
139 INLINE void LineSegs::
140 set_vertex_color(int n, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
141  set_vertex_color(n, LColor(r, g, b, a));
142 }
GeomNode * create(bool dynamic=false)
Creates a new GeomNode that will render the series of line segments and points described via calls to...
Definition: lineSegs.I:108
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0f)
Establishes the color that will be assigned to all vertices created by future calls to move_to() and ...
Definition: lineSegs.I:56
void set_thickness(PN_stdfloat thick)
Establishes the line thickness or point size in pixels that will be assigned to all lines and points ...
Definition: lineSegs.I:74
void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Moves the pen to the given point without drawing a line.
Definition: lineSegs.I:84
void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Draws a line segment from the pen's last position (the last call to move_to or draw_to) to the indica...
Definition: lineSegs.I:94
void set_vertex(int n, const LVertex &vert)
Moves the nth point or vertex of the line segment sequence generated by the last call to create().
Definition: lineSegs.cxx:120
void set_vertex_color(int vertex, const LColor &c)
Changes the vertex color of the nth point or vertex.
Definition: lineSegs.cxx:142
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34