Panda3D
|
00001 // Filename: geomVertexRewriter.I 00002 // Created by: drose (28Mar05) 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 //////////////////////////////////////////////////////////////////// 00017 // Function: GeomVertexRewriter::Default Constructor 00018 // Access: Published 00019 // Description: Constructs an invalid GeomVertexRewriter. You must use 00020 // the assignment operator to assign a valid 00021 // GeomVertexRewriter to this object before you can use 00022 // it. 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE GeomVertexRewriter:: 00025 GeomVertexRewriter(Thread *current_thread) : 00026 GeomVertexWriter(current_thread), 00027 GeomVertexReader(current_thread) 00028 { 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: GeomVertexRewriter::Constructor 00033 // Access: Published 00034 // Description: Constructs a new rewriter to process the vertices of 00035 // the indicated data object. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE GeomVertexRewriter:: 00038 GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) : 00039 GeomVertexWriter(vertex_data, current_thread), 00040 GeomVertexReader(vertex_data, current_thread) 00041 { 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: GeomVertexRewriter::Constructor 00046 // Access: Published 00047 // Description: Constructs a new rewriter to process the vertices of 00048 // the indicated data object. This flavor creates the 00049 // rewriter specifically to process the named data type. 00050 //////////////////////////////////////////////////////////////////// 00051 INLINE GeomVertexRewriter:: 00052 GeomVertexRewriter(GeomVertexData *vertex_data, const string &name, 00053 Thread *current_thread) : 00054 GeomVertexWriter(vertex_data, current_thread), 00055 GeomVertexReader(vertex_data, current_thread) 00056 { 00057 set_column(name); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: GeomVertexRewriter::Constructor 00062 // Access: Published 00063 // Description: Constructs a new rewriter to process the vertices of 00064 // the indicated data object. This flavor creates the 00065 // rewriter specifically to process the named data type. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE GeomVertexRewriter:: 00068 GeomVertexRewriter(GeomVertexData *vertex_data, const InternalName *name, 00069 Thread *current_thread) : 00070 GeomVertexWriter(vertex_data, current_thread), 00071 GeomVertexReader(vertex_data, current_thread) 00072 { 00073 set_column(name); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: GeomVertexRewriter::Constructor 00078 // Access: Published 00079 // Description: Constructs a new rewriter to process the vertices of 00080 // the indicated array only. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE GeomVertexRewriter:: 00083 GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) : 00084 GeomVertexWriter(array_data, current_thread), 00085 GeomVertexReader(array_data, current_thread) 00086 { 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: GeomVertexRewriter::Constructor 00091 // Access: Published 00092 // Description: Constructs a new rewriter to process the vertices of 00093 // the indicated array only. 00094 //////////////////////////////////////////////////////////////////// 00095 INLINE GeomVertexRewriter:: 00096 GeomVertexRewriter(GeomVertexArrayData *array_data, int column, 00097 Thread *current_thread) : 00098 GeomVertexWriter(array_data, current_thread), 00099 GeomVertexReader(array_data, current_thread) 00100 { 00101 set_column(column); 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: GeomVertexRewriter::Copy Constructor 00106 // Access: Published 00107 // Description: 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE GeomVertexRewriter:: 00110 GeomVertexRewriter(const GeomVertexRewriter ©) : 00111 GeomVertexWriter(copy), 00112 GeomVertexReader(copy) 00113 { 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: GeomVertexRewriter::Copy Assignment Operator 00118 // Access: Published 00119 // Description: 00120 //////////////////////////////////////////////////////////////////// 00121 INLINE void GeomVertexRewriter:: 00122 operator = (const GeomVertexRewriter ©) { 00123 GeomVertexWriter::operator = (copy); 00124 GeomVertexReader::operator = (copy); 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: GeomVertexRewriter::Destructor 00129 // Access: Published 00130 // Description: 00131 //////////////////////////////////////////////////////////////////// 00132 INLINE GeomVertexRewriter:: 00133 ~GeomVertexRewriter() { 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: GeomVertexRewriter::get_vertex_data 00138 // Access: Published 00139 // Description: Returns the vertex data object that the 00140 // rewriter is processing. 00141 //////////////////////////////////////////////////////////////////// 00142 INLINE GeomVertexData *GeomVertexRewriter:: 00143 get_vertex_data() const { 00144 nassertr(GeomVertexWriter::get_vertex_data() == 00145 GeomVertexReader::get_vertex_data(), NULL); 00146 return GeomVertexWriter::get_vertex_data(); 00147 } 00148 00149 //////////////////////////////////////////////////////////////////// 00150 // Function: GeomVertexRewriter::get_array_data 00151 // Access: Published 00152 // Description: Returns the particular array object that the 00153 // rewriter is currently processing. 00154 //////////////////////////////////////////////////////////////////// 00155 INLINE GeomVertexArrayData *GeomVertexRewriter:: 00156 get_array_data() const { 00157 nassertr(GeomVertexWriter::get_array_data() == 00158 GeomVertexReader::get_array_data(), NULL); 00159 return GeomVertexWriter::get_array_data(); 00160 } 00161 00162 //////////////////////////////////////////////////////////////////// 00163 // Function: GeomVertexRewriter::set_column 00164 // Access: Published 00165 // Description: Sets up the rewriter to use the nth data type of the 00166 // GeomVertexFormat, numbering from 0. 00167 // 00168 // This also resets both the read and write row 00169 // numbers to the start row (the same value passed to 00170 // a previous call to set_row(), or 0 if set_row() 00171 // was never called.) 00172 // 00173 // The return value is true if the data type is valid, 00174 // false otherwise. 00175 //////////////////////////////////////////////////////////////////// 00176 INLINE bool GeomVertexRewriter:: 00177 set_column(int column) { 00178 // It's important to invoke the writer first, then the reader. See 00179 // set_row(). 00180 GeomVertexWriter::set_column(column); 00181 return GeomVertexReader::set_column(column); 00182 } 00183 00184 //////////////////////////////////////////////////////////////////// 00185 // Function: GeomVertexRewriter::set_column 00186 // Access: Published 00187 // Description: Sets up the rewriter to use the data type with the 00188 // indicated name. 00189 // 00190 // This also resets both the read and write row 00191 // numbers to the start row (the same value passed to 00192 // a previous call to set_row(), or 0 if set_row() 00193 // was never called.) 00194 // 00195 // The return value is true if the data type is valid, 00196 // false otherwise. 00197 //////////////////////////////////////////////////////////////////// 00198 INLINE bool GeomVertexRewriter:: 00199 set_column(const string &name) { 00200 return set_column(InternalName::make(name)); 00201 } 00202 00203 //////////////////////////////////////////////////////////////////// 00204 // Function: GeomVertexRewriter::set_column 00205 // Access: Published 00206 // Description: Sets up the rewriter to use the data type with the 00207 // indicated name. 00208 // 00209 // This also resets both the read and write row 00210 // numbers to the start row (the same value passed to 00211 // a previous call to set_row(), or 0 if set_row() 00212 // was never called.) 00213 // 00214 // The return value is true if the data type is valid, 00215 // false otherwise. 00216 //////////////////////////////////////////////////////////////////// 00217 INLINE bool GeomVertexRewriter:: 00218 set_column(const InternalName *name) { 00219 // It's important to invoke the writer first, then the reader. See 00220 // set_row(). 00221 GeomVertexWriter::set_column(name); 00222 return GeomVertexReader::set_column(name); 00223 } 00224 00225 //////////////////////////////////////////////////////////////////// 00226 // Function: GeomVertexRewriter::set_column 00227 // Access: Published 00228 // Description: Sets up the rewriter to use the indicated column 00229 // description on the given array. 00230 // 00231 // This also resets both the read and write row 00232 // numbers to the start row (the same value passed to 00233 // a previous call to set_row(), or 0 if set_row() 00234 // was never called.) 00235 // 00236 // The return value is true if the data type is valid, 00237 // false otherwise. 00238 //////////////////////////////////////////////////////////////////// 00239 INLINE bool GeomVertexRewriter:: 00240 set_column(int array, const GeomVertexColumn *column) { 00241 // It's important to invoke the writer first, then the reader. See 00242 // set_row(). 00243 GeomVertexWriter::set_column(array, column); 00244 return GeomVertexReader::set_column(array, column); 00245 } 00246 00247 //////////////////////////////////////////////////////////////////// 00248 // Function: GeomVertexRewriter::clear 00249 // Access: Published 00250 // Description: Resets the GeomVertexRewriter to the initial state. 00251 //////////////////////////////////////////////////////////////////// 00252 INLINE void GeomVertexRewriter:: 00253 clear() { 00254 GeomVertexWriter::clear(); 00255 GeomVertexReader::clear(); 00256 } 00257 00258 //////////////////////////////////////////////////////////////////// 00259 // Function: GeomVertexRewriter::has_column 00260 // Access: Published 00261 // Description: Returns true if a valid data type has been 00262 // successfully set, or false if the data type does not 00263 // exist. 00264 //////////////////////////////////////////////////////////////////// 00265 INLINE bool GeomVertexRewriter:: 00266 has_column() const { 00267 nassertr(GeomVertexWriter::get_column() == 00268 GeomVertexReader::get_column(), false); 00269 return GeomVertexWriter::has_column(); 00270 } 00271 00272 //////////////////////////////////////////////////////////////////// 00273 // Function: GeomVertexRewriter::get_array 00274 // Access: Published 00275 // Description: Returns the array index containing the data type that 00276 // the rewriter is working on. 00277 //////////////////////////////////////////////////////////////////// 00278 INLINE int GeomVertexRewriter:: 00279 get_array() const { 00280 nassertr(GeomVertexWriter::get_array() == 00281 GeomVertexReader::get_array(), -1); 00282 return GeomVertexWriter::get_array(); 00283 } 00284 00285 //////////////////////////////////////////////////////////////////// 00286 // Function: GeomVertexRewriter::get_column 00287 // Access: Published 00288 // Description: Returns the description of the data type that the 00289 // rewriter is working on. 00290 //////////////////////////////////////////////////////////////////// 00291 INLINE const GeomVertexColumn *GeomVertexRewriter:: 00292 get_column() const { 00293 nassertr(GeomVertexWriter::get_column() == 00294 GeomVertexReader::get_column(), NULL); 00295 return GeomVertexWriter::get_column(); 00296 } 00297 00298 //////////////////////////////////////////////////////////////////// 00299 // Function: GeomVertexRewriter::set_row 00300 // Access: Published 00301 // Description: Sets the start, write, and write index to the 00302 // indicated value. The rewriter will begin traversing 00303 // from the given row. 00304 //////////////////////////////////////////////////////////////////// 00305 INLINE void GeomVertexRewriter:: 00306 set_row(int row) { 00307 // It's important to invoke the Writer first, since that might force 00308 // a recopy of the array, which might invalidate the pointer already 00309 // stored by the Reader if we invoked the Reader first. 00310 GeomVertexWriter::set_row(row); 00311 GeomVertexReader::set_row(row); 00312 } 00313 00314 //////////////////////////////////////////////////////////////////// 00315 // Function: GeomVertexRewriter::get_start_row 00316 // Access: Published 00317 // Description: Returns the row index at which the rewriter 00318 // started. It will return to this row if you reset 00319 // the current column. 00320 //////////////////////////////////////////////////////////////////// 00321 INLINE int GeomVertexRewriter:: 00322 get_start_row() const { 00323 nassertr(GeomVertexWriter::get_start_row() == 00324 GeomVertexReader::get_start_row(), 0); 00325 return GeomVertexWriter::get_start_row(); 00326 } 00327 00328 //////////////////////////////////////////////////////////////////// 00329 // Function: GeomVertexRewriter::is_at_end 00330 // Access: Published 00331 // Description: Returns true if the reader or writer is currently at 00332 // the end of the list of vertices, false otherwise. 00333 //////////////////////////////////////////////////////////////////// 00334 INLINE bool GeomVertexRewriter:: 00335 is_at_end() const { 00336 return GeomVertexWriter::is_at_end() || GeomVertexReader::is_at_end(); 00337 }