Panda3D
Loading...
Searching...
No Matches
lineSegs.h
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.h
10 * @author drose
11 * @date 2002-03-16
12 */
13
14#ifndef LINESEGS_H
15#define LINESEGS_H
16
17#include "pandabase.h"
18
19#include "luse.h"
20#include "geom.h"
21#include "geomNode.h"
22#include "geomVertexData.h"
23#include "namable.h"
24
25#include "pvector.h"
26
27/**
28 * Encapsulates creation of a series of connected or disconnected line
29 * segments or points, for drawing paths or rays. This class doesn't attempt
30 * to be the smartest it could possibly be; it's intended primarily as a
31 * visualization and editing tool.
32 */
33class EXPCL_PANDA_GRUTIL LineSegs : public Namable {
34PUBLISHED:
35 explicit LineSegs(const std::string &name = "lines");
36 ~LineSegs();
37
38 void reset();
39 INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
40 INLINE void set_color(const LColor &color);
41 INLINE void set_thickness(PN_stdfloat thick);
42
43 INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
44 void move_to(const LVecBase3 &v);
45
46 INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
47 void draw_to(const LVecBase3 &v);
48
49 const LVertex &get_current_position();
50 bool is_empty();
51
52 INLINE GeomNode *create(bool dynamic = false);
53 GeomNode *create(GeomNode *previous, bool dynamic = false);
54
55 // Functions to move the line vertices after they have been created.
56 INLINE int get_num_vertices() const;
57 LVertex get_vertex(int n) const;
58 MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
59 void set_vertex(int n, const LVertex &vert);
60 INLINE void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
61
62 LColor get_vertex_color(int vertex) const;
63 MAKE_SEQ(get_vertex_colors, get_num_vertices, get_vertex_color);
64 void set_vertex_color(int vertex, const LColor &c);
65 INLINE void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f);
66
67private:
68 class Point {
69 public:
70 INLINE Point();
71 INLINE Point(const LVecBase3 &point, const LColor &color);
72 INLINE Point(const Point &copy);
73 INLINE void operator = (const Point &copy);
74
75 LVertex _point;
76 UnalignedLVecBase4 _color;
77 };
78
79 typedef pvector<Point> SegmentList;
80 typedef pvector<SegmentList> LineList;
81
82 LineList _list;
83 LColor _color;
84 PN_stdfloat _thick;
85
86 PT(GeomVertexData) _created_data;
87};
88
89#include "lineSegs.I"
90
91#endif
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
LineSegs(const std::string &name="lines")
Constructs a LineSegs object, which can be used to create any number of disconnected lines or points ...
Definition lineSegs.cxx:32
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 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
get_vertex_color
Returns the color of the nth point or vertex.
Definition lineSegs.h:63
void reset()
Removes any lines in progress and resets to the initial empty state.
Definition lineSegs.cxx:50
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
get_num_vertices
Returns the total number of line segment and point vertices generated by the last call to create().
Definition lineSegs.h:58
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_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
bool is_empty()
Returns true if move_to() or draw_to() have not been called since the last reset() or create(),...
Definition lineSegs.cxx:96
void set_vertex_color(int vertex, const LColor &c)
Changes the vertex color of the nth point or vertex.
Definition lineSegs.cxx:142
get_vertex
Returns the nth point or vertex of the line segment sequence generated by the last call to create().
Definition lineSegs.h:58
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
const LVertex & get_current_position()
Returns the pen's current position.
Definition lineSegs.cxx:154
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.