Panda3D
|
00001 // Filename: lineSegs.h 00002 // Created by: drose (16Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef LINESEGS_H 00016 #define LINESEGS_H 00017 00018 #include "pandabase.h" 00019 00020 #include "luse.h" 00021 #include "geom.h" 00022 #include "geomNode.h" 00023 #include "geomVertexData.h" 00024 #include "namable.h" 00025 00026 #include "pvector.h" 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : LineSegs 00030 // Description : Encapsulates creation of a series of connected or 00031 // disconnected line segments or points, for drawing 00032 // paths or rays. This class doesn't attempt to be the 00033 // smartest it could possibly be; it's intended 00034 // primarily as a visualization and editing tool. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDA_GRUTIL LineSegs : public Namable { 00037 PUBLISHED: 00038 LineSegs(const string &name = "lines"); 00039 ~LineSegs(); 00040 00041 void reset(); 00042 INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f); 00043 INLINE void set_color(const LColor &color); 00044 INLINE void set_thickness(PN_stdfloat thick); 00045 00046 INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); 00047 void move_to(const LVecBase3 &v); 00048 00049 INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); 00050 void draw_to(const LVecBase3 &v); 00051 00052 const LVertex &get_current_position(); 00053 bool is_empty(); 00054 00055 INLINE GeomNode *create(bool dynamic = false); 00056 GeomNode *create(GeomNode *previous, bool dynamic = false); 00057 00058 // Functions to move the line vertices after they have been created. 00059 INLINE int get_num_vertices() const; 00060 LVertex get_vertex(int n) const; 00061 MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); 00062 void set_vertex(int n, const LVertex &vert); 00063 INLINE void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); 00064 00065 LColor get_vertex_color(int vertex) const; 00066 MAKE_SEQ(get_vertex_colors, get_num_vertices, get_vertex_color); 00067 void set_vertex_color(int vertex, const LColor &c); 00068 INLINE void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f); 00069 00070 private: 00071 class Point { 00072 public: 00073 INLINE Point(); 00074 INLINE Point(const LVecBase3 &point, const LColor &color); 00075 INLINE Point(const Point ©); 00076 INLINE void operator = (const Point ©); 00077 00078 LVertex _point; 00079 UnalignedLVecBase4 _color; 00080 }; 00081 00082 typedef pvector<Point> SegmentList; 00083 typedef pvector<SegmentList> LineList; 00084 00085 LineList _list; 00086 LColor _color; 00087 PN_stdfloat _thick; 00088 00089 PT(GeomVertexData) _created_data; 00090 }; 00091 00092 #include "lineSegs.I" 00093 00094 #endif