00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE EggPrimitive::
00022 EggPrimitive(const string &name): EggNode(name) {
00023 _bface = false;
00024 _connected_shading = S_unknown;
00025 }
00026
00027
00028
00029
00030
00031
00032 INLINE EggPrimitive::
00033 EggPrimitive(const EggPrimitive ©) :
00034 EggNode(copy),
00035 EggAttributes(copy),
00036 _textures(copy._textures),
00037 _material(copy._material),
00038 _bface(copy._bface)
00039 {
00040 copy_vertices(copy);
00041 _connected_shading = S_unknown;
00042 }
00043
00044
00045
00046
00047
00048
00049 INLINE EggPrimitive &EggPrimitive::
00050 operator = (const EggPrimitive ©) {
00051 EggNode::operator = (copy);
00052 EggAttributes::operator = (copy);
00053 copy_vertices(copy);
00054 _textures = copy._textures;
00055 _material = copy._material;
00056 _bface = copy._bface;
00057 _connected_shading = S_unknown;
00058 return *this;
00059 }
00060
00061
00062
00063
00064
00065
00066 INLINE EggPrimitive::
00067 ~EggPrimitive() {
00068 clear();
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 INLINE string EggPrimitive::
00082 get_sort_name() const {
00083 const string &name = get_name();
00084 if (!name.empty() && !isdigit(name[0])) {
00085 return name;
00086 }
00087 return string();
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097 INLINE void EggPrimitive::
00098 clear_connected_shading() {
00099 _connected_shading = S_unknown;
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 INLINE EggPrimitive::Shading EggPrimitive::
00120 get_connected_shading() const {
00121 if (_connected_shading == S_unknown) {
00122 ((EggPrimitive *)this)->set_connected_shading(S_unknown, this);
00123 }
00124
00125 return _connected_shading;
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 INLINE void EggPrimitive::
00139 set_texture(EggTexture *texture) {
00140 clear_texture();
00141 add_texture(texture);
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 INLINE bool EggPrimitive::
00155 has_texture() const {
00156 return get_num_textures() > 0;
00157 }
00158
00159
00160
00161
00162
00163
00164
00165 INLINE bool EggPrimitive::
00166 has_texture(EggTexture *texture) const {
00167 PT_EggTexture t = texture;
00168 return (::find(_textures.begin(), _textures.end(), t) != _textures.end());
00169 }
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 INLINE EggTexture *EggPrimitive::
00182 get_texture() const {
00183 return has_texture() ? get_texture(0) : (EggTexture *)NULL;
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 INLINE void EggPrimitive::
00197 add_texture(EggTexture *texture) {
00198 _textures.push_back(texture);
00199 }
00200
00201
00202
00203
00204
00205
00206 INLINE void EggPrimitive::
00207 clear_texture() {
00208 _textures.clear();
00209 }
00210
00211
00212
00213
00214
00215
00216
00217 INLINE int EggPrimitive::
00218 get_num_textures() const {
00219 return _textures.size();
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 INLINE EggTexture *EggPrimitive::
00229 get_texture(int n) const {
00230 nassertr(n >= 0 && n < (int)_textures.size(), NULL);
00231 return _textures[n];
00232 }
00233
00234
00235
00236
00237
00238
00239
00240 INLINE void EggPrimitive::
00241 set_material(EggMaterial *material) {
00242 _material = material;
00243 }
00244
00245
00246
00247
00248
00249
00250 INLINE void EggPrimitive::
00251 clear_material() {
00252 _material = (EggMaterial *)NULL;
00253 }
00254
00255
00256
00257
00258
00259
00260
00261 INLINE EggMaterial *EggPrimitive::
00262 get_material() const {
00263 return _material;
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 INLINE bool EggPrimitive::
00275 has_material() const {
00276 return _material != (EggMaterial *)NULL;
00277 }
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 INLINE void EggPrimitive::
00289 set_bface_flag(bool flag) {
00290 _bface = flag;
00291 }
00292
00293
00294
00295
00296
00297
00298
00299
00300 INLINE bool EggPrimitive::
00301 get_bface_flag() const {
00302 return _bface;
00303 }
00304
00305
00306
00307
00308
00309
00310
00311 INLINE EggPrimitive::iterator EggPrimitive::
00312 begin() const {
00313 return _vertices.begin();
00314 }
00315
00316
00317
00318
00319
00320
00321 INLINE EggPrimitive::iterator EggPrimitive::
00322 end() const {
00323 return _vertices.end();
00324 }
00325
00326
00327
00328
00329
00330
00331 INLINE EggPrimitive::reverse_iterator EggPrimitive::
00332 rbegin() const {
00333 return _vertices.rbegin();
00334 }
00335
00336
00337
00338
00339
00340
00341 INLINE EggPrimitive::reverse_iterator EggPrimitive::
00342 rend() const {
00343 return _vertices.rend();
00344 }
00345
00346
00347
00348
00349
00350
00351 INLINE bool EggPrimitive::
00352 empty() const {
00353 return _vertices.empty();
00354 }
00355
00356
00357
00358
00359
00360
00361 INLINE EggPrimitive::size_type EggPrimitive::
00362 size() const {
00363 return _vertices.size();
00364 }
00365
00366
00367
00368
00369
00370
00371
00372 INLINE EggVertex *EggPrimitive::
00373 operator [] (int index) const {
00374 nassertr(index >= 0 && index < (int)size(), NULL);
00375 return *(begin() + index);
00376 }
00377
00378
00379
00380
00381
00382
00383 INLINE EggPrimitive::iterator EggPrimitive::
00384 insert(iterator position, EggVertex *x) {
00385 prepare_add_vertex(x, position - _vertices.begin(), _vertices.size() + 1);
00386 iterator i = _vertices.insert((Vertices::iterator &)position, x);
00387 x->test_pref_integrity();
00388 test_vref_integrity();
00389 return i;
00390 }
00391
00392
00393
00394
00395
00396
00397 INLINE EggPrimitive::iterator EggPrimitive::
00398 erase(iterator position) {
00399 prepare_remove_vertex(*position, position - _vertices.begin(), _vertices.size());
00400 iterator i = _vertices.erase((Vertices::iterator &)position);
00401 test_vref_integrity();
00402 return i;
00403 }
00404
00405
00406
00407
00408
00409
00410
00411
00412 INLINE void EggPrimitive::
00413 replace(iterator position, EggVertex *x) {
00414 nassertv(position != end());
00415
00416
00417
00418 prepare_remove_vertex(*position, -1, -1);
00419 prepare_add_vertex(x, -1, -1);
00420 *(Vertices::iterator &)position = x;
00421
00422 x->test_pref_integrity();
00423 test_vref_integrity();
00424 }
00425
00426
00427
00428
00429
00430
00431 INLINE void EggPrimitive::
00432 clear() {
00433 erase(begin(), end());
00434 }
00435
00436
00437
00438
00439
00440
00441 INLINE int EggPrimitive::
00442 get_num_vertices() const {
00443 return size();
00444 }
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 INLINE void EggPrimitive::
00455 set_vertex(int index, EggVertex *vertex) {
00456 nassertv(index >= 0 && index < (int)size());
00457 replace(begin() + index, vertex);
00458 }
00459
00460
00461
00462
00463
00464
00465 INLINE EggVertex *EggPrimitive::
00466 get_vertex(int index) const {
00467 nassertr(index >= 0 && index < (int)size(), NULL);
00468 return *(begin() + index);
00469 }
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 INLINE EggVertexPool *EggPrimitive::
00480 get_pool() const {
00481 return empty() ? (EggVertexPool *)NULL : _vertices.front()->get_pool();
00482 }