Changeset 1017 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 06/15/06 11:50:48 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshSaver.h
r989 r1017 113 113 // Saves a Mesh into a file. 114 114 int save(Mesh *geoMesh, const char *fileNameMesh); 115 116 // temporal members used to tweak the lodtree leaf submesh 117 int leavesSubMesh; 118 VertexBuffer *leavesVB; 119 Index *indices; 120 int numindices; 115 121 }; 116 122 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp
r989 r1017 23 23 GeoMeshSaver::GeoMeshSaver() 24 24 { 25 leavesSubMesh=-1; 26 leavesVB=NULL; 27 numindices=0; 28 indices=NULL; 25 29 } 26 30 … … 60 64 unnormalizeModel(mGeoMesh); 61 65 66 if (leavesSubMesh>-1 && leavesVB) 67 { 68 Vector3 bmax(geoMesh->mMeshBounds.maxX,geoMesh->mMeshBounds.maxY,geoMesh->mMeshBounds.maxZ); 69 Vector3 bmin(geoMesh->mMeshBounds.minX,geoMesh->mMeshBounds.minY,geoMesh->mMeshBounds.minZ); 70 Vector3 center = (bmax+bmin)*0.5f; 71 float scale = geoMesh->mMeshBounds.scaleFactor; 72 73 mGeoMesh->mSubMesh[leavesSubMesh].mSharedVertexBuffer=false; 74 mGeoMesh->mSubMesh[leavesSubMesh].mStripCount=0; 75 mGeoMesh->mSubMesh[leavesSubMesh].mIndexCount=numindices; 76 int icount = mGeoMesh->mSubMesh[leavesSubMesh].mIndexCount; 77 mGeoMesh->mSubMesh[leavesSubMesh].mIndex=new Index[icount]; 78 for (int i=0; i<icount; i++) 79 mGeoMesh->mSubMesh[leavesSubMesh].mIndex[i]=indices[i]; 80 81 mGeoMesh->mSubMesh[leavesSubMesh].mType=GEO_TRIANGLE_LIST; 82 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer=new VertexBuffer(); 83 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexInfo=VERTEX_POSITION; 84 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexCount=leavesVB->mVertexCount;; 85 int vcount = mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexCount; 86 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition=new Vector3[vcount]; 87 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal=new Vector3[vcount]; 88 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords=new Vector2[vcount]; 89 for (int i=0; i<vcount; i++) 90 { 91 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].x = leavesVB->mPosition[i].x / scale + center.x; 92 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].y = leavesVB->mPosition[i].y / scale + center.y; 93 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].z = leavesVB->mPosition[i].z / scale + center.z; 94 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].x = leavesVB->mNormal[i].x; 95 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].y = leavesVB->mNormal[i].y; 96 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].z = leavesVB->mNormal[i].z; 97 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords[i].x = leavesVB->mTexCoords[i].x; 98 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords[i].y = leavesVB->mTexCoords[i].y; 99 } 100 } 101 62 102 // Open the file. 63 mSerializer = new Serializer( name, 64 Serializer::WRITE); 65 103 mSerializer = new Serializer(name,Serializer::WRITE); 66 104 67 105 // Write the file header. … … 773 811 // Translate around center then scale. 774 812 // For each submesh. 813 814 bool sharedScaled=false; 815 775 816 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 776 817 { … … 778 819 vertex_buffer = geoMesh->mSubMesh[submesh].mVertexBuffer; 779 820 821 if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer && sharedScaled) 822 continue; 823 780 824 // For each index of the strip. 781 825 for (int i = 0; i < vertex_buffer->mVertexCount; i++) … … 791 835 // If is a shared vertex Buffer. 792 836 if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer) 793 { 794 break; 795 } 796 } 797 } 798 837 sharedScaled=true; 838 } 839 } 840 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1014 r1017 1003 1003 } 1004 1004 1005 VertexBuffer *origSubMeshVB=NULL; 1006 int orig_numindices=0; 1007 Index *orig_indices=NULL; 1008 1005 1009 //--------------------------------------------------------------------------- 1006 1010 // Button Process Callback … … 1014 1018 progressBarType = PROCESS; 1015 1019 mProcessBar->position(0); 1020 1021 origSubMeshVB=NULL; 1016 1022 1017 1023 // Initialize error flag. … … 1080 1086 else 1081 1087 { 1088 origSubMeshVB=mGeoMesh->mSubMesh[idMeshLeaves].mVertexBuffer->Clone(); 1089 orig_numindices=mGeoMesh->mSubMesh[idMeshLeaves].mIndexCount; 1090 orig_indices=new Index[orig_numindices]; 1091 for (int i=0; i<orig_numindices; i++) 1092 orig_indices[i]=mGeoMesh->mSubMesh[idMeshLeaves].mIndex[i]; 1093 1082 1094 std::cout << "Simplificando hojas..."; 1083 1095 simplifyLeavesCollapse(); … … 1324 1336 file_name[strlen(file_name) - 4] = '\0'; 1325 1337 1338 mesh_saver->leavesSubMesh=idMeshLeaves; 1339 mesh_saver->leavesVB=origSubMeshVB; 1340 mesh_saver->numindices=orig_numindices; 1341 mesh_saver->indices=orig_indices; 1326 1342 mesh_saver->save( mGeoMesh, 1327 1343 strcat(file_name,".mesh"));
Note: See TracChangeset
for help on using the changeset viewer.