Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/grutil/lineSegs.h

Go to the documentation of this file.
00001 // Filename: lineSegs.h
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef LINESEGS_H
00020 #define LINESEGS_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "luse.h"
00025 #include "geom.h"
00026 #include "geomPoint.h"
00027 #include "geomLine.h"
00028 #include "geomLinestrip.h"
00029 #include "geomNode.h"
00030 #include "namable.h"
00031 
00032 #include "pvector.h"
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //       Class : LineSegs
00036 // Description : Encapsulates creation of a series of connected or
00037 //               disconnected line segments or points, for drawing
00038 //               paths or rays.  This class doesn't attempt to be the
00039 //               smartest it could possibly be; it's intended
00040 //               primarily as a visualization and editing tool.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA LineSegs : public Namable {
00043 PUBLISHED:
00044   LineSegs(const string &name = "lines");
00045   ~LineSegs();
00046 
00047   void reset();
00048   INLINE void set_color(float r, float g, float b, float a = 1.0f);
00049   INLINE void set_color(const Colorf &color);
00050   INLINE void set_thickness(float thick);
00051 
00052   INLINE void move_to(float x, float y, float z);
00053   void move_to(const LVecBase3f &v);
00054 
00055   INLINE void draw_to(float x, float y, float z);
00056   void draw_to(const LVecBase3f &v);
00057 
00058   const Vertexf &get_current_position();
00059   bool is_empty();
00060 
00061   INLINE GeomNode *create(bool frame_accurate = false);
00062   GeomNode *create(GeomNode *previous, bool frame_accurate = false);
00063 
00064   // Functions to move the line vertices after they have been created.
00065   INLINE int get_num_vertices() const;
00066 
00067   INLINE Vertexf get_vertex(int vertex) const;
00068   INLINE void set_vertex(int vertex, const Vertexf &vert);
00069   INLINE void set_vertex(int vertex, float x, float y, float z);
00070 
00071   INLINE Colorf get_vertex_color(int vertex) const;
00072   INLINE void set_vertex_color(int vertex, const Colorf &color);
00073   INLINE void set_vertex_color(int vertex, float r, float g, float b, float a = 1.0f);
00074 
00075 private:
00076   class Point {
00077   public:
00078     INLINE Point();
00079     INLINE Point(const LVecBase3f &point, const Colorf &color);
00080     INLINE Point(const Point &copy);
00081     INLINE void operator = (const Point &copy);
00082 
00083     Vertexf _point;
00084     Colorf _color;
00085   };
00086 
00087   typedef pvector<Point> SegmentList;
00088   typedef pvector<SegmentList> LineList;
00089 
00090   LineList _list;
00091   Colorf _color;
00092   float _thick;
00093 
00094   PTA_Vertexf _created_verts;
00095   PTA_Colorf _created_colors;
00096 };
00097 
00098 #include "lineSegs.I"
00099 
00100 #endif

Generated on Fri May 2 00:39:46 2003 for Panda by doxygen1.3