Changeset 508 for trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
- Timestamp:
- 01/08/06 05:56:40 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r503 r508 477 477 int i = 1; 478 478 int j = 0; 479 int k = mVertices.size() - 1;479 int k = (int)mVertices.size() - 1; 480 480 int count = 0; 481 481 … … 490 490 } 491 491 } 492 493 494 void Polygon3::Triangulate(VertexIndexContainer &indices) 495 { 496 int i = 1; 497 int j = 0; 498 int k = (int)mVertices.size() - 1; 499 500 int count = 0; 501 502 while (i < k) 503 { 504 indices.push_back(k); 505 indices.push_back(j); 506 indices.push_back(i); 507 508 if ((count ++) % 2) 509 j = i ++; 510 else 511 j = k --; 512 } 513 } 514 515 516 void Polygon3::AddToMesh(Mesh &mesh) 517 { 518 const int n = (int)mesh.mVertices.size(); 519 520 //-- add the vertices 521 VertexContainer::const_iterator vit, vit_end = mVertices.end(); 522 for (vit = mVertices.begin(); vit != vit_end; ++ vit) 523 { 524 mesh.mVertices.push_back(*vit); 525 } 526 527 // one quad => no triangulation necessary 528 if ((int)mVertices.size() == 4) 529 { 530 mesh.AddFace(new Face(n, n + 1, n + 2, n + 3)); 531 } 532 else 533 { 534 VertexIndexContainer indices; 535 Triangulate(indices); 536 537 // add indices of triangle strip 538 for (int i = 0; i < (int)indices.size(); i += 3) 539 { 540 Face *face = new Face(n + indices[i], 541 n + indices[i + 1], 542 n + indices[i + 2]); 543 mesh.AddFace(face); 544 } 545 } 546 }
Note: See TracChangeset
for help on using the changeset viewer.