- Timestamp:
- 04/30/07 08:16:31 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshLoader.h
r1788 r2341 53 53 const unsigned short M_EDGE_LIST_LOD = 0xB100; 54 54 const unsigned short M_EDGE_GROUP = 0xB110; 55 const unsigned short M_POSES = 0xC000; 56 const unsigned short M_ANIMATIONS = 0xD000; 57 const unsigned short M_LODSTRIPS = 0xABCD; 58 const unsigned short M_LODTREES = 0xDCBA; 55 59 const unsigned short SUBMESH_COUNT = 0; 56 60 const unsigned short GEOMESH_BUILD = 1; -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSaver.h
r1136 r2341 1 /* ==========================================================================1 /*======================================================================= 2 2 * (C) 2005 Universitat Jaume I 3 * ==========================================================================3 *======================================================================= 4 4 * PROYECT: GAME TOOLS 5 * ========================================================================*/6 /* CONTENT:5 *======================================================================= 6 * CONTENT: 7 7 * 8 8 * 9 9 * @file GeoMeshSaver.h 10 * ========================================================================*/10 *=======================================================================*/ 11 11 12 12 #ifndef __GEO_MESH_SAVER__ … … 21 21 { 22 22 private: 23 23 24 // The mesh to write. 24 25 Mesh *mGeoMesh; … … 48 49 // Write Mesh Bounds. 49 50 void writeMeshBounds(Mesh *geoMesh); 50 51 52 // Write submesh name table. 53 void writeSubMeshNameTable(Mesh *geoMesh); 54 51 55 // Calculate the mesh size in bytes. 52 56 size_t calcMeshSize(const Mesh *geoMesh); -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshStripifier.h
r1559 r2341 1 /*======================================================================= ===1 /*======================================================================= 2 2 * (C) 2005 Universidad Jaime I de Castellón 3 *======================================================================= ===3 *======================================================================= 4 4 * PROYECT: GAME TOOLS 5 *======================================================================= ===*/6 /* CONTENT: Make triangle strips meshes from triangle list meshes.5 *======================================================================= 6 * CONTENT: Make triangle strips meshes from triangle list meshes. 7 7 * 8 8 * 9 9 * @file GeoMeshStripifier.h 10 *======================================================================= ===*/10 *=======================================================================*/ 11 11 12 12 #ifndef __GEO_STRIPIFIER__ -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoSubMesh.h
r1009 r2341 49 49 MeshType mType; ///< Type of mesh 50 50 51 char mName[255]; ///< Submesh name. 51 52 char mMaterialName[255]; ///< Material name 52 53 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp
r2322 r2341 59 59 mSubMesh[i].mType = mesh.mSubMesh[i].mType; 60 60 61 strcpy(mSubMesh[i].mName,mesh.mSubMesh[i].mName); 61 62 strcpy(mSubMesh[i].mMaterialName,mesh.mSubMesh[i].mMaterialName); 62 63 … … 202 203 mSubMesh[i].mVertexBuffer->mVertexInfo = mesh.mSubMesh[i].mVertexBuffer->mVertexInfo; 203 204 mSubMesh[i].mType = mesh.mSubMesh[i].mType; 205 206 strcpy(mSubMesh[i].mName,mesh.mSubMesh[i].mName); 204 207 strcpy(mSubMesh[i].mMaterialName,mesh.mSubMesh[i].mMaterialName); 205 208 … … 515 518 mesh->mSubMesh[i].mType = mSubMesh[i].mType; 516 519 520 strcpy(mesh->mSubMesh[i].mName,mSubMesh[i].mName); 517 521 strcpy(mesh->mSubMesh[i].mMaterialName,mSubMesh[i].mMaterialName); 518 522 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp
r2127 r2341 14 14 #include <cctype> 15 15 #include <map> 16 #include "GeoLodStripsLibrary.h" 17 #include "GeoLodStripsConstructor.h" 16 18 17 19 using namespace Geometry; … … 165 167 unsigned short headerID; 166 168 size_t i; 167 //float aux;168 169 size_t k; 169 170 bool found; … … 462 463 } 463 464 464 465 465 if (idx32bit) 466 466 { … … 561 561 } 562 562 } 563 564 563 } 565 564 … … 597 596 598 597 jumpChunk(f); 599 600 598 } 601 599 } … … 606 604 void GeoMeshLoader::readSubMeshNameTable(FILE *f, Mesh *geoMesh) 607 605 { 608 unsigned short chunkID; 609 unsigned short subMeshIndex; 610 char string[255]; 611 606 unsigned short chunkID; 607 unsigned short subMeshIndex; 608 char string[255]; 609 610 if (!feof(f)) 611 { 612 chunkID = readChunk(f); 613 614 while (!feof(f) && (chunkID == M_SUBMESH_NAME_TABLE_ELEMENT)) 615 { 616 // Debug. 617 cout << " M_SUBMESH_NAME_TABLE_ELEMENT" 618 << endl; 619 620 // Read in the index of the submesh. 621 fread(&subMeshIndex,sizeof(unsigned short),1,f); 622 623 // Read in the String and map it to its index. 624 fgets(string,255,f); 625 626 string[strlen(string) - 1] = '\0'; 627 628 // Gets the submesh name. 629 strcpy(geoMesh->mSubMesh[subMeshIndex].mName,string); 630 631 cout << "--> SubMesh " 632 << subMeshIndex 633 << ": " 634 << string 635 << endl; 636 637 // If we're not end of file get the next chunk ID. 638 if (!feof(f)) 639 { 640 chunkID = readChunk(f); 641 } 642 } 612 643 if (!feof(f)) 613 644 { 614 chunkID = readChunk(f); 615 616 while (!feof(f) && (chunkID == M_SUBMESH_NAME_TABLE_ELEMENT )) 617 { 618 // Debug. 619 cout << " M_SUBMESH_NAME_TABLE_ELEMENT" 620 << endl; 621 622 // Read in the index of the submesh. 623 fread(&subMeshIndex,sizeof(unsigned short),1,f); 624 625 // Read in the String and map it to its index. 626 fgets(string,255,f); 627 628 // If we're not end of file get the next chunk ID. 629 if (!feof(f)) 630 { 631 chunkID = readChunk(f); 632 } 633 } 634 if (!feof(f)) 635 { 636 // Backpedal back to start of chunk. 637 fseek(f,-(long)CHUNK_OVERHEAD_SIZE,1); 638 } 639 } 645 // Backpedal back to start of chunk. 646 fseek(f,-(long)CHUNK_OVERHEAD_SIZE,1); 647 } 648 } 640 649 } 641 650 … … 643 652 // Read a mesh file. 644 653 //------------------------------------------------------------------------- 645 646 #include "GeoLodStripsLibrary.h"647 #include "GeoLodStripsConstructor.h"648 649 654 void GeoMeshLoader::readMesh(FILE *f, Mesh *geoMesh, int option) 650 655 { … … 667 672 chunkID = readChunk(f); 668 673 669 while(!feof(f) && 670 (chunkID == M_GEOMETRY || 671 chunkID == M_SUBMESH || 672 chunkID == M_MESH_SKELETON_LINK || 673 chunkID == M_MESH_BONE_ASSIGNMENT || 674 chunkID == M_MESH_LOD || 675 chunkID == M_MESH_BOUNDS || 676 chunkID == M_SUBMESH_NAME_TABLE || 677 chunkID == M_EDGE_LISTS || 678 chunkID == 0xabcd || 679 chunkID == 0xdcba)) 674 while (!feof(f) && 675 (chunkID == M_GEOMETRY || 676 chunkID == M_SUBMESH || 677 chunkID == M_MESH_SKELETON_LINK || 678 chunkID == M_MESH_BONE_ASSIGNMENT || 679 chunkID == M_MESH_LOD || 680 chunkID == M_MESH_BOUNDS || 681 chunkID == M_SUBMESH_NAME_TABLE || 682 chunkID == M_EDGE_LISTS || 683 chunkID == M_LODSTRIPS || 684 chunkID == M_LODTREES || 685 chunkID == M_POSES || 686 chunkID == M_ANIMATIONS)) 680 687 { 681 688 switch(chunkID) 682 689 { 683 case 0xabcd:690 case M_LODSTRIPS: 684 691 685 692 // Debug. … … 741 748 break; 742 749 743 case 0xdcba: 750 case M_LODTREES: 751 744 752 cout << "LODTREES_Chunk" << endl; 745 753 treesimpseq = new Geometry::TreeSimplificationSequence; … … 761 769 break; 762 770 763 764 771 case M_GEOMETRY: 765 772 … … 792 799 cout << " M_MESH_SKELETON_LINK " 793 800 << endl; 794 795 801 796 802 readSkeletonLink(f, geoMesh, option); … … 799 805 800 806 case M_MESH_BONE_ASSIGNMENT: 801 802 // Debug.803 //cout << " M_MESH_BONE_ASSIGNMENT "804 // << endl;805 807 806 808 readMeshBoneAssignment(f, geoMesh, option); … … 823 825 << endl; 824 826 825 //jumpChunk(f);826 827 readMeshBounds(f, geoMesh, option); 827 828 break; … … 844 845 jumpChunk(f); 845 846 break; 847 848 case M_POSES: 849 850 // Debug. 851 cout << " M_POSES " 852 << endl; 853 854 jumpChunk(f); 855 break; 856 857 case M_ANIMATIONS: 858 859 // Debug. 860 cout << " M_ANIMATIONS " 861 << endl; 862 863 jumpChunk(f); 864 break; 846 865 } 847 866 … … 866 885 } 867 886 } 868 869 } 870 887 } 871 888 872 889 //------------------------------------------------------------------------- … … 879 896 size_t strip_count; 880 897 size_t tailIndex; 881 //size_t tail;882 898 883 899 head_found = false; … … 1476 1492 { 1477 1493 fgets(geoMesh->mSkeletonName,255,f); 1494 1495 geoMesh->mSkeletonName[strlen(geoMesh->mSkeletonName) - 1] = '\0'; 1478 1496 1479 1497 geoMesh->hasSkeleton = true; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp
r2127 r2341 181 181 if (geoMesh->hasSkeleton) 182 182 { 183 strcat(geoMesh->mSkeletonName,"\n"); 184 183 185 // Write skeleton link 184 186 writeSkeletonLink(geoMesh->mSkeletonName); … … 199 201 writeMeshBounds(geoMesh); 200 202 203 // Write submesh name table. 204 writeSubMeshNameTable(geoMesh); 205 201 206 /* 202 207 // Write LOD data if any … … 212 217 writeBoundsInfo(pMesh); 213 218 LogManager::getSingleton().logMessage("Bounds information exported."); 214 215 // Write submesh name table216 LogManager::getSingleton().logMessage("Exporting submesh name table...");217 writeSubMeshNameTable(pMesh);218 LogManager::getSingleton().logMessage("Submesh name table exported.");219 219 220 220 // Write edge lists … … 414 414 415 415 // Write the vertex declaration header. 416 writeChunkHeader( 416 writeChunkHeader(M_GEOMETRY_VERTEX_DECLARATION,size); 417 417 418 418 // Debug. … … 425 425 // Positions. 426 426 // Write the vertex element header for position. 427 writeChunkHeader( 427 writeChunkHeader(M_GEOMETRY_VERTEX_ELEMENT,size); 428 428 429 429 // Debug. … … 448 448 // Normals. 449 449 // Write the vertex element header for position. 450 writeChunkHeader( 450 writeChunkHeader(M_GEOMETRY_VERTEX_ELEMENT,size); 451 451 452 452 // Debug. … … 528 528 529 529 // Write the vertex buffer header. 530 writeChunkHeader( 530 writeChunkHeader(M_GEOMETRY_VERTEX_BUFFER, size); 531 531 532 532 // Debug. … … 613 613 writeFloats(geoMesh->mMeshBounds.maxZ,1); 614 614 writeFloats(geoMesh->mMeshBounds.radius,1); 615 } 616 617 //------------------------------------------------------------------------- 618 // Write submesh name table. 619 //------------------------------------------------------------------------- 620 void GeoMeshSaver::writeSubMeshNameTable(Mesh *geoMesh) 621 { 622 size_t size; 623 size_t names_size; 624 625 // Size of the names of the submeshes. 626 names_size = 0; 627 628 // For each submesh. 629 for (size_t i = 0; i < geoMesh->mSubMeshCount; i++) 630 { 631 names_size = strlen(geoMesh->mSubMesh[i].mName); 632 } 633 634 size = CHUNK_OVERHEAD_SIZE 635 + 636 names_size 637 + 638 (CHUNK_OVERHEAD_SIZE + sizeof(short)) * geoMesh->mSubMeshCount; 639 640 writeChunkHeader(M_SUBMESH_NAME_TABLE, (unsigned long)size); 641 642 // For each submesh. 643 for (size_t i = 0; i < geoMesh->mSubMeshCount; i++) 644 { 645 size = CHUNK_OVERHEAD_SIZE 646 + 647 sizeof(short) 648 + 649 strlen(geoMesh->mSubMesh[i].mName); 650 651 writeChunkHeader(M_SUBMESH_NAME_TABLE_ELEMENT, (unsigned long)size); 652 653 writeShorts(i, 1); 654 655 strcat(geoMesh->mSubMesh[i].mName,"\n"); 656 mSerializer->WriteData(geoMesh->mSubMesh[i].mName); 657 } 615 658 } 616 659 … … 751 794 752 795 writeString(mesh_version); 753 754 796 } 755 797 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshStripifier.cpp
r1559 r2341 1 /* ===================================================================== =====1 /* ===================================================================== 2 2 * (C) 2005 Universitat Jaume I 3 * ===================================================================== =====3 * ===================================================================== 4 4 * PROYECT: GAME TOOLS 5 * ===================================================================== =====*/6 /** CONTENT: Make triangle strip meshes from triangle list meshes.7 8 9 10 /*===========================================================================*/5 * ===================================================================== 6 * CONTENT: Make triangle strip meshes from triangle list meshes. 7 * 8 * 9 * @file GeoMeshStripifier.cpp 10 * =====================================================================*/ 11 11 12 12 #include "GeoMeshStripifier.h" … … 15 15 using namespace std; 16 16 17 //------------------------------------------------------------------------- ----17 //------------------------------------------------------------------------- 18 18 // Private. 19 //------------------------------------------------------------------------- ----20 21 //------------------------------------------------------------------------- ----22 // /InitList.23 //------------------------------------------------------------------------- ----19 //------------------------------------------------------------------------- 20 21 //------------------------------------------------------------------------- 22 // InitList. 23 //------------------------------------------------------------------------- 24 24 BOOL CustomStripifier::InitList(PLISTHEAD LHead) 25 25 { … … 35 35 } 36 36 37 //------------------------------------------------------------------------- ----37 //------------------------------------------------------------------------- 38 38 // AddHead. 39 //------------------------------------------------------------------------- ----39 //------------------------------------------------------------------------- 40 40 BOOL CustomStripifier::AddHead(PLISTHEAD LHead, PLISTINFO LInfo) 41 41 { … … 8062 8062 void CustomStripifier::Save_Walks(int numfaces) 8063 8063 { 8064 int x,y,numverts; 8065 int front_walk, back_walk; 8066 ListHead *pListHead; 8067 PF_FACES temp = NULL; 8068 8069 for (x=0; x<numfaces; x++) 8070 { 8071 /* for each face, get the face */ 8072 pListHead = PolFaces[x]; 8073 temp = (PF_FACES) PeekList(pListHead,LISTHEAD,0); 8074 numverts = temp->nPolSize; 8075 front_walk = 0; 8076 back_walk = 0; 8077 8078 /* we are finding patches only for quads */ 8079 if (numverts == 4) 8080 { 8081 /* for each face not seen yet, do North and South together 8082 and East and West together 8083 */ 8084 for (y=0;y<2;y++) 8085 { 8086 /* Check if the opposite sides were seen already from another 8087 starting face, if they were then there is no need to do 8088 the walk again 8089 */ 8090 8091 if ( ((*(temp->walked+y) == -1) && 8092 (*(temp->walked+y+2) == -1) )) 8064 int x,y,numverts; 8065 int front_walk, back_walk; 8066 ListHead *pListHead; 8067 PF_FACES temp = NULL; 8068 8069 for (x=0; x<numfaces; x++) 8070 { 8071 /* for each face, get the face */ 8072 pListHead = PolFaces[x]; 8073 temp = (PF_FACES) PeekList(pListHead,LISTHEAD,0); 8074 numverts = temp->nPolSize; 8075 front_walk = 0; 8076 back_walk = 0; 8077 8078 /* we are finding patches only for quads */ 8079 if (numverts == 4) 8093 8080 { 8094 /* Find walk for the first edge */ 8095 front_walk = Calculate_Walks(x,y,temp); 8096 /* Find walk in the opposite direction */ 8097 back_walk = Calculate_Walks(x,y+2,temp); 8098 /* Now put into the data structure the numbers that 8099 we have found 8100 */ 8101 Assign_Walk(x,temp,front_walk,y,back_walk); 8102 Assign_Walk(x,temp,back_walk,y+2,front_walk); 8081 /* for each face not seen yet, do North and South together 8082 and East and West together 8083 */ 8084 for (y=0;y<2;y++) 8085 { 8086 /* Check if the opposite sides were seen already from another 8087 starting face, if they were then there is no need to do 8088 the walk again 8089 */ 8090 8091 if ( ((*(temp->walked+y) == -1) && 8092 (*(temp->walked+y+2) == -1) )) 8093 { 8094 /* Find walk for the first edge */ 8095 front_walk = Calculate_Walks(x,y,temp); 8096 /* Find walk in the opposite direction */ 8097 back_walk = Calculate_Walks(x,y+2,temp); 8098 /* Now put into the data structure the numbers that 8099 we have found 8100 */ 8101 Assign_Walk(x,temp,front_walk,y,back_walk); 8102 Assign_Walk(x,temp,back_walk,y+2,front_walk); 8103 } 8104 } 8103 8105 } 8104 } 8105 } 8106 } 8106 } 8107 8107 } 8108 8108 … … 8557 8557 } 8558 8558 8559 //------------------------------------------------------------------------- ----8559 //------------------------------------------------------------------------- 8560 8560 // Constructors. 8561 //------------------------------------------------------------------------- ----8561 //------------------------------------------------------------------------- 8562 8562 8563 8563 MeshStripifier::MeshStripifier() … … 8584 8584 } 8585 8585 8586 //------------------------------------------------------------------------- ----8586 //------------------------------------------------------------------------- 8587 8587 // Destroyers. 8588 //------------------------------------------------------------------------- ----8588 //------------------------------------------------------------------------- 8589 8589 CustomStripifier::~CustomStripifier() 8590 8590 { … … 8596 8596 } 8597 8597 8598 //------------------------------------------------------------------------- ----8598 //------------------------------------------------------------------------- 8599 8599 // Public. 8600 //------------------------------------------------------------------------- ----8601 8602 //------------------------------------------------------------------------- ----8600 //------------------------------------------------------------------------- 8601 8602 //------------------------------------------------------------------------- 8603 8603 // Stripify. 8604 //------------------------------------------------------------------------- ----8604 //------------------------------------------------------------------------- 8605 8605 int CustomStripifier::Stripify() 8606 8606 { … … 8620 8620 } 8621 8621 8622 //------------------------------------------------------------------------- ----8622 //------------------------------------------------------------------------- 8623 8623 // GetMesh: Return de current Mesh. 8624 //------------------------------------------------------------------------- ----8624 //------------------------------------------------------------------------- 8625 8625 Mesh* CustomStripifier::GetMesh() 8626 8626 { … … 8633 8633 } 8634 8634 8635 //------------------------------------------------------------------------- ----8635 //------------------------------------------------------------------------- 8636 8636 // Set the progress bar function. 8637 //------------------------------------------------------------------------- ----8637 //------------------------------------------------------------------------- 8638 8638 void CustomStripifier::SetProgressFunc(TIPOFUNC upb) 8639 8639 { … … 8642 8642 } 8643 8643 8644 //------------------------------------------------------------------------- ----8644 //------------------------------------------------------------------------- 8645 8645 // Sets what is the submesh that stores the leaves. 8646 //------------------------------------------------------------------------- ----8646 //------------------------------------------------------------------------- 8647 8647 void CustomStripifier::SetSubMeshLeaves(size_t submesh) 8648 8648 { -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSubMesh.cpp
r1009 r2341 15 15 mType(GEO_TRIANGLE_LIST) 16 16 { 17 strcpy(mName,""); 17 18 strcpy(mMaterialName,""); 18 19 } -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r2127 r2341 307 307 size_t getTriangleCount(Mesh *geoMesh); 308 308 309 // Get the number of degenerated triangles. 310 size_t getDegeneratedCount(Mesh *geoMesh); 311 309 312 // Get the number of strips. 310 313 size_t getStripCount(Mesh *geoMesh); … … 340 343 341 344 // Set textures to mesh model. 342 void setTextures(); 345 void setTextures(); 346 347 // Write strips into a file. 348 void writeStrips(Mesh *geomesh); 343 349 344 350 public: … … 400 406 fltk::Widget *mVertices; 401 407 fltk::Widget *mTriangles; 408 fltk::Widget *mDegenerated; 402 409 fltk::Widget *mStrips; 403 410 fltk::Widget *mQuads; -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r2324 r2341 37 37 y = fltk::event_y(); 38 38 39 40 39 switch (button) 41 40 { … … 139 138 } 140 139 141 //------------------------------------------------------------------------- --140 //------------------------------------------------------------------------- 142 141 // Get the number of frames per second. 143 //------------------------------------------------------------------------- --142 //------------------------------------------------------------------------- 144 143 size_t GeoMeshView::getFPS() 145 144 { … … 147 146 } 148 147 149 //------------------------------------------------------------------------- --148 //------------------------------------------------------------------------- 150 149 // Calculate the number of frames per second. 151 //------------------------------------------------------------------------- --150 //------------------------------------------------------------------------- 152 151 void GeoMeshView::calcFPS() 153 152 { … … 643 642 { 644 643 // The end of the index array. 645 indexEnd = 646 size =indexEnd - indexBegin;644 indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 645 size = indexEnd - indexBegin; 647 646 } 648 647 else … … 678 677 } 679 678 680 // VERTEX ARRAYS679 // VERTEX ARRAYS. 681 680 glEnableClientState(GL_VERTEX_ARRAY); 682 681 glEnableClientState(GL_NORMAL_ARRAY); … … 938 937 // For each one of the strips. 939 938 int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 940 939 941 940 glBegin(GL_TRIANGLE_STRIP); 942 941 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r2323 r2341 104 104 } 105 105 106 107 108 106 //------------------------------------------------------------------------- 109 107 // Repaint the FPS label. … … 156 154 cb_menuFileSave_i(o,v); 157 155 } 156 158 157 159 158 //------------------------------------------------------------------------- … … 1086 1085 stripify(); 1087 1086 1087 // Debug. 1088 //writeStrips(mGeoMesh); 1089 1088 1090 break; 1089 1091 … … 1298 1300 { 1299 1301 char *file_name = NULL; 1302 char *ptr; 1303 char message[255]; 1300 1304 GeoMeshSaver *mesh_saver; 1301 1305 Serializer *oSerializer; 1306 int answer_yes; 1302 1307 1303 1308 // Sets the progress bar to process bar. … … 1320 1325 if (file_name) 1321 1326 { 1322 // Undo the simplification changes. 1323 undo(); 1324 1325 // Stripify the mesh object. 1326 stripify(); 1327 1328 // Reset the build bar. 1329 mBuildBar->position(0); 1330 1331 // Simplification sequence. 1332 oMeshSimpSequence = mMeshSimplifier->GetSimplificationSequence(); 1333 1334 // If the simplification sequence and the mesh exist. 1335 if (oMeshSimpSequence && mGeoMesh) 1336 { 1337 oLodStrip = new LodStripsConstructor( mGeoMesh, 1338 oMeshSimpSequence, 1339 idMeshLeaves, 1340 progress_function); 1341 1342 oLodStrip->UpdateMesh(); 1343 1344 // Deletes the previous mesh. 1345 delete mUndoMesh; 1346 1347 mUndoMesh = new Mesh(); 1348 1349 // Sets the undo mesh. 1350 *mUndoMesh = *mGeoMesh; 1351 1352 delete mGeoMesh; 1353 1354 mGeoMesh = oLodStrip->GetMesh(); 1355 1356 geoMeshView->setMesh(mGeoMesh); 1357 1358 mesh_saver = new GeoMeshSaver(); 1359 1360 mesh_saver->leavesSubMesh = idMeshLeaves; 1361 mesh_saver->leavesVB = origSubMeshVB; 1362 mesh_saver->numindices = orig_numindices; 1363 mesh_saver->indices = orig_indices; 1364 1365 mesh_saver->save(mGeoMesh,file_name); 1366 1367 delete mesh_saver; 1368 1369 oLodStrip->Save(file_name); 1327 // Cut extension. 1328 ptr = strtok(file_name,"."); 1329 1330 // If has extension. 1331 if (ptr) 1332 { 1333 strcpy(file_name,ptr); 1334 } 1335 1336 // Adds mesh extension. 1337 strcat(file_name,".mesh"); 1338 1339 // If File Exists. 1340 if (fileExists(file_name)) 1341 { 1342 // Compose message. 1343 strcpy(message,"Do you want to replace "); 1344 strcat(message,filename_name(file_name)); 1345 strcat(message,"?"); 1346 1347 // Question. 1348 answer_yes = fltk::ask(message); 1349 } 1350 1351 // If answer yes to replace question 1352 // or if file not exists. 1353 if (answer_yes) 1354 { 1355 1356 // Undo the simplification changes. 1357 undo(); 1358 1359 // Stripify the mesh object. 1360 stripify(); 1361 1362 // Reset the build bar. 1363 mBuildBar->position(0); 1364 1365 // Simplification sequence. 1366 oMeshSimpSequence = mMeshSimplifier->GetSimplificationSequence(); 1367 1368 // If the simplification sequence and the mesh exist. 1369 if (oMeshSimpSequence && mGeoMesh) 1370 { 1371 oLodStrip = new LodStripsConstructor( mGeoMesh, 1372 oMeshSimpSequence, 1373 idMeshLeaves, 1374 progress_function); 1375 1376 oLodStrip->UpdateMesh(); 1377 1378 // Deletes the previous mesh. 1379 delete mUndoMesh; 1380 1381 mUndoMesh = new Mesh(); 1382 1383 // Sets the undo mesh. 1384 *mUndoMesh = *mGeoMesh; 1385 1386 delete mGeoMesh; 1387 1388 mGeoMesh = oLodStrip->GetMesh(); 1389 1390 geoMeshView->setMesh(mGeoMesh); 1391 1392 mesh_saver = new GeoMeshSaver(); 1393 1394 mesh_saver->leavesSubMesh = idMeshLeaves; 1395 mesh_saver->leavesVB = origSubMeshVB; 1396 mesh_saver->numindices = orig_numindices; 1397 mesh_saver->indices = orig_indices; 1398 1399 mesh_saver->save(mGeoMesh,file_name); 1400 1401 delete mesh_saver; 1402 1403 oLodStrip->Save(file_name); 1404 } 1370 1405 } 1371 1406 else … … 1837 1872 { 1838 1873 char type[10]; 1874 1839 1875 unsigned int group_index; 1840 1876 unsigned int group_count; 1841 1877 unsigned int bone_count; 1878 1842 1879 fltk::ItemGroup **info_group; 1843 1880 … … 1867 1904 char *skel_name = new char[256]; 1868 1905 char *bone_assig = new char[256]; 1906 1869 1907 sprintf(group_name,"Skeleton"); 1870 1908 info_group[group_index] = new fltk::ItemGroup(group_name); … … 1879 1917 bone_count += mGeoMesh->mSubMesh[i].mBones.size(); 1880 1918 } 1919 1881 1920 sprintf(bone_assig,"Bone assignamets: %d",bone_count); 1882 1921 new fltk::Item(bone_assig); … … 1886 1925 } 1887 1926 1888 for(int i =0; i<mGeoMesh->mSubMeshCount;i++)1927 for(int i = 0; i < mGeoMesh->mSubMeshCount; i++) 1889 1928 { 1890 1929 char *group_name = new char[256]; … … 1907 1946 1908 1947 // Submesh identifier. 1909 sprintf(group_name,"SubMesh %d %s",i,type); 1948 sprintf(group_name, 1949 "SubMesh %d %s:%s", 1950 i, 1951 type, 1952 mGeoMesh->mSubMesh[i].mName); 1910 1953 1911 1954 info_group[group_index] = new fltk::ItemGroup(group_name); 1912 1955 info_group[group_index]->begin(); 1913 1956 fltk::Item *sharedGeometry; 1957 1914 1958 if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) 1915 1959 { … … 1922 1966 1923 1967 // Adds material name. 1924 char *cadena2 =new char[100];1968 char *cadena2 = new char[100]; 1925 1969 sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); 1926 1970 1927 1971 fltk::Item *geomaterial = new fltk::Item(cadena2); 1928 1972 1929 char *cadena3 =new char[100];1973 char *cadena3 = new char[100]; 1930 1974 1931 sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); 1975 sprintf(cadena3, 1976 "Number of indexes: %d", 1977 mGeoMesh->mSubMesh[i].mIndexCount); 1978 1932 1979 fltk::Item *numberIndex = new fltk::Item(cadena3); 1980 1933 1981 if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) 1934 1982 { 1935 fltk::Item *type =new fltk::Item("Triangle List");1983 fltk::Item *type = new fltk::Item("Triangle List"); 1936 1984 } 1937 1985 else 1938 1986 { 1939 fltk::Item *type =new fltk::Item("Triangle Strips");1987 fltk::Item *type = new fltk::Item("Triangle Strips"); 1940 1988 } 1941 1989 1942 char *cadenavertex=new char[30]; 1943 sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); 1944 fltk::Item *numberVertex = new fltk::Item(cadenavertex); 1945 1946 if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 1990 char *cadenavertex = new char[30]; 1991 1992 sprintf(cadenavertex, 1993 "Number of vertices: %d", 1994 mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); 1995 1996 fltk::Item *numberVertex = new fltk::Item(cadenavertex); 1997 1998 if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo 1999 & 2000 Geometry::VERTEX_NORMAL) 1947 2001 { 1948 fltk::Item *normals =new fltk::Item("Normals: Yes");2002 fltk::Item *normals = new fltk::Item("Normals: Yes"); 1949 2003 } 1950 2004 else 1951 2005 { 1952 fltk::Item *normals =new fltk::Item("Normals: No");2006 fltk::Item *normals = new fltk::Item("Normals: No"); 1953 2007 } 1954 2008 1955 if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 2009 if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo 2010 & 2011 Geometry::VERTEX_TEXCOORDS) 1956 2012 { 1957 fltk::Item *textures =new fltk::Item("Textures: Yes");2013 fltk::Item *textures = new fltk::Item("Textures: Yes"); 1958 2014 } 1959 2015 else 1960 2016 { 1961 fltk::Item *textures =new fltk::Item("Textures: No");2017 fltk::Item *textures = new fltk::Item("Textures: No"); 1962 2018 } 1963 2019 1964 1965 2020 info_group[group_index]->end(); 1966 2021 } 2022 1967 2023 ogeometry->end(); 1968 2024 this->mMeshInfo->add(ogeometry); … … 2057 2113 break; 2058 2114 case GEO_TRIANGLE_STRIPS: 2059 triangle_count += geoSubMesh->mIndexCount - 2; 2115 triangle_count += geoSubMesh->mIndexCount 2116 - 2117 2; 2060 2118 break; 2061 2119 } … … 2064 2122 2065 2123 return triangle_count; 2124 } 2125 2126 //------------------------------------------------------------------------- 2127 // Get the number of degenerated triangles. 2128 //------------------------------------------------------------------------- 2129 size_t GeoMeshViewUI::getDegeneratedCount(Geometry::Mesh *geoMesh) 2130 { 2131 size_t degenerated; 2132 size_t same_index; 2133 SubMesh *geoSubMesh; 2134 2135 // Initialize the degenerated count. 2136 degenerated = 0; 2137 2138 // Initiazlize same index count. 2139 same_index = 1; 2140 2141 // For each submesh. 2142 for (size_t submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 2143 { 2144 // Gets the actual submesh. 2145 geoSubMesh = &geoMesh->mSubMesh[submesh]; 2146 2147 if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 2148 { 2149 // Find degenerated triangles. 2150 for (size_t i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 2151 { 2152 if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i + 1]) 2153 { 2154 same_index++; 2155 } 2156 else 2157 { 2158 if (same_index > 1) 2159 { 2160 degenerated += same_index; 2161 } 2162 else if (i < (geoSubMesh->mIndexCount - 2)) 2163 { 2164 if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i + 2]) 2165 { 2166 degenerated++; 2167 } 2168 } 2169 2170 same_index = 1; 2171 } 2172 } 2173 } 2174 } 2175 2176 return degenerated; 2066 2177 } 2067 2178 … … 2460 2571 static char vertices_value[50]; 2461 2572 static char triangles_value[50]; 2573 static char degenerated_value[50]; 2462 2574 static char strips_value[50]; 2463 2575 … … 2471 2583 2472 2584 mTriangles->label(triangles_value); 2585 2586 // Translate the degenerated count to a char value. 2587 sprintf(degenerated_value,"Degenerated %d",getDegeneratedCount(mGeoMesh)); 2588 2589 mDegenerated->label(degenerated_value); 2473 2590 2474 2591 // Translate the triangle count to a char value. … … 2679 2796 } 2680 2797 2798 //------------------------------------------------------------------------- 2681 2799 // Set textures to mesh model. 2800 //------------------------------------------------------------------------- 2682 2801 void GeoMeshViewUI::setTextures() 2683 2802 { … … 3241 3360 { 3242 3361 fltk::Widget* o; 3243 o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); 3362 o = mDegenerated = new fltk::Widget(354, 3, 30, 15, "Degenerated"); 3363 o->box(fltk::NO_BOX); 3364 o->labelfont(fltk::HELVETICA_BOLD); 3365 o->color((fltk::Color)0xe0dfe300); 3366 } 3367 3368 { 3369 fltk::Widget* o; 3370 o = mStrips = new fltk::Widget(454, 3, 30, 15, "Strips"); 3244 3371 o->box(fltk::NO_BOX); 3245 3372 o->labelfont(fltk::HELVETICA_BOLD); … … 3320 3447 } 3321 3448 3449 //------------------------------------------------------------------------- 3450 // Write file of strips. 3451 //------------------------------------------------------------------------- 3452 void GeoMeshViewUI::writeStrips(Mesh *geomesh) 3453 { 3454 Index *index; 3455 Index *indexBegin; 3456 Index *indexEnd; 3457 SubMesh *geosubmesh; 3458 3459 ofstream out ("strips.txt"); 3460 3461 // For each submesh. 3462 for (size_t submesh = 0; submesh < geomesh->mSubMeshCount; submesh++) 3463 { 3464 geosubmesh = &geomesh->mSubMesh[submesh]; 3465 3466 // For each one of the strips. 3467 for (size_t strip = 0; strip < geosubmesh->mStripCount; strip++) 3468 { 3469 // First index of the strip. 3470 indexBegin = geosubmesh->mStrip[strip]; 3471 3472 // If is the final strip 3473 if (strip == (geosubmesh->mStripCount - 1)) 3474 { 3475 // The end of the index array. 3476 indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 3477 } 3478 else 3479 { 3480 // The beginning of the next strip. 3481 indexEnd = geosubmesh->mStrip[strip + 1]; 3482 } 3483 3484 for (index = indexBegin; index < indexEnd; index++) 3485 { 3486 out << index[0] 3487 << " "; 3488 } 3489 3490 out << endl; 3491 } 3492 } 3493 3494 out.close(); 3495 } 3496
Note: See TracChangeset
for help on using the changeset viewer.