Changeset 2341 for GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Timestamp:
- 04/30/07 08:16:31 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.