Panda3D
 All Classes Functions Variables Enumerations
lineSegs.I
00001 // Filename: lineSegs.I
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 ////////////////////////////////////////////////////////////////////
00016 //     Function: LineSegs::Point::Constructor
00017 //       Access: Public
00018 //  Description:
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE LineSegs::Point::
00021 Point() {
00022 }
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: LineSegs::Point::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 INLINE LineSegs::Point::
00030 Point(const LVecBase3 &point, const LColor &color) :
00031   _point(point[0], point[1], point[2]),
00032   _color(color)
00033 {
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: LineSegs::Point::Copy Constructor
00038 //       Access: Public
00039 //  Description:
00040 ////////////////////////////////////////////////////////////////////
00041 INLINE LineSegs::Point::
00042 Point(const LineSegs::Point &copy) :
00043   _point(copy._point),
00044   _color(copy._color)
00045 {
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: LineSegs::Point::Copy Assignment Operator
00050 //       Access: Public
00051 //  Description:
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE void LineSegs::Point::
00054 operator = (const LineSegs::Point &copy) {
00055   _point = copy._point;
00056   _color = copy._color;
00057 }
00058 
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: LineSegs::set_color
00062 //       Access: Public
00063 //  Description: Establishes the color that will be assigned to all
00064 //               vertices created by future calls to move_to() and
00065 //               draw_to().
00066 ////////////////////////////////////////////////////////////////////
00067 INLINE void LineSegs::
00068 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
00069   _color.set(r, g, b, a);
00070 }
00071 
00072 ////////////////////////////////////////////////////////////////////
00073 //     Function: LineSegs::set_color
00074 //       Access: Public
00075 //  Description: Establishes the color that will be assigned to all
00076 //               vertices created by future calls to move_to() and
00077 //               draw_to().
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE void LineSegs::
00080 set_color(const LColor &color) {
00081   _color = color;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: LineSegs::set_thickness
00086 //       Access: Public
00087 //  Description: Establishes the line thickness or point size in
00088 //               pixels that will be assigned to all lines and points
00089 //               created by future calls to create().
00090 ////////////////////////////////////////////////////////////////////
00091 INLINE void LineSegs::
00092 set_thickness(PN_stdfloat thick) {
00093   _thick = thick;
00094 }
00095 
00096 ////////////////////////////////////////////////////////////////////
00097 //     Function: LineSegs::move_to
00098 //       Access: Public
00099 //  Description: Moves the pen to the given point without drawing a
00100 //               line.  When followed by draw_to(), this marks the
00101 //               first point of a line segment; when followed by
00102 //               move_to() or create(), this creates a single point.
00103 ////////////////////////////////////////////////////////////////////
00104 INLINE void LineSegs::
00105 move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00106   move_to(LVertex(x, y, z));
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: LineSegs::draw_to
00111 //       Access: Public
00112 //  Description: Draws a line segment from the pen's last position
00113 //               (the last call to move_to or draw_to) to the
00114 //               indicated point.  move_to() and draw_to() only update
00115 //               tables; the actual drawing is performed when create()
00116 //               is called.
00117 ////////////////////////////////////////////////////////////////////
00118 INLINE void LineSegs::
00119 draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00120   draw_to(LVertex(x, y, z));
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: LineSegs::create
00125 //       Access: Public
00126 //  Description: Creates a new GeomNode that will render the series of
00127 //               line segments and points described via calls to
00128 //               move_to() and draw_to().  The lines and points are
00129 //               created with the color and thickness established by
00130 //               calls to set_color() and set_thick().
00131 //
00132 //               If dynamic is true, the line segments will be created
00133 //               with the dynamic Geom setting, optimizing them for
00134 //               runtime vertex animation.
00135 ////////////////////////////////////////////////////////////////////
00136 INLINE GeomNode *LineSegs::
00137 create(bool dynamic) {
00138   GeomNode *gnode = new GeomNode(get_name());
00139   return create(gnode, dynamic);
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: LineSegs::get_num_vertices
00144 //       Access: Public
00145 //  Description: Returns the total number of line segment and point
00146 //               vertices generated by the last call to create().  The
00147 //               positions of these vertices may be read and adjusted
00148 //               through get_vertex() and set_vertex().
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE int LineSegs::
00151 get_num_vertices() const {
00152   if (_created_data == (GeomVertexData *)NULL) {
00153     return 0;
00154   }
00155   return _created_data->get_num_rows();
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: LineSegs::set_vertex
00160 //       Access: Public
00161 //  Description: Moves the nth point or vertex of the line segment
00162 //               sequence generated by the last call to create().  The
00163 //               first move_to() generates vertex 0; subsequent
00164 //               move_to() and draw_to() calls generate consecutively
00165 //               higher vertex numbers.
00166 ////////////////////////////////////////////////////////////////////
00167 INLINE void LineSegs::
00168 set_vertex(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00169   set_vertex(n, LVertex(x, y, z));
00170 }
00171 
00172 ////////////////////////////////////////////////////////////////////
00173 //     Function: LineSegs::set_vertex_color
00174 //       Access: Public
00175 //  Description: Changes the vertex color of the nth point or vertex.
00176 //               See set_vertex().
00177 ////////////////////////////////////////////////////////////////////
00178 INLINE void LineSegs::
00179 set_vertex_color(int n, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
00180   set_vertex_color(n, LColor(r, g, b, a));
00181 }
 All Classes Functions Variables Enumerations