Changeset 989 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 05/29/06 11:59:07 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h
r980 r989 114 114 unsigned long long_actual; 115 115 size_t currentSubMesh; 116 bool mError; 116 117 117 118 struct GeometryElement -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshSaver.h
r980 r989 110 110 // Gets the material of the mesh. 111 111 String getMaterialName(); 112 112 113 113 // Saves a Mesh into a file. 114 114 int save(Mesh *geoMesh, const char *fileNameMesh); -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r988 r989 71 71 enum SimplificationType 72 72 { 73 NO_SIMPLIFICATION, 73 74 MESHSIMP, 74 75 HOJAS, … … 121 122 inline void cb_menuFileSave_i(fltk::Item*, void*); 122 123 static void cb_menuFileSave(fltk::Item*, void*); 123 inline void cb_menu OpenSaveAs_i(fltk::Item*, void*);124 static void cb_menu OpenSaveAs(fltk::Item*, void*);124 inline void cb_menuFileSaveAs_i(fltk::Item*, void*); 125 static void cb_menuFileSaveAs(fltk::Item*, void*); 125 126 126 127 inline void cb_menuMeshInfo_i(fltk::Item*, void*); … … 131 132 static void cb_menuFileTransformSharedVertex(fltk::Item* o, void* v); 132 133 133 inline void cb_menu OpenQuit_i(fltk::Item*, void*);134 static void cb_menu OpenQuit(fltk::Item*, void*);134 inline void cb_menuFileQuit_i(fltk::Item*, void*); 135 static void cb_menuFileQuit(fltk::Item*, void*); 135 136 inline void cb_menuEditUndo_i(fltk::Item*, void*); 136 137 static void cb_menuEditUndo(fltk::Item*, void*); … … 201 202 static void cb_mLogo(fltk::InvisibleBox*, void*); 202 203 204 // Shows build process. 205 void activeBuildProcess(); 206 203 207 // Shows the stripify panel. 204 208 void showStripify(); … … 271 275 void openMeshFile(); 272 276 277 // Check if file exists. 278 bool fileExists(const char *fileNameMesh); 279 273 280 public: 274 281 … … 281 288 fltk::Item *menuFileOpen; 282 289 fltk::Item *menuFileSave; 283 fltk::Item *menu OpenSaveAs;290 fltk::Item *menuFileSaveAs; 284 291 fltk::Item *menuMeshInfo; 285 292 fltk::Item *menuMeshExportOBJ; 286 293 fltk::Item *menuFileTransformSharedVertex; 287 294 288 fltk::Item *menu OpenQuit;295 fltk::Item *menuFileQuit; 289 296 fltk::ItemGroup *menuEdit; 290 297 fltk::Item *menuEditUndo; -
GTP/trunk/Lib/Geom/shared/GeoTool/out.objf
r988 r989 3 3 #by Francine Evans 4 4 5 t 1413 1414 1412 6 q 1415 7 q 1399 8 q 1400 9 q 1398 10 q 1401 11 q 1402 12 q 1403 13 q 1404 14 q 1405 15 q 1406 16 q 1407 17 q 1408 18 q 1409 19 q 1410 1411 20 t 1395 1396 1394 21 q 1397 22 q 1381 23 q 1382 24 q 1380 25 q 1383 26 q 1384 27 q 1385 28 q 1386 29 q 1387 30 q 1388 31 q 1389 32 q 1390 33 q 1391 34 q 1392 1393 35 t 1377 1378 1376 36 q 1379 37 q 1363 38 q 1364 39 q 1362 40 q 1365 41 q 1366 42 q 1367 43 q 1368 44 q 1369 45 q 1370 46 q 1371 47 q 1372 48 q 1373 49 q 1374 1375 50 t 1359 1360 1358 51 q 1361 52 q 1345 53 q 1346 54 q 1344 55 q 1347 56 q 1348 57 q 1349 58 q 1350 59 q 1351 60 q 1352 61 q 1353 62 q 1354 63 q 1355 64 q 1356 1357 65 t 1340 1341 1339 66 q 1342 67 q 1312 68 q 1313 69 q 1311 70 q 1314 71 q 1319 72 q 1320 73 q 1323 74 q 1324 75 q 1327 76 q 1328 77 q 1331 78 q 1332 79 q 1335 1336 80 t 1294 1295 1293 81 q 1305 82 q 1304 83 q 1301 84 q 1300 85 q 1297 86 q 1296 87 q 1298 88 q 1299 89 q 1302 90 q 1303 91 q 1306 92 q 1307 93 q 1291 94 q 1290 1292 95 t 1284 1285 1283 96 q 1286 97 q 1287 98 q 1289 99 q 1275 100 q 1276 1275 101 q 1252 1275 102 q 1255 1275 103 q 1277 104 q 1287 105 q 1278 106 q 1279 1278 107 q 1259 1278 108 q 1257 109 q 1277 1257 110 q 1255 111 q 1256 1255 112 q 1254 113 q 1252 1254 114 q 1253 1254 115 q 1274 1254 116 q 1273 117 q 1256 118 q 1258 119 q 1257 1258 120 q 1259 1258 121 q 1260 122 q 1273 123 q 1262 1273 124 q 1272 1273 125 q 1270 1273 126 q 1271 1274 127 t 1271 1268 1270 1269 128 t 1288 1283 1288 1287 129 q 1280 130 q 1279 131 q 1261 132 q 1259 1261 133 q 1260 1261 134 q 1262 1261 135 q 1263 136 q 1280 137 q 1281 138 q 1288 1281 139 q 1282 1281 140 q 1265 141 q 1263 142 q 1264 143 q 1262 1264 144 q 1272 1264 145 q 1266 146 q 1265 147 q 1267 1282 148 t 1453 1452 1453 1479 149 q 1478 150 q 1475 151 q 1474 152 q 1471 153 q 1470 154 q 1467 155 q 1466 156 q 1463 157 q 1462 158 q 1459 159 q 1458 160 q 1455 161 q 1454 162 q 1452 1453 163 t 1477 1476 1477 1451 164 q 1450 165 q 1448 166 q 1449 167 q 1456 168 q 1457 169 q 1460 170 q 1461 171 q 1464 172 q 1465 173 q 1468 174 q 1469 175 q 1472 176 q 1473 177 q 1476 1477 178 t 1421 1420 1421 1447 179 q 1446 180 q 1443 181 q 1442 182 q 1439 183 q 1438 184 q 1435 185 q 1434 186 q 1431 187 q 1430 188 q 1427 189 q 1426 190 q 1423 191 q 1422 192 q 1420 1421 193 t 1445 1444 1445 1419 194 q 1418 195 q 1416 196 q 1417 197 q 1424 198 q 1425 199 q 1428 200 q 1429 201 q 1432 202 q 1433 203 q 1436 204 q 1437 205 q 1440 206 q 1441 207 q 1444 1445 208 t 1343 1317 1316 209 q 1315 1316 210 q 1321 1316 211 q 1325 1316 212 q 1329 1316 213 q 1333 1316 214 q 1337 1343 215 t 1309 1338 1310 216 q 1334 1310 217 q 1330 1310 218 q 1326 1310 219 q 1322 1310 220 q 1318 1310 221 q 1308 1309 5 t 77 128 77 57 6 q 76 57 7 q 56 8 q 49 9 q 51 49 10 q 50 49 11 q 52 49 12 q 59 49 13 q 46 49 14 q 47 49 15 q 58 16 q 57 58 17 q 53 58 18 q 55 58 19 q 60 58 20 q 48 21 q 47 22 q 43 23 q 46 24 q 42 25 q 41 42 26 q 39 27 q 43 28 q 44 29 q 48 60 30 t 39 44 39 40 31 q 41 40 32 q 45 33 q 44 34 q 52 35 q 55 52 36 q 53 52 37 q 54 38 q 50 54 39 q 68 40 q 53 41 q 67 42 q 128 67 43 q 138 44 q 139 138 45 q 144 138 46 q 124 138 47 q 127 48 q 128 127 49 q 126 50 q 124 51 q 125 124 52 q 123 53 q 144 123 54 q 130 55 q 125 56 q 132 57 q 131 132 58 q 128 132 59 q 77 132 60 q 76 61 q 130 76 62 q 144 63 q 145 64 q 139 65 q 97 139 66 q 140 67 q 67 68 q 141 69 q 143 141 70 q 142 71 q 140 142 72 q 97 73 q 96 97 74 q 95 97 75 q 103 97 76 q 105 97 77 q 102 78 q 145 79 q 78 80 q 76 81 q 75 76 82 q 74 83 q 56 74 84 q 50 74 85 q 68 86 q 69 87 q 67 69 88 q 70 89 q 17 90 q 73 91 q 18 92 q 62 18 93 q 20 18 94 q 19 95 q 17 96 q 25 17 97 q 28 98 q 24 99 q 29 100 q 23 29 101 q 27 29 102 q 32 29 103 q 34 104 q 28 105 q 33 106 q 25 33 107 q 11 33 108 q 15 109 q 34 110 q 13 111 q 32 112 q 16 32 113 q 31 114 q 27 31 115 q 26 116 q 30 26 117 q 25 26 118 q 19 119 q 21 120 q 20 121 q 22 20 122 q 66 123 q 62 124 q 65 62 125 q 61 62 126 q 63 62 127 q 72 128 q 73 129 q 71 130 q 70 71 131 q 67 132 q 72 67 133 q 63 134 q 143 135 q 135 136 q 142 135 137 q 96 138 q 98 139 q 95 98 140 q 99 98 141 q 100 98 142 q 137 143 q 135 137 144 q 64 137 145 q 38 146 q 66 147 q 64 148 q 65 64 149 q 61 150 q 136 151 q 63 136 152 q 135 64 153 t 27 26 27 21 154 q 23 155 q 22 156 q 24 22 157 q 78 158 q 66 78 159 q 137 78 160 q 100 161 q 102 100 162 q 101 163 q 99 101 164 q 106 165 q 102 106 166 q 105 167 q 111 105 168 q 110 169 q 103 110 170 q 90 110 171 q 93 172 q 111 173 q 91 111 174 q 92 111 175 q 109 176 q 106 109 177 q 99 178 q 108 99 179 q 104 180 q 95 104 181 q 103 104 182 q 107 183 q 108 107 184 q 87 107 185 q 88 107 186 q 89 187 q 103 89 188 q 90 189 q 83 90 190 q 84 191 q 93 192 q 85 193 q 91 194 q 81 195 q 92 196 q 86 92 197 q 94 198 q 109 94 199 q 108 94 200 q 87 94 201 q 79 202 q 86 79 203 q 81 79 204 q 80 205 q 87 80 206 q 88 207 q 82 208 q 89 82 209 q 83 82 210 q 81 80 211 t 81 83 81 84 85 212 t 24 78 24 75 213 q 17 75 214 q 69 74 215 t 45 52 45 46 41 216 t 14 1 13 217 q 8 218 q 16 219 q 3 16 220 q 10 221 q 31 10 222 q 30 10 223 q 9 10 224 q 2 225 q 3 2 226 q 1 2 227 q 5 228 q 9 229 q 12 230 q 30 12 231 q 25 12 232 q 11 12 233 q 4 234 q 5 4 235 q 1 4 236 q 7 237 q 11 7 238 q 15 239 q 6 240 q 14 6 241 q 1 7 242 t 1 3 1 8 243 t 128 131 128 129 244 q 126 245 q 134 126 246 q 133 247 q 125 248 q 120 125 249 q 121 250 q 131 251 q 122 252 q 129 122 253 q 117 122 254 q 118 255 q 121 118 256 q 120 118 257 q 116 118 258 q 115 259 q 117 260 q 114 117 261 q 119 117 262 q 133 134 263 t 120 133 120 119 264 q 113 265 q 114 113 266 q 115 113 267 q 116 120 268 t 38 112 35 269 q 36 35 270 q 37 38 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
r985 r989 15 15 using namespace std; 16 16 17 //--------------------------------------------------------------------------- 17 18 // Jump a chunk. 19 //--------------------------------------------------------------------------- 18 20 void GeoMeshLoader::jumpChunk(FILE *f) 19 21 { … … 24 26 } 25 27 28 //--------------------------------------------------------------------------- 26 29 // Read a chunk. 30 //--------------------------------------------------------------------------- 27 31 unsigned short GeoMeshLoader::readChunk(FILE *f) 28 32 { … … 35 39 } 36 40 41 //--------------------------------------------------------------------------- 37 42 // Read geometry vertex element. 43 //--------------------------------------------------------------------------- 38 44 void GeoMeshLoader::readGeometryVertexElement(FILE *f, Mesh *geoMesh) 39 45 { … … 103 109 } 104 110 111 //--------------------------------------------------------------------------- 105 112 // Read geometry vertex declaration. 113 //--------------------------------------------------------------------------- 106 114 void GeoMeshLoader::readGeometryVertexDeclaration(FILE *f, Mesh *geoMesh) 107 115 { … … 143 151 }// End readGeometryVertexDeclaration. 144 152 153 //--------------------------------------------------------------------------- 145 154 // Read geometry vertex buffer. 155 //--------------------------------------------------------------------------- 146 156 void GeoMeshLoader::readGeometryVertexBuffer(FILE *f, Mesh *geoMesh, int option) 147 157 { … … 270 280 cout << "Error: Source not found." 271 281 << endl; 272 } 273 274 } 275 282 283 // Error. 284 mError = true; 285 } 286 287 } 288 289 //--------------------------------------------------------------------------- 276 290 // Read Geometry. 291 //--------------------------------------------------------------------------- 277 292 void GeoMeshLoader::readGeometry(FILE *f, Mesh *geoMesh, int option) 278 293 { … … 361 376 } 362 377 378 //--------------------------------------------------------------------------- 363 379 // Read a submesh operation. 380 //--------------------------------------------------------------------------- 364 381 void GeoMeshLoader::readSubMeshOperation( FILE *f, 365 382 Mesh *geoMesh, … … 383 400 } 384 401 402 //--------------------------------------------------------------------------- 385 403 // Read a submesh. 404 //--------------------------------------------------------------------------- 386 405 void GeoMeshLoader::readSubMesh(FILE *f, Mesh *geoMesh, int option) 387 406 { … … 479 498 cout << "Error: Missing mesh geometry." 480 499 << endl; 500 501 // Error. 502 mError = true; 481 503 } 482 504 … … 537 559 } 538 560 561 //--------------------------------------------------------------------------- 539 562 // Read a mesh lod information. 563 //--------------------------------------------------------------------------- 540 564 void GeoMeshLoader::readMeshLodInfo(FILE *f, Mesh *geoMesh) 541 565 { … … 572 596 } 573 597 598 //--------------------------------------------------------------------------- 574 599 // Read a submesh name table. 600 //--------------------------------------------------------------------------- 575 601 void GeoMeshLoader::readSubMeshNameTable(FILE *f, Mesh *geoMesh) 576 602 { … … 609 635 } 610 636 637 //--------------------------------------------------------------------------- 611 638 // Read a mesh file. 639 //--------------------------------------------------------------------------- 612 640 void GeoMeshLoader::readMesh(FILE *f, Mesh *geoMesh, int option) 613 641 { … … 741 769 cout << "Error: Reading failure." 742 770 << endl; 743 } 744 } 745 746 } 747 748 /* 749 Allocate memory to the array of strips 750 */ 771 772 // Error. 773 mError = true; 774 } 775 } 776 777 } 778 779 780 //--------------------------------------------------------------------------- 781 // Allocate memory to the array of strips 782 //--------------------------------------------------------------------------- 751 783 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh) 752 784 { … … 848 880 } 849 881 882 //--------------------------------------------------------------------------- 850 883 // Remove degenerate triangles of a submesh given. 884 //--------------------------------------------------------------------------- 851 885 SubMesh * GeoMeshLoader::removeDegenerateTriangles(SubMesh *geoSubMesh) 852 886 { … … 951 985 } 952 986 987 //--------------------------------------------------------------------------- 953 988 // Loads a mesh. 989 //--------------------------------------------------------------------------- 954 990 Mesh* GeoMeshLoader::load(char *nameFileMesh) 955 991 { … … 961 997 SubMesh *geosubmesh; 962 998 963 // Initialize the current submesh;964 currentSubMesh = -1;965 966 999 // Debug. 967 1000 cout << "---------------------------------" … … 972 1005 << endl; 973 1006 974 // Initialize the return value. 975 geoMesh = new Mesh(); 1007 geoMesh = NULL; 976 1008 977 1009 // Open the mesh file. 978 pFile = fopen( nameFileMesh, "rb" ); 979 980 if (!pFile) 981 { 1010 pFile = fopen(nameFileMesh, "rb"); 1011 1012 if (pFile) 1013 { 1014 // Initialize the current submesh; 1015 currentSubMesh = -1; 1016 1017 // Initialize the return value. 1018 geoMesh = new Mesh(); 1019 1020 // Count the submeshes 1021 // and next build the geomesh. 1022 for (int option = 0; option < 2;option++) 1023 { 1024 // Initialize Error. 1025 mError = false; 1026 1027 fread(&uno,sizeof(unsigned short),1,pFile); 1028 1029 if (uno != M_HEADER) 1030 { 1031 // Debug. 1032 cout << "Error: Header not found." 1033 << endl; 1034 1035 // Error. 1036 mError = true; 1037 } 1038 1039 // Read version. 1040 fgets(version,255,pFile); 1041 1042 cout << version << endl; 1043 1044 if (strcmp(version,"[MeshSerializer_v1.30]\n")) 1045 { 1046 // Debug. 1047 cout << "Error: Wrong mesh version." 1048 << endl 1049 << "Only version 1.3 or older allowed." 1050 << endl; 1051 1052 // Error. 1053 mError = true; 1054 } 1055 1056 while(!feof(pFile)) 1057 { 1058 chunkID = readChunk(pFile); 1059 1060 switch (chunkID) 1061 { 1062 case M_MESH: 1063 readMesh(pFile, geoMesh, option); 1064 break; 1065 } 1066 } 1067 1068 // Create the submesh array. 1069 if (option == SUBMESH_COUNT) 1070 { 1071 geoMesh->mSubMesh = new SubMesh[geoMesh->mSubMeshCount]; 1072 } 1073 1074 // Move the curso to the begining of the file. 1075 fseek(pFile,0,SEEK_SET); 1076 } 1077 1078 // Goes to the end of the file. 1079 fseek(pFile,0,SEEK_END); 1080 1081 // Gets the size of the file. 1082 mFileSize = ftell(pFile); 1083 1084 // Close the mesh file. 1085 fclose(pFile); 1086 1087 // If no error. 1088 if (!mError) 1089 { 1090 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 1091 { 1092 // Gets the actual submesh. 1093 geosubmesh = &geoMesh->mSubMesh[submesh]; 1094 1095 if (geosubmesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 1096 { 1097 // Fill the strips list. 1098 geosubmesh = BuildStripsGeoSubMesh(geosubmesh); 1099 } 1100 } 1101 1102 // Sets coods between -1 and 1. 1103 normalizeModel(geoMesh); 1104 } 1105 } 1106 else 1107 { 982 1108 // Debug. 983 cout << "Error: File " 984 << nameFileMesh 985 << " not found." 1109 cout << "Error: File not found." 986 1110 << endl; 1111 1112 // File not found. 1113 mError = true; 1114 } 1115 1116 // If an error happens. 1117 if (mError) 1118 { 1119 delete geoMesh; 987 1120 988 exit(0); 989 } 990 991 // Count the submeshes 992 // and next build the geomesh. 993 for (int option = 0; option < 2;option++) 994 { 995 fread(&uno,sizeof(unsigned short),1,pFile); 996 997 if (uno != M_HEADER) 998 { 999 // Debug. 1000 cout << "Error: Header not found." 1001 << endl; 1002 } 1003 1004 // Read version. 1005 fgets(version,255,pFile); 1006 1007 cout << version << endl; 1008 1009 if (strcmp(version,"[MeshSerializer_v1.30]\n")) 1010 { 1011 // Debug. 1012 cout << "Error: Wrong mesh version." 1013 << endl 1014 << "Only version 1.3 or older allowed." 1015 << endl; 1016 } 1017 1018 while(!feof(pFile)) 1019 { 1020 chunkID = readChunk(pFile); 1021 1022 switch (chunkID) 1023 { 1024 case M_MESH: 1025 readMesh(pFile, geoMesh, option); 1026 break; 1027 } 1028 } 1029 1030 // Create the submesh array 1031 if (option == SUBMESH_COUNT) 1032 { 1033 geoMesh->mSubMesh = new SubMesh[geoMesh->mSubMeshCount]; 1034 } 1035 1036 // Move the curso to the begining of the file. 1037 fseek(pFile,0,SEEK_SET); 1038 } 1039 1040 // Goes to the end of the file. 1041 fseek(pFile,0,SEEK_END); 1042 1043 // Gets the size of the file. 1044 mFileSize = ftell(pFile); 1045 1046 // Close the mesh file. 1047 fclose(pFile); 1048 1049 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 1050 { 1051 // Gets the actual submesh. 1052 geosubmesh = &geoMesh->mSubMesh[submesh]; 1053 1054 if (geosubmesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 1055 { 1056 // Fill the strips list. 1057 geosubmesh = BuildStripsGeoSubMesh(geosubmesh); 1058 } 1059 } 1060 1061 // Sets coods between -1 and 1. 1062 normalizeModel(geoMesh); 1063 1121 geoMesh = NULL; 1122 } 1123 1064 1124 return geoMesh; 1065 1125 } 1066 1126 1127 //--------------------------------------------------------------------------- 1067 1128 // Sets coords between -1 and 1. 1129 //--------------------------------------------------------------------------- 1068 1130 void GeoMeshLoader::normalizeModel(Mesh *geoMesh) 1069 1131 { … … 1187 1249 } 1188 1250 1251 //--------------------------------------------------------------------------- 1189 1252 // Get the size in bytes of the file. 1253 //--------------------------------------------------------------------------- 1190 1254 size_t GeoMeshLoader::getFileSize() 1191 1255 { … … 1193 1257 } 1194 1258 1259 //--------------------------------------------------------------------------- 1195 1260 // Constructor 1261 //--------------------------------------------------------------------------- 1196 1262 GeoMeshLoader::GeoMeshLoader() 1197 1263 { … … 1200 1266 } 1201 1267 1268 //--------------------------------------------------------------------------- 1202 1269 // Destroyer. 1270 //--------------------------------------------------------------------------- 1203 1271 GeoMeshLoader::~GeoMeshLoader() 1204 1272 { … … 1206 1274 } 1207 1275 1208 //OSCAR 1276 //--------------------------------------------------------------------------- 1277 // Read bones of the submesh. 1278 //--------------------------------------------------------------------------- 1209 1279 void GeoMeshLoader::readSubMeshBoneAssignment(FILE* f, SubMesh* geoSubMesh,int option) 1210 1280 { … … 1224 1294 } 1225 1295 1226 //OSCAR 1296 //--------------------------------------------------------------------------- 1297 // Read bones of the main mesh. 1298 //--------------------------------------------------------------------------- 1227 1299 void GeoMeshLoader::readMeshBoneAssignment(FILE* f, Mesh* geoMesh,int option) 1228 1300 { … … 1243 1315 } 1244 1316 1245 //OSCAR 1317 //--------------------------------------------------------------------------- 1318 // Read skeleton link. 1319 //--------------------------------------------------------------------------- 1246 1320 void GeoMeshLoader::readSkeletonLink(FILE* f, Mesh* geoMesh,int option) 1247 1321 { … … 1259 1333 } 1260 1334 1335 //--------------------------------------------------------------------------- 1261 1336 // Read bounding box settings. 1337 //--------------------------------------------------------------------------- 1262 1338 void GeoMeshLoader::readMeshBounds(FILE *f, Mesh *geoMesh, int option) 1263 1339 { -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp
r985 r989 1 /* 1 /*========================================================================== 2 2 * (C) 2005 Universitat Jaume I 3 * 3 *========================================================================== 4 4 * PROYECT: GAME TOOLS 5 * 6 /* *CONTENT:7 8 9 10 /*===========================================================================*/5 *==========================================================================*/ 6 /* CONTENT: 7 * 8 * 9 * @file GeoMeshSaver.cpp 10 *==========================================================================*/ 11 11 #include <GeoMeshSaver.h> 12 12 … … 14 14 using namespace std; 15 15 16 //------------------------------------------ 16 //--------------------------------------------------------------------------- 17 17 // Public: 18 //------------------------------------------ 19 20 // //////////////////21 // Constructors. //22 // //////////////////18 //--------------------------------------------------------------------------- 19 20 //--------------------------------------------------------------------------- 21 // Constructors. 22 //--------------------------------------------------------------------------- 23 23 GeoMeshSaver::GeoMeshSaver() 24 24 { 25 25 } 26 26 27 // ////////////////28 // Destroyer. //29 // ////////////////27 //--------------------------------------------------------------------------- 28 // Destroyer. 29 //--------------------------------------------------------------------------- 30 30 GeoMeshSaver::~GeoMeshSaver() 31 31 { … … 33 33 } 34 34 35 //--------------------------------------------------------------------------- 35 36 // Saves a Mesh into a file. 37 //--------------------------------------------------------------------------- 36 38 int GeoMeshSaver::save(Mesh *geoMesh, const char *fileNameMesh) 37 39 { -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r988 r989 83 83 // Save As Callback 84 84 //--------------------------------------------------------------------------- 85 inline void GeoMeshViewUI::cb_menu OpenSaveAs_i(fltk::Item*, void*)85 inline void GeoMeshViewUI::cb_menuFileSaveAs_i(fltk::Item*, void*) 86 86 { 87 87 fltk::FileChooser *fcho; 88 88 GeoMeshSaver *mesh_saver; 89 char file_name[255]; 90 char message[255]; 91 char *ptr; 92 int answer_yes; 93 94 // Initialize answer to yes. 95 answer_yes = 1; 89 96 90 97 if (mGeoMesh != NULL) … … 99 106 if (fcho->value()) 100 107 { 101 mesh_saver = new GeoMeshSaver(); 102 mesh_saver->save(mGeoMesh,filename_name(fcho->value())); 103 delete mesh_saver; 108 // Gets file name. 109 strcpy(file_name,fcho->value()); 110 111 // Cut extension. 112 ptr = strtok(file_name,"."); 113 114 // If has extension. 115 if (ptr) 116 { 117 strcpy(file_name,ptr); 118 } 119 120 // Adds mesh extension. 121 strcat(file_name,".mesh"); 122 123 // If File Exists. 124 if (fileExists(file_name)) 125 { 126 // Compose message. 127 strcpy(message,"Do you want to replace "); 128 strcat(message,file_name); 129 strcat(message,"?"); 130 131 // Question. 132 answer_yes = fltk::ask(message); 133 } 134 135 // If answer yes to replace question. 136 // or if file not exists. 137 if (answer_yes) 138 { 139 mesh_saver = new GeoMeshSaver(); 140 141 142 mesh_saver->save(mGeoMesh,filename_name(file_name)); 143 144 delete mesh_saver; 145 } 104 146 } 105 106 147 // Repaint the window. 107 148 mMainWindow->redraw(); … … 111 152 } 112 153 113 void GeoMeshViewUI::cb_menu OpenSaveAs(fltk::Item* o, void* v)114 { 115 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 116 -> 117 cb_menu OpenSaveAs_i(o,v);154 void GeoMeshViewUI::cb_menuFileSaveAs(fltk::Item* o, void* v) 155 { 156 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 157 -> 158 cb_menuFileSaveAs_i(o,v); 118 159 } 119 160 … … 210 251 // Quit Callback 211 252 //--------------------------------------------------------------------------- 212 inline void GeoMeshViewUI::cb_menu OpenQuit_i(fltk::Item*, void*)253 inline void GeoMeshViewUI::cb_menuFileQuit_i(fltk::Item*, void*) 213 254 { 214 255 delete this; 215 256 } 216 257 217 void GeoMeshViewUI::cb_menu OpenQuit(fltk::Item* o, void* v)218 { 219 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 220 -> 221 cb_menu OpenQuit_i(o,v);258 void GeoMeshViewUI::cb_menuFileQuit(fltk::Item* o, void* v) 259 { 260 ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) 261 -> 262 cb_menuFileQuit_i(o,v); 222 263 } 223 264 … … 710 751 openMeshFile(); 711 752 712 // Show title.713 mProcessTitle->label("Visualize LodStrips");714 753 715 754 // If an object is loaded. … … 735 774 // Free memory. 736 775 delete fcho; 737 }738 776 739 777 // Hide the right panel. 740 778 hideRightPanel(); 741 779 780 // Show title. 781 mProcessTitle->label("Visualize LodStrips"); 782 742 783 // Show the Visulize LodStrips panel. 743 784 showLodStripSlider(); … … 745 786 // Repaint the window. 746 787 mMainWindow->redraw(); 747 } 748 788 789 } 790 } 749 791 750 792 inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) … … 752 794 fltk::FileChooser *fcho; 753 795 const char *lod_file; 754 796 755 797 // Sets menus application state to NONE. 756 798 mApplicationState = NONE; … … 762 804 // Loads a mesh file. 763 805 openMeshFile(); 764 765 // Show title.766 mProcessTitle->label("Visualize LodTrees");767 806 768 807 /*if (geoMeshView->getLeavesSubmesh()==-1) 769 {808 { 770 809 fltk::alert("No se ha seleccionado el submesh de hojas!"); 771 810 return; 772 }*/ 773 774 // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 775 int leafsSubMeshID = -1; 776 for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 777 if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 778 { 779 leafsSubMeshID=i; 780 break; 781 } 782 783 811 }*/ 784 812 785 813 // If an object is loaded. 786 814 if (mGeoMesh != NULL) 787 815 { 788 fcho = new fltk::FileChooser("", 789 "*.lod", 790 fltk::FileChooser::CREATE, 791 "Open Lod file"); 792 793 fcho->exec(); 794 795 // If a file was selected. 796 if (fcho->value()) 816 // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 817 int leafsSubMeshID = -1; 818 819 for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 797 820 { 798 // Build lod strips library. 799 800 std::string lodstripFile(fcho->value()); 801 delete fcho; 821 if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 822 { 823 leafsSubMeshID=i; 824 break; 825 } 826 } 827 828 // If an object is loaded. 829 if (mGeoMesh != NULL) 830 { 802 831 fcho = new fltk::FileChooser("", 803 "*.l eafseq",832 "*.lod", 804 833 fltk::FileChooser::CREATE, 805 "Open L eafSeqfile");834 "Open Lod file"); 806 835 807 836 fcho->exec(); 808 837 838 // If a file was selected. 809 839 if (fcho->value()) 810 840 { 811 std::string leafseqFile(fcho->value()); 812 813 setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 814 815 // Sets the aplication mode. 816 mApplicationState = VISUALIZE_LODTREES; 841 // Build lod strips library. 842 843 std::string lodstripFile(fcho->value()); 844 delete fcho; 845 fcho = new fltk::FileChooser("", 846 "*.leafseq", 847 fltk::FileChooser::CREATE, 848 "Open LeafSeq file"); 849 850 fcho->exec(); 851 852 if (fcho->value()) 853 { 854 std::string leafseqFile(fcho->value()); 855 856 setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 857 858 // Sets the aplication mode. 859 mApplicationState = VISUALIZE_LODTREES; 860 } 817 861 } 862 863 // Free memory. 864 delete fcho; 865 866 // Hide the right panel. 867 hideRightPanel(); 868 869 // Show title. 870 mProcessTitle->label("Visualize LodTrees"); 871 872 // Show the Visulize LodTree panel. 873 showLodStripSlider(); 874 showLodTreeSlider(); 875 876 // Repaint the window. 877 mMainWindow->redraw(); 818 878 } 819 820 // Free memory. 821 delete fcho; 822 } 823 824 // Hide the right panel. 825 hideRightPanel(); 826 827 // Show the Visulize LodTree panel. 828 showLodStripSlider(); 829 showLodTreeSlider(); 830 831 // Repaint the window. 832 mMainWindow->redraw(); 833 } 879 } 880 } 881 834 882 void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) 835 883 { … … 1009 1057 // Create the simplification sequence. 1010 1058 createSimplificationSequence(); 1059 1060 // Show build process. 1061 activeBuildProcess(); 1011 1062 } 1012 1063 … … 1054 1105 delete mMeshSimplifier; 1055 1106 geoMeshView->restoreContext(); 1107 1108 // Show build process. 1109 activeBuildProcess(); 1056 1110 } 1057 1111 } … … 1107 1161 inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) 1108 1162 { 1109 char *file_name=NULL;1163 char *file_name = NULL; 1110 1164 GeoMeshSaver *mesh_saver; 1111 1165 Serializer *oSerializer; 1112 1166 1113 1167 // Sets the progress bar to process bar. 1114 1168 progressBarType = BUILD; … … 1125 1179 // Build the LOD file. 1126 1180 case LODTREES_AUTO: 1127 1181 1128 1182 // Open file chooser dialog. 1129 1183 file_name = fltk::file_chooser("Build LOD","*",""); … … 1135 1189 std::cout << "OK!" << std::endl; 1136 1190 1137 /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence();1138 auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ));1139 1140 if (auxTreeSimpSequence && mGeoMesh)1141 {1142 LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence);1143 delete auxLodTreeConstructor;1144 }1145 else1146 {1147 fltk::alert("There is no leaf simplification sequence.");1148 break;1149 }1150 1151 1152 delete auxTreeSimpSequence;*/1153 1191 /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 1192 auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 1193 1194 if (auxTreeSimpSequence && mGeoMesh) 1195 { 1196 LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 1197 delete auxLodTreeConstructor; 1198 } 1199 else 1200 { 1201 fltk::alert("There is no leaf simplification sequence."); 1202 break; 1203 } 1204 1205 1206 delete auxTreeSimpSequence;*/ 1207 1154 1208 1155 1209 case LODSTRIPS_AUTO: … … 1309 1363 1310 1364 //--------------------------------------------------------------------------- 1365 // Active Build process. 1366 //--------------------------------------------------------------------------- 1367 void GeoMeshViewUI::activeBuildProcess() 1368 { 1369 //mButtonBuild->set_visible(); 1370 mButtonBuild->activate(); 1371 1372 //mBuildBar->set_visible(); 1373 mBuildBar->activate(); 1374 } 1375 1376 //--------------------------------------------------------------------------- 1311 1377 // Show the stripify panel 1312 1378 //--------------------------------------------------------------------------- … … 1572 1638 1573 1639 mButtonBuild->set_visible(); 1574 mButtonBuild->activate();1640 //mButtonBuild->activate(); 1575 1641 1576 1642 mBuildBar->set_visible(); 1577 mBuildBar->activate();1643 //mBuildBar->activate(); 1578 1644 } 1579 1645 //--------------------------------------------------------------------------- … … 1586 1652 1587 1653 mButtonBuild->set_visible(); 1588 mButtonBuild->activate();1654 //mButtonBuild->activate(); 1589 1655 1590 1656 mBuildBar->set_visible(); 1591 mBuildBar->activate();1657 //mBuildBar->activate(); 1592 1658 } 1593 1659 … … 2310 2376 void GeoMeshViewUI::openMeshFile() 2311 2377 { 2378 Mesh *mesh_loaded; 2312 2379 fltk::FileChooser *fcho; 2313 2380 static char char_value[10]; 2314 2381 static char title[256]; 2315 2382 2316 2383 fcho = new fltk::FileChooser("", 2317 2384 "*.mesh", … … 2326 2393 if (mFileName) 2327 2394 { 2328 // Set Window Title.2329 strcpy(title,mFileName);2330 mMainWindow->label(strcat(title," - GeoTool"));2331 2332 // Identify the mesh that stores the leaves2333 idMeshLeaves = -1;2334 2335 // Stores the name of the mesh.2336 nombremesh = new char[255];2337 strcpy(nombremesh,mFileName);2338 2339 // Delete the current mesh.2340 delete mGeoMesh;2341 delete mUndoMesh;2342 2343 2395 // Loads a new mesh. 2344 mGeoMesh = geoMeshLoader->load(mFileName); 2345 2346 // Reset the undo mesh. 2347 mUndoMesh = new Mesh(); 2348 *mUndoMesh = *mGeoMesh; 2349 2350 // Translate the MB count to a char value. 2351 sprintf(char_value, 2352 "MB %.3f", 2353 (float)geoMeshLoader->getFileSize()/1024/1024); 2354 2355 mMB->label(char_value); 2356 2357 // Visualize mesh. 2358 geoMeshView->setMesh(mGeoMesh); 2359 2360 // Hide right panel. 2361 hideRightPanel(); 2362 2363 // Quit culling. 2364 menuRenderCW->clear_value(); 2365 menuRenderCCW->clear_value(); 2366 geoMeshView->deactiveCW(); 2367 geoMeshView->deactiveCCW(); 2368 2369 // Deactive solid mode and wire. 2370 menuRenderSolid->clear_value(); 2371 menuRenderWire->clear_value(); 2372 geoMeshView->deactiveSolid(); 2373 geoMeshView->deactiveWire(); 2374 2375 // Fit model in midle. 2376 geoMeshView->fit(); 2377 2378 // Lighting smooth. 2379 menuRenderFlat->clear_value(); 2380 menuRenderSmooth->set_value(); 2381 geoMeshView->smooth(); 2382 2383 // Show title. 2384 mProcessTitle->label("Mesh Info"); 2385 2386 // Shows the mesh info. 2387 showMeshInfo(); 2388 2389 // if the mesh is stripified. 2390 geoMeshView->setStripColors(); 2391 2392 // Refresh geometry attributes. 2393 refreshApplicationBar(); 2394 } 2395 2396 mesh_loaded = geoMeshLoader->load(mFileName); 2397 2398 // If no error happens. 2399 if (mesh_loaded) 2400 { 2401 // Identify the mesh that stores the leaves 2402 idMeshLeaves = -1; 2403 2404 // Delete the current mesh. 2405 delete mGeoMesh; 2406 delete mUndoMesh; 2407 2408 // Assigns mesh loaded. 2409 mGeoMesh = mesh_loaded; 2410 2411 // Set Window Title. 2412 strcpy(title,mFileName); 2413 mMainWindow->label(strcat(title," - GeoTool")); 2414 2415 // Stores the name of the mesh. 2416 nombremesh = new char[255]; 2417 strcpy(nombremesh,mFileName); 2418 2419 // Reset the undo mesh. 2420 mUndoMesh = new Mesh(); 2421 *mUndoMesh = *mGeoMesh; 2422 2423 // Translate the MB count to a char value. 2424 sprintf(char_value, 2425 "MB %.3f", 2426 (float)geoMeshLoader->getFileSize()/1024/1024); 2427 2428 mMB->label(char_value); 2429 2430 // Visualize mesh. 2431 geoMeshView->setMesh(mGeoMesh); 2432 2433 // Hide right panel. 2434 hideRightPanel(); 2435 2436 // Quit culling. 2437 menuRenderCW->clear_value(); 2438 menuRenderCCW->clear_value(); 2439 geoMeshView->deactiveCW(); 2440 geoMeshView->deactiveCCW(); 2441 2442 // Deactive solid mode and wire. 2443 menuRenderSolid->clear_value(); 2444 menuRenderWire->clear_value(); 2445 geoMeshView->deactiveSolid(); 2446 geoMeshView->deactiveWire(); 2447 2448 // Fit model in midle. 2449 geoMeshView->fit(); 2450 2451 // Lighting smooth. 2452 menuRenderFlat->clear_value(); 2453 menuRenderSmooth->set_value(); 2454 geoMeshView->smooth(); 2455 2456 // Show title. 2457 mProcessTitle->label("Mesh Info"); 2458 2459 // Shows the mesh info. 2460 showMeshInfo(); 2461 2462 // if the mesh is stripified. 2463 geoMeshView->setStripColors(); 2464 2465 // Refresh geometry attributes. 2466 refreshApplicationBar(); 2467 2468 // Restore simplification state. 2469 simplificationState = NO_SIMPLIFICATION; 2470 } 2471 } 2396 2472 // Free memory. 2397 2473 delete fcho; 2474 } 2475 2476 //--------------------------------------------------------------------------- 2477 // If file exists. 2478 //--------------------------------------------------------------------------- 2479 bool GeoMeshViewUI::fileExists(const char *fileNameMesh) 2480 { 2481 FILE *pFile; 2482 2483 // Open the mesh file. 2484 pFile = fopen(fileNameMesh, "r"); 2485 2486 if (pFile) 2487 { 2488 return true; 2489 } 2490 else 2491 { 2492 return false; 2493 } 2398 2494 } 2399 2495 … … 2447 2543 { 2448 2544 fltk::Group* o; 2449 o = MainView = new fltk::Group(0, 0, 5 00, 530);2545 o = MainView = new fltk::Group(0, 0, 570, 530); 2450 2546 o->begin(); 2451 2547 2452 2548 { 2453 2549 fltk::InvisibleBox* o; 2454 o = cframe = new fltk::InvisibleBox(0, 0, 5 00, 530);2550 o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); 2455 2551 o->box(fltk::FLAT_BOX); 2456 2552 o->color((fltk::Color)0xffffff00); … … 2460 2556 { 2461 2557 GeoMeshView* o; 2462 o = geoMeshView = new GeoMeshView( 0,0,5 00,530,0,this);2558 o = geoMeshView = new GeoMeshView( 0,0,570,530,0,this); 2463 2559 } 2464 2560 … … 2471 2567 { 2472 2568 fltk::Group* o; 2473 o = MainView = new fltk::Group(5 00, 0, 300, 530);2569 o = MainView = new fltk::Group(570, 0, 230, 530); 2474 2570 o->begin(); 2475 2571 … … 2477 2573 fltk::Button* o; 2478 2574 //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); 2479 o = mButtonProcess = new fltk::Button( 65, 410, 73, 25, "Process");2575 o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); 2480 2576 o->callback((fltk::Callback*)cb_mButtonProcess); 2481 2577 o->hide(); … … 2486 2582 fltk::ProgressBar* o; 2487 2583 //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); 2488 o = mProcessBar = new fltk::ProgressBar(16, 435, 1 75, 18);2584 o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); 2489 2585 o->hide(); 2490 2586 o->deactivate(); … … 2493 2589 { 2494 2590 fltk::Button* o; 2495 o = mButtonSort = new fltk::Button( 65, 375, 73, 25, "Sort");2591 o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); 2496 2592 o->callback((fltk::Callback*)cb_mButtonSort); 2497 2593 o->hide(); … … 2501 2597 { 2502 2598 fltk::ProgressBar* o; 2503 o = mSortBar = new fltk::ProgressBar(16, 390, 1 75, 18);2599 o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); 2504 2600 o->hide(); 2505 2601 o->deactivate(); … … 2508 2604 { 2509 2605 fltk::Button* o; 2510 o = mButtonBuild = new fltk::Button( 65, 455, 73, 25, "Build");2606 o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); 2511 2607 o->callback((fltk::Callback*)cb_mButtonBuild); 2512 2608 o->hide(); … … 2516 2612 { 2517 2613 fltk::ProgressBar* o; 2518 o = mBuildBar = new fltk::ProgressBar(16, 480, 1 75, 18);2614 o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); 2519 2615 o->hide(); 2520 2616 o->deactivate(); … … 2564 2660 2565 2661 { 2566 mProcessTitle = new fltk::Widget(0, 0, 300, 25, "");2662 mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); 2567 2663 fltk::Widget* o = mProcessTitle; 2568 2664 o->set_vertical(); … … 2629 2725 2630 2726 { 2631 fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 300, 380);2727 fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); 2632 2728 o->set_vertical(); 2633 2729 o->callback((fltk::Callback*)cb_mMeshInfo); … … 2661 2757 2662 2758 { 2663 fltk::Item* o = menu OpenSaveAs = new fltk::Item("Save As");2664 o->callback((fltk::Callback*)cb_menu OpenSaveAs);2759 fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); 2760 o->callback((fltk::Callback*)cb_menuFileSaveAs); 2665 2761 } 2666 2762 … … 2676 2772 2677 2773 { 2678 fltk::Item* o = menu OpenQuit = new fltk::Item("Quit");2679 o->callback((fltk::Callback*)cb_menu OpenQuit);2774 fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); 2775 o->callback((fltk::Callback*)cb_menuFileQuit); 2680 2776 } 2681 2777
Note: See TracChangeset
for help on using the changeset viewer.