Panda3D
lineSegs.h
1 // Filename: lineSegs.h
2 // Created by: drose (16Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LINESEGS_H
16 #define LINESEGS_H
17 
18 #include "pandabase.h"
19 
20 #include "luse.h"
21 #include "geom.h"
22 #include "geomNode.h"
23 #include "geomVertexData.h"
24 #include "namable.h"
25 
26 #include "pvector.h"
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : LineSegs
30 // Description : Encapsulates creation of a series of connected or
31 // disconnected line segments or points, for drawing
32 // paths or rays. This class doesn't attempt to be the
33 // smartest it could possibly be; it's intended
34 // primarily as a visualization and editing tool.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_GRUTIL LineSegs : public Namable {
37 PUBLISHED:
38  LineSegs(const string &name = "lines");
39  ~LineSegs();
40 
41  void reset();
42  INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
43  INLINE void set_color(const LColor &color);
44  INLINE void set_thickness(PN_stdfloat thick);
45 
46  INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
47  void move_to(const LVecBase3 &v);
48 
49  INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
50  void draw_to(const LVecBase3 &v);
51 
52  const LVertex &get_current_position();
53  bool is_empty();
54 
55  INLINE GeomNode *create(bool dynamic = false);
56  GeomNode *create(GeomNode *previous, bool dynamic = false);
57 
58  // Functions to move the line vertices after they have been created.
59  INLINE int get_num_vertices() const;
60  LVertex get_vertex(int n) const;
61  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
62  void set_vertex(int n, const LVertex &vert);
63  INLINE void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
64 
65  LColor get_vertex_color(int vertex) const;
66  MAKE_SEQ(get_vertex_colors, get_num_vertices, get_vertex_color);
67  void set_vertex_color(int vertex, const LColor &c);
68  INLINE void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
69 
70 private:
71  class Point {
72  public:
73  INLINE Point();
74  INLINE Point(const LVecBase3 &point, const LColor &color);
75  INLINE Point(const Point &copy);
76  INLINE void operator = (const Point &copy);
77 
78  LVertex _point;
79  UnalignedLVecBase4 _color;
80  };
81 
84 
85  LineList _list;
86  LColor _color;
87  PN_stdfloat _thick;
88 
89  PT(GeomVertexData) _created_data;
90 };
91 
92 #include "lineSegs.I"
93 
94 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is an "unaligned" LVecBase4.
Definition: lvecBase4.h:300
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
A base class for all things which can have a name.
Definition: namable.h:29
Encapsulates creation of a series of connected or disconnected line segments or points, for drawing paths or rays.
Definition: lineSegs.h:36
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37