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

panda/src/grutil/lineSegs.I

Go to the documentation of this file.
00001 // Filename: lineSegs.I
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 ////////////////////////////////////////////////////////////////////
00020 //     Function: LineSegs::Point::Constructor
00021 //       Access: Public
00022 //  Description:
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE LineSegs::Point::
00025 Point() {
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: LineSegs::Point::Constructor
00030 //       Access: Public
00031 //  Description:
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE LineSegs::Point::
00034 Point(const LVecBase3f &point, const Colorf &color) :
00035   _point(point[0], point[1], point[2]),
00036   _color(color)
00037 {
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: LineSegs::Point::Copy Constructor
00042 //       Access: Public
00043 //  Description:
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE LineSegs::Point::
00046 Point(const LineSegs::Point &copy) :
00047   _point(copy._point),
00048   _color(copy._color)
00049 {
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: LineSegs::Point::Copy Assignment Operator
00054 //       Access: Public
00055 //  Description:
00056 ////////////////////////////////////////////////////////////////////
00057 INLINE void LineSegs::Point::
00058 operator = (const LineSegs::Point &copy) {
00059   _point = copy._point;
00060   _color = copy._color;
00061 }
00062 
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: LineSegs::set_color
00066 //       Access: Public
00067 //  Description: Establishes the color that will be assigned to all
00068 //               vertices created by future calls to move_to() and
00069 //               draw_to().
00070 ////////////////////////////////////////////////////////////////////
00071 INLINE void LineSegs::
00072 set_color(float r, float g, float b, float a) {
00073   _color.set(r, g, b, a);
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: LineSegs::set_color
00078 //       Access: Public
00079 //  Description: Establishes the color that will be assigned to all
00080 //               vertices created by future calls to move_to() and
00081 //               draw_to().
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE void LineSegs::
00084 set_color(const Colorf &color) {
00085   _color = color;
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: LineSegs::set_thickness
00090 //       Access: Public
00091 //  Description: Establishes the line thickness or point size in
00092 //               pixels that will be assigned to all lines and points
00093 //               created by future calls to create().
00094 ////////////////////////////////////////////////////////////////////
00095 INLINE void LineSegs::
00096 set_thickness(float thick) {
00097   _thick = thick;
00098 }
00099 
00100 ////////////////////////////////////////////////////////////////////
00101 //     Function: LineSegs::move_to
00102 //       Access: Public
00103 //  Description: Moves the pen to the given point without drawing a
00104 //               line.  When followed by draw_to(), this marks the
00105 //               first point of a line segment; when followed by
00106 //               move_to() or create(), this creates a single point.
00107 ////////////////////////////////////////////////////////////////////
00108 INLINE void LineSegs::
00109 move_to(float x, float y, float z) {
00110   move_to(Vertexf(x, y, z));
00111 }
00112 
00113 ////////////////////////////////////////////////////////////////////
00114 //     Function: LineSegs::draw_to
00115 //       Access: Public
00116 //  Description: Draws a line segment from the pen's last position
00117 //               (the last call to move_to or draw_to) to the
00118 //               indicated point.  move_to() and draw_to() only update
00119 //               tables; the actual drawing is performed when create()
00120 //               is called.
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE void LineSegs::
00123 draw_to(float x, float y, float z) {
00124   draw_to(Vertexf(x, y, z));
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: LineSegs::create
00129 //       Access: Public
00130 //  Description: Creates a new GeomNode that will render the series of
00131 //               line segments and points described via calls to
00132 //               move_to() and draw_to().  The lines and points are
00133 //               created with the color and thickness established by
00134 //               calls to set_color() and set_thick().
00135 //
00136 //               If frame_accurate is true, the line segments will be
00137 //               created as a frame-accurate index, so that later
00138 //               calls to set_vertex or set_vertex_color will be
00139 //               visually correct.
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE GeomNode *LineSegs::
00142 create(bool frame_accurate) {
00143   GeomNode *gnode = new GeomNode(get_name());
00144   return create(gnode, frame_accurate);
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: LineSegs::get_num_vertices
00149 //       Access: Public
00150 //  Description: Returns the total number of line segment and point
00151 //               vertices generated by the last call to create().  The
00152 //               positions of these vertices may be read and adjusted
00153 //               through get_vertex() and set_vertex().
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE int LineSegs::
00156 get_num_vertices() const {
00157   return _created_verts.size();
00158 }
00159 
00160 ////////////////////////////////////////////////////////////////////
00161 //     Function: LineSegs::get_vertex
00162 //       Access: Public
00163 //  Description: Returns the nth point or vertex of the line segment
00164 //               sequence generated by the last call to create().  The
00165 //               first move_to() generates vertex 0; subsequent
00166 //               move_to() and draw_to() calls generate consecutively
00167 //               higher vertex numbers.
00168 ////////////////////////////////////////////////////////////////////
00169 INLINE Vertexf LineSegs::
00170 get_vertex(int vertex) const {
00171   nassertr(vertex >= 0 && vertex < (int)_created_verts.size(),
00172            Vertexf(0.0f, 0.0f, 0.0f));
00173   return _created_verts[vertex];
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: LineSegs::set_vertex
00178 //       Access: Public
00179 //  Description: Moves the nth point or vertex of the line segment
00180 //               sequence generated by the last call to create().  The
00181 //               first move_to() generates vertex 0; subsequent
00182 //               move_to() and draw_to() calls generate consecutively
00183 //               higher vertex numbers.
00184 ////////////////////////////////////////////////////////////////////
00185 INLINE void LineSegs::
00186 set_vertex(int vertex, const Vertexf &vert) {
00187   nassertv(vertex >= 0 && vertex < (int)_created_verts.size());
00188   _created_verts[vertex] = vert;
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: LineSegs::set_vertex
00193 //       Access: Public
00194 //  Description: Moves the nth point or vertex of the line segment
00195 //               sequence generated by the last call to create().  The
00196 //               first move_to() generates vertex 0; subsequent
00197 //               move_to() and draw_to() calls generate consecutively
00198 //               higher vertex numbers.
00199 ////////////////////////////////////////////////////////////////////
00200 INLINE void LineSegs::
00201 set_vertex(int vertex, float x, float y, float z) {
00202   set_vertex(vertex, Vertexf(x, y, z));
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: LineSegs::get_vertex_color
00207 //       Access: Public
00208 //  Description: Returns the color of the nth point or vertex/
00209 ////////////////////////////////////////////////////////////////////
00210 INLINE Colorf LineSegs::
00211 get_vertex_color(int vertex) const {
00212   nassertr(vertex >= 0 && vertex < (int)_created_colors.size(),
00213            Colorf(0.0f, 0.0f, 0.0f, 0.0f));
00214   return _created_colors[vertex];
00215 }
00216 
00217 ////////////////////////////////////////////////////////////////////
00218 //     Function: LineSegs::set_vertex_color
00219 //       Access: Public
00220 //  Description: Changes the vertex color of the nth point or vertex.
00221 //               See set_vertex().
00222 ////////////////////////////////////////////////////////////////////
00223 INLINE void LineSegs::
00224 set_vertex_color(int vertex, const Colorf &color) {
00225   nassertv(vertex >= 0 && vertex < (int)_created_verts.size());
00226   _created_colors[vertex] = color;
00227 }
00228 
00229 ////////////////////////////////////////////////////////////////////
00230 //     Function: LineSegs::set_vertex_color
00231 //       Access: Public
00232 //  Description: Changes the vertex color of the nth point or vertex.
00233 //               See set_vertex().
00234 ////////////////////////////////////////////////////////////////////
00235 INLINE void LineSegs::
00236 set_vertex_color(int vertex, float r, float g, float b, float a) {
00237   set_vertex_color(vertex, Colorf(r, g, b, a));
00238 }

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