1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538
|
proc int FTM_SelCheck(string $nodes[]){ int $sel = 0; if (size($nodes)) $sel = 1; else confirmDialog -t "File Texture Manager" -m "必须至少选择一个文件纹理节点!" -b "OK"; return $sel; }
proc FTM_END(){ confirmDialog -t "File Texture Manager" -m "操作已完成。\n作业已完成。" -ma center -b "OK"; }
proc FTM_Log (string $type, string $node, string $log) { string $finLog; if (size($node)) $log = $node + "\n"; else $log = "\t" + $log + "\n"; switch ($type) { case "start": $finLog = "\n***************************************************************************************************************\n\ File Texture 管理器日志启动\n\ ***************************************************************************************************************\n"; break; case "end": $finLog = "***************************************************************************************************************\n\ File Texture 管理器日志结束\n\ ***************************************************************************************************************\n"; break; default: $finLog = $log; break; } print $finLog; }
proc string FTM_GetPath (string $FTM_FileOrPath, string $FTM_OldPath) { $FTM_OldPath = `substituteAll "\\\\" $FTM_OldPath "/"`; if ($FTM_FileOrPath == "file") $FTM_OldPath = `dirname $FTM_OldPath`; $FTM_OldPath = `substitute "/*$" $FTM_OldPath ""`; string $FTM_RightPath; if (size($FTM_OldPath)) $FTM_RightPath = `toNativePath ($FTM_OldPath + "/")`; return $FTM_RightPath; }
proc string[] FTM_GetFile (string $FTM_OldFullPath) { string $FTM_RightPath[]; string $FTM_PathElements[]; int $FTM_PathElementsSize; $FTM_OldFullPath = `substituteAll "\\\\" $FTM_OldFullPath "/"`; $FTM_RightPath[0] = `toNativePath $FTM_OldFullPath`; $FTM_PathElementsSize = `tokenize $FTM_OldFullPath "/" $FTM_PathElements`; $FTM_RightPath[1] = $FTM_PathElements[$FTM_PathElementsSize - 1]; return $FTM_RightPath; }
proc string[] FTM_FileTextureAnalyst () { global string $lsCmd; string $FTM_Files[] = eval($lsCmd);
string $FTM_Groups[]; int $FTM_GroupsSize; if (size($FTM_Files)){ $FTM_Groups[0] = "FTM_EmptySocket_FTM"; $FTM_Groups[1] = "FTM_MissingPathSocket_FTM"; }
for ($eachFile in $FTM_Files) { $FTM_GroupsSize = size($FTM_Groups); string $FTM_CurrentFullPath = substituteAll ("\\\\", `getAttr ($eachFile + ".fileTextureName")`, "/"); string $FTM_CurrentPath = dirname ($FTM_CurrentFullPath);
if (size($FTM_CurrentPath)) { for ($j=2; $j<$FTM_GroupsSize; $j++) { string $buffer[]; tokenize $FTM_Groups[$j] "*" $buffer; string $FTM_OldPath = $buffer[0]; string $cmp1 = $FTM_CurrentPath; string $cmp2 = $FTM_OldPath; if (`about -nt`) { $cmp1 = tolower($FTM_CurrentPath); $cmp2 = tolower($FTM_OldPath); }
if ($cmp1 == $cmp2) { string $tmp = $FTM_Groups[$j]; $tmp += "*" + $eachFile; $FTM_Groups[$j] = $tmp; break; } }
if ($j >= $FTM_GroupsSize) { $FTM_Groups[$FTM_GroupsSize] = $FTM_CurrentPath + "*" + $eachFile; continue; } } else if (size($FTM_CurrentFullPath)){ string $tmp = $FTM_Groups[1]; $tmp += "*" + $eachFile; $FTM_Groups[1] = $tmp; } else{ string $tmp = $FTM_Groups[0]; $tmp += "*" + $eachFile; $FTM_Groups[0] = $tmp; } }
select -cl; return $FTM_Groups; }
proc FTM_EditUIControl (string $FTM_OptionColumn, string $FTM_HelpForm) {
radioButtonGrp -e -on1 ("textFieldButtonGrp -e -en 0 -tx \"\" " + $FTM_OptionColumn + "|FTM_SourceDirectoryField") -on2 ("textFieldButtonGrp -e -en 1 -tx \"\" " + $FTM_OptionColumn + "|FTM_SourceDirectoryField") ($FTM_OptionColumn + "|FTM_OperationMode");
textFieldButtonGrp -e -bc ("FTM_BrowseCmd \"file\" \"" + $FTM_OptionColumn + "|FTM_SourceDirectoryField\" \"Set_S.D.\" 0") ($FTM_OptionColumn + "|FTM_SourceDirectoryField");
textFieldButtonGrp -e -bc ("FTM_BrowseCmd \"path\" \"" + $FTM_OptionColumn + "|FTM_TargetDirectoryField\" \"Set_T.D.\" 4") ($FTM_OptionColumn + "|FTM_TargetDirectoryField");
checkBoxGrp -e -on1 ("textFieldGrp -e -en 1 -text \"\" " + $FTM_OptionColumn + "|FTM_NewFolderNameField") -of1 ("textFieldGrp -e -en 0 -text \"MyTextureFiles\" " + $FTM_OptionColumn + "|FTM_NewFolderNameField") ($FTM_OptionColumn + "|FTM_MakeFolderChecker");
checkBox -e -onc ("textField -e -en 1 -text \"\" " + $FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_PrefixField") -ofc ("textField -e -en 0 -text \"prefix_\" " + $FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_PrefixField") ($FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_AddPrefixChecker");
checkBox -e -onc ("textField -e -en 1 -text \"\" " + $FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_SuffixField") -ofc ("textField -e -en 0 -text \"_suffix\" " + $FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_SuffixField") ($FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_AddSuffixChecker");
checkBoxGrp -e -on1 ("textFieldGrp -e -en 1 -text \"\" " + $FTM_OptionColumn + "|FTM_OldStringField; textFieldGrp -e -en 1 -text \"\" " + $FTM_OptionColumn + "|FTM_NewStringField") -of1 ("textFieldGrp -e -en 0 -text \"OldString\" " + $FTM_OptionColumn + "|FTM_OldStringField; textFieldGrp -e -en 0 -text \"NewString\" " + $FTM_OptionColumn + "|FTM_NewStringField") ($FTM_OptionColumn + "|FTM_ReplaceStringChecker");
string $FTM_HelpDescription = "\n 说 明:\n\n"; $FTM_HelpDescription += " 文件纹理管理器适用于Windows/Linux/MAC,以一种非常方便的方式管理文件纹理。\n\n"; $FTM_HelpDescription += " File Texture Manager 基本功能:\n\n"; $FTM_HelpDescription += " 1. 分析场景文件纹理\n"; $FTM_HelpDescription += " 2. 将原始纹理文件复制或移动到用户定义的路径\n"; $FTM_HelpDescription += " 3. 更新文件纹理的路径\n"; $FTM_HelpDescription += " 4. 也支持Mentalray纹理节点\n\n"; $FTM_HelpDescription += " FTM 额外功能:\n"; $FTM_HelpDescription += " 1. 替换文件纹理路径的根字符串。例如,重定向源代码\n"; $FTM_HelpDescription += " 2. 根据文件纹理的分辨率设置/取消设置内存效率。大于“阈值”(Threshold)(x或y)的纹理将设置为在设置模式下使用渲染器首选格式(Maya为BOT,mentalray为.map)。如果需要,将自动生成相应的内存高效文件。取消设置时,x和y中小于阈值的所有纹理都将设置为使用法线纹理,从该文件生成了内存高效纹理。BOT取消设置假设法线纹理存在于同一目录中。Mentalray.map unset将首先检查是否存在法线纹理。如果没有,FTM将尝试从.map文件中提取一个。指向序列的节点将被忽略。\n"; $FTM_HelpDescription += " 3. 将筛选类型设置为选定文件节点的指定类型。\n"; $FTM_HelpDescription += " 4. 将选定文件节点的纹理文件格式从“从”转换为“到”。如果“From”不是“*\”,则只处理纹理文件格式与“From \”匹配的文件节点。对于使用图像序列作为纹理文件的文件节点,需要指定转换范围,因此只打印出相应的命令,而不是真正执行任务。此函数使用Maya“imgcvt\”和mentalray\“imf_copy”多功能进行转换,因此请确保它们可以在系统可执行路径中找到。\n\n"; $FTM_HelpDescription += "【工作流程】:\n"; $FTM_HelpDescription += " 步骤 1. 分析场景文件纹理(可选择方式)\n"; $FTM_HelpDescription += " 步骤 2. 通过选中UI中的相关复选框,选择要管理的场景文件纹理(节点)\n 也可以通过自己的方法执行此操作,例如在Hypershade中选择它们。\n"; $FTM_HelpDescription += " 步骤 3. 根据需要设置选项。\n"; $FTM_HelpDescription += " 步骤 4. 通过按下相关按钮进行复制、移动或设置。\n\n"; $FTM_HelpDescription += "【小贴士】:\n"; $FTM_HelpDescription += " 1. 始终为每个纹理文件保留两个不同的版本。例如,“abc_LowRes.tga\”处于低分辨率,而“abc_HighRes.tga”处于高分辨率。使用低分辨率纹理来加速交互。只需记住在渲染之前使用FileTextureManager将每个文件纹理重置为指向相关的高分辨率纹理即可。(添加前缀、添加后缀,甚至替换字符串。)\n"; $FTM_HelpDescription += " 2. File Texture Manager 的UI不会像属性编辑器那样动态更新,因此最好重新-分析场景文件纹理 每次完成FTM工作时。如果您根本不使用分析功能,则无需执行此操作。\n\n"; $FTM_HelpDescription += "【注释】:\n"; $FTM_HelpDescription += " 1. 如果用户决定创建一个新文件夹,最终目标目录将等于目标目录加上新文件夹。\n"; $FTM_HelpDescription += " 2. 添加后缀功能对纹理文件名有限制。为了确保它按要求工作,文件名必须是常规格式,例如 filename.ext\”、“filename.[#…#].ext\“、\”filename.ext.[#…#]\n"; $FTM_HelpDescription += " 3. 添加prfix、添加后缀和替换字符串可以同时执行到每个文件纹理。替换字符串首先计算,然后添加后缀,最后添加前缀。\n"; $FTM_HelpDescription += " 4. 强烈建议不要在前缀、后缀、旧字符串和新字符串中包含“.\”。\n"; $FTM_HelpDescription += " 5. 有时过程会失败。原因可能多种多样。最可能的原因可能是以下两个原因之一或两者:a.在源目录中找不到纹理文件;b.被拒绝阅读、书写或删除。\n\n"; $FTM_HelpDescription += "【详情】:\n"; $FTM_HelpDescription += " 1. 分析场景文件纹理可以让你知道场景中有多少文件纹理,在哪里,它们是否存在,等等。它还允许用户只需单击一次就可以选择指向同一路径的所有纹理文件。\n"; $FTM_HelpDescription += " 2. 如何选择操作模式取决于不同的源目录状态。如果文件所在位置,请使用“自动”模式,否则请使用“手动”模式。\n"; $FTM_HelpDescription += " 3. 其他功能如UI中所示非常明确。\n";
scrollField -e -text $FTM_HelpDescription ($FTM_HelpForm + "|FTM_HelpField"); }
proc int FTM_FCWhatIs(string $string) { int $isWhat; global string $FTM_FCAllFormats[]; $string = tolower($string);
if (stringArrayCount($string,$FTM_FCAllFormats)) $isWhat = 0; else if (size(match("[0-9]*",$string)) == size($string)) $isWhat = 1; else if ($string == "bot") $isWhat = 3; else $isWhat = 2;
return $isWhat; }
proc string[] FTM_FCFileRegularName(string $file) { $file = substituteAll ("\\\\", $file, "/"); string $fileRegularName[] = stringToStringArray(basename($file,""),".");
string $fileName; string $seqNum; string $fileFormat;
switch (size($fileRegularName)) { case 0: break; case 1: $fileName = $fileRegularName[0]; break; case 2: if (FTM_FCWhatIs($fileRegularName[1]) == 0) { $fileName = $fileRegularName[0]; $fileFormat = $fileRegularName[1]; } else if (FTM_FCWhatIs($fileRegularName[1]) == 1) { $fileName = $fileRegularName[0]; $seqNum = $fileRegularName[1]; } else $fileName = basename($file,""); break; default: string $lastPiece = $fileRegularName[size($fileRegularName)-1]; if (FTM_FCWhatIs($lastPiece) == 0) { $fileFormat = $lastPiece; $fileName = basenameEx($file); $lastPiece = $fileRegularName[size($fileRegularName)-2]; if (FTM_FCWhatIs($lastPiece) == 1) { $seqNum = $lastPiece; $fileName = basenameEx($fileName); } } else if (FTM_FCWhatIs($lastPiece) == 1) { $seqNum = $lastPiece; $fileName = basenameEx($file); $lastPiece = $fileRegularName[size($fileRegularName)-2]; if (FTM_FCWhatIs($lastPiece) == 0) { $fileFormat = $lastPiece; $fileName = basenameEx($fileName); } } else if (FTM_FCWhatIs($lastPiece) == 3) { $fileFormat = $fileRegularName[size($fileRegularName)-2] + ".bot"; if (size($fileRegularName) == 3) $fileName = $fileRegularName[0]; else { $lastPiece = $fileRegularName[size($fileRegularName)-3]; if (FTM_FCWhatIs($lastPiece) == 1) { $seqNum = $lastPiece; $fileName = basenameEx(basenameEx(basenameEx($file))); } else $fileName = basenameEx(basenameEx($file)); } } else $fileName = basename($file,""); break; }
$fileRegularName[0] = $fileName; $fileRegularName[1] = $seqNum; $fileRegularName[2] = $fileFormat;
return $fileRegularName; }
proc string FTM_FCSubstituteLastPattern(string $inputString, string $targetPattern, string $newPattern) { $inputString = substituteAll("\\\\", $inputString, "/");
string $exp1 = "^.*" + $targetPattern + "+"; string $noTail = match($exp1,$inputString);
string $exp2 = $targetPattern + "+$"; string $newNoEnd = substitute($exp2,$noTail,$newPattern);
string $badChar[] = {"+",".","^","$","[","]","(",")"}; for ($char in $badChar) $noTail = `substituteAllString $noTail $char ("\\"+$char)`; string $exp3 = "^" + $noTail + "+"; string $outputString = substitute($exp3,$inputString,$newNoEnd);
$outputString = toNativePath($outputString); return $outputString; }
proc int FTM_FCDigitsNumber(string $fileName) { string $fileRegularName[] = FTM_FCFileRegularName($fileName); $fileName = FTM_FCSubstituteLastPattern($fileName,$fileRegularName[1],"*"); string $filesInSeq[] = `getFileList -fs $fileName`;
int $digiNum = 0; for ($i=0;$i<size($filesInSeq);$i++) { string $tmp[] = FTM_FCFileRegularName($filesInSeq[$i]); if ($digiNum <= size($tmp[1])) $digiNum = size($tmp[1]); }
return $digiNum; }
proc FTM_FCGo(int $progressUI, string $sourceFormatUI, string $targetFormat, int $handleSeq, int $updatePath, int $removeOrig)
{ if (FTM_SelCheck(`ls -sl -typ file `)) { waitCursor -state on; FTM_Log "start" "" "";
string $fileNodesList[] = FTM_FCGetMatches($sourceFormatUI);
int $isSeq[]; int $isOneOfSeq[];
string $file; string $fileFC; string $fileUpdatePath; string $fileRemove;
if ($progressUI) {
int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size($fileNodesList)`; }
for ($i=0;$i<size($fileNodesList);$i++){ FTM_Log "" ($fileNodesList[$i]+":") "";
if ($progressUI){
if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $progress = $i+1; $percentage = $progress * (100/size($fileNodesList)); progressWindow -e -pr $progress -st ("Handling " + $fileNodesList[$i] + " ...... " + $percentage + "%"); }
$file = toNativePath(substituteAll("\\\\",`getAttr ($fileNodesList[$i] + ".fileTextureName")`,"/")); $fileFC = $file; $fileRemove = $file; string $fileRegularName[] = FTM_FCFileRegularName($file); string $isBOT = `match "bot" $fileRegularName[2]`; if (size($isBOT)) { FTM_Log "" "Texture file is a BOT file. Skipped!" ""; continue; } string $targetFile = FTM_FCSubstituteLastPattern($file,$fileRegularName[2],$targetFormat);
if (!size($fileRegularName[2])) $targetFile += "." + $targetFormat; $fileUpdatePath = $targetFile; string $cmp1,$cmp2; $cmp1 = $fileUpdatePath; $cmp2 = $fileRemove; if (`about -nt`) { $cmp1 = toNativePath(tolower($cmp1)); $cmp2 = toNativePath(tolower($cmp2)); }
if($cmp1 == $cmp2) FTM_Log "" "" "This file node was already handled before. Process skipped.";
else{ $isSeq[$i] = 0; $isOneOfSeq[$i] = 0; if (`nodeType $fileNodesList[$i]` == "file" && size($fileRegularName[1])) { if (`getAttr ($fileNodesList[$i] + ".useFrameExtension")`) $isSeq[$i] = 1; else $isOneOfSeq[$i] = 1; }
int $isMR_c = 0; int $isMR_x = 0; if ($fileRegularName[2] == "map" && $targetFormat != "map") $isMR_x = 1; else if ($fileRegularName[2] != "map" && $targetFormat == "map") $isMR_c = 1; string $cmdFC = "system(\""; if ($isMR_c) $cmdFC += "imf_copy -p -r"; else if ($isMR_x) $cmdFC += "imf_copy"; else $cmdFC += "imgcvt -t " + $targetFormat; string $cmdUpdatePath = "setAttr -typ \"string\" " + $fileNodesList[$i] + ".fileTextureName "; string $cmdRemoveOrig = "sysFile -del \"";
if (!$handleSeq && $isSeq[$i]) FTM_Log "" "" "Sequence was not selected to be handled. Skipped."; else { if ($handleSeq && $isSeq[$i]){ string $padding = ""; for ($j=0;$j<FTM_FCDigitsNumber($file);$j++) $padding += "@"; $targetFile = FTM_FCSubstituteLastPattern($targetFile,$fileRegularName[1],$padding); $fileFC = FTM_FCSubstituteLastPattern($file,$fileRegularName[1],$padding); $fileRemove = FTM_FCSubstituteLastPattern($file,$fileRegularName[1],"*");
if (!$isMR_c && !$isMR_x) $cmdFC += " -n startIn endIn stepIn -N startOut endOut stepOut"; } $cmdFC += " \\\"" + encodeString($fileFC) + "\\\" \\\"" + encodeString($targetFile) + "\\\""; if ($isMR_c || $isMR_x) $cmdFC += " " + $targetFormat + "\")"; else $cmdFC += "\")";
if (`file -q -ex $fileUpdatePath`) FTM_Log "" "" "Convertion skipped. New format texture exists, maybe convertion has been done before."; else{ if (!$isSeq[$i]){ string $cmdFCFeedback = eval($cmdFC); if (size($cmdFCFeedback)) FTM_Log "" "" $cmdFCFeedback; if (`file -q -ex $fileUpdatePath`) FTM_Log "" "" ("Convertion succeeded. Converted from \"" + $fileFC + "\" to \"" + $targetFile + "\"."); else FTM_Log "" "" "Convertion failed. Could be file permission problem, disk capacity problem or source texture is of unknown/unsupported format."; } else { if (!$isMR_c && !$isMR_x) FTM_Log "" "" ("Sequence specified. Command to execute (format conversion):" + $cmdFC); else FTM_Log "" "" "Sequence specified. Use \"imf_copy\" to convert your tetures. A simple loop might be needed."; } }
if ($updatePath) { $cmdUpdatePath += "\"" + encodeString(toNativePath($fileUpdatePath)) + "\";"; $cmdRemoveOrig += encodeString($fileRemove) + "\";";
if (!$isSeq[$i]){ if (`file -q -ex $fileUpdatePath`){ if(catchQuiet(eval($cmdUpdatePath))) { FTM_Log "" "" "WARNING: Attribute \"fileTextureName\" is locked/connected and can NOT be modified!"; FTM_Log "" "" "WARNING: Path updating failed. So Original Texture Removing will not be done even if it was selected to."; } else { FTM_Log "" "" ("Path updating succeeded. Set to \"" + (toNativePath($fileUpdatePath)) + "\"."); if ($removeOrig){ if ($isOneOfSeq[$i]) FTM_Log "" "" "Only one file of a whole sequence is used as texture, no file in the sequence is supposed to be removed."; else if (!$isSeq[$i]){ if (!eval($cmdRemoveOrig)) FTM_Log "" "" "Original texture removing failed, could be file permission problem."; else FTM_Log "" "" ("Original texture removing succeeded. Removed \"" + $fileRemove + "\"."); } } } } else FTM_Log "" "" "Convertion failed, Path Updating and Original Texture Removing will not be done even if they were selected to."; } else { FTM_Log "" "" ("Sequence specified. Command to execute (update path info):" + $cmdUpdatePath); if ($removeOrig) FTM_Log "" "" ("Sequence specified. Command to execute (remove original textures):" + $cmdRemoveOrig); } } } } }
if (!size($fileNodesList)) FTM_Log "" "No texture is of specified format." ""; if ($progressUI){ progressWindow -ep; FTM_Log "end" "" ""; FTM_END; } waitCursor -state off; } }
global proc string[] FTM_FCGetMatches (string $formatUI) { string $fileNodesList[]; string $tmpNodesList[] = `ls -sl -typ file `; if (`FTM_SelCheck $tmpNodesList`) { string $tmpNode; string $tmpFile;
string $format = `optionMenu -q -v $formatUI`; if ($format!="*") { for ($tmpNode in $tmpNodesList) { $tmpFile = `getAttr ($tmpNode + ".fileTextureName")`; string $tmpFileRegularName[] = FTM_FCFileRegularName($tmpFile); if (tolower($tmpFileRegularName[2]) == tolower($format)) $fileNodesList[size($fileNodesList)] = $tmpNode; } } else $fileNodesList = $tmpNodesList; } return $fileNodesList; }
global proc FTM_FCGatherInfo(string $FTM_ExtraFunctionColumn) { string $sourceFormatUI = $FTM_ExtraFunctionColumn + "|FTM_FCRow|FTM_FCSourceMenu"; string $targetFormat = `optionMenu -q -v ($FTM_ExtraFunctionColumn + "|FTM_FCRow|FTM_FCTargetMenu")`; int $handleSeq = `checkBox -q -v ($FTM_ExtraFunctionColumn + "|FTM_SeqCheck")`; int $updatePath = `checkBox -q -v ($FTM_ExtraFunctionColumn + "|FTM_UpdateCheck")`; int $removeOrig = `checkBox -q -v ($FTM_ExtraFunctionColumn + "|FTM_RemoveCheck")`;
FTM_FCGo 1 $sourceFormatUI $targetFormat $handleSeq $updatePath $removeOrig; }
global proc FTM_FilterSetup(string $FTM_ExtraFunctionColumn) { string $Nodes[] = `ls -sl -typ file`; if (`FTM_SelCheck $Nodes`) { waitCursor -state on; FTM_Log "start" "" ""; int $filterType = `optionMenu -q -sl ($FTM_ExtraFunctionColumn+"|FTM_FilterTypeRow|FTM_FilterTypeMenu")` -1; string $filter = `optionMenu -q -v ($FTM_ExtraFunctionColumn+"|FTM_FilterTypeRow|FTM_FilterTypeMenu")`;
int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size $Nodes`;
for ($i=0;$i<size($Nodes);$i++) { FTM_Log "" ($Nodes[$i]+":") ""; if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $progress = $i; $percentage = $progress * 100 / size($Nodes); progressWindow -e -pr $progress -st ("Setting filter type, please wait...... " + $percentage + "%");
string $cmd = "setAttr " + $Nodes[$i] + ".filterType " + $filterType; if (catchQuiet(eval($cmd))) FTM_Log "" "" "Attribute \"filterType\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" ("Set filter type to \"" + $filter + "\""); } progressWindow -ep; FTM_Log "end" "" ""; FTM_END; waitCursor -state off; } }
global proc FTM_BOTSetup(int $FTM_BOTMode, string $FTM_ExtraFunctionColumn) { string $FTM_FileNodes[]=`ls -sl -typ file`; if (`FTM_SelCheck $FTM_FileNodes`) { waitCursor -state on; FTM_Log "start" "" ""; int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size $FTM_FileNodes`;
for ($i=0; $i<size($FTM_FileNodes); $i++){ FTM_Log "" ($FTM_FileNodes[$i]+":") ""; if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $progress = $i; $percentage = $progress * 100 / size($FTM_FileNodes); progressWindow -e -pr $progress -st ("Setting BOT options, please wait...... " + $percentage + "%"); if (`getAttr ($FTM_FileNodes[$i] + ".useFrameExtension")`) { FTM_Log "" "" "Sequence specified, Skipped!"; continue; }
int $resolution = `intFieldGrp -q -v1 ($FTM_ExtraFunctionColumn + "|FTM_BOTRow|FTM_BOTResFieldGrp")`; float $xRes = `getAttr ($FTM_FileNodes[$i] + ".outSizeX")`; float $yRes = `getAttr ($FTM_FileNodes[$i] + ".outSizeY")`;
if ($FTM_BOTMode) { if ($xRes >= $resolution || $yRes >= $resolution) { string $FTM_File = `getAttr ($FTM_FileNodes[$i] + ".fileTextureName")`; $FTM_File = `substituteAll "\\\\" $FTM_File "/"`; string $FTM_TheBOT = `substitute "(\\.bot)*$" $FTM_File ""` + ".bot"; string $BOTCmd = "makebot -c -r " + $resolution + " -i \"" + $FTM_File + "\" -o \"" + $FTM_TheBOT + "\""; if (catchQuiet(eval($BOTCmd))) FTM_Log "" "" "BOT file generation failed. Could be permission issue or the BOT file already exists."; string $cacheCmd = "setAttr " + $FTM_FileNodes[$i] + ".useCache 1"; string $pathCmd = "setAttr -typ \"string\" " + $FTM_FileNodes[$i] + ".fileTextureName \"" + $FTM_TheBOT + "\""; if (catchQuiet(eval($cacheCmd))) FTM_Log "" "" "WARNING: Attribute \"useCache\" is locked/connected and can NOT be modified!"; else if (catchQuiet(eval($pathCmd))) FTM_Log "" "" "WARNING: Attribute \"fileTextureName\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" "BOT setup OK."; } else FTM_Log "" "" ("Resolution \"" + $xRes + "x" + $yRes + "\" is LOWER than specified threshold, skipped!"); } else { if ($xRes <= $resolution && $yRes <= $resolution) { string $cacheCmd = "setAttr " + $FTM_FileNodes[$i] + ".useCache 0"; string $FTM_File = `getAttr ($FTM_FileNodes[$i] + ".fileTextureName")`; $FTM_File = `substituteAll "\\\\" $FTM_File "/"`; $FTM_File = `substitute "(\\.bot)*$" $FTM_File ""`; string $pathCmd = "setAttr -typ \"string\" " + $FTM_FileNodes[$i] + ".fileTextureName \"" + $FTM_File + "\""; if (catchQuiet(eval($cacheCmd))) FTM_Log "" "" "WARNING: Attribute \"useCache\" is locked/connected and can NOT be modified!"; else if (catchQuiet(eval($pathCmd))) FTM_Log "" "" "WARNING: Attribute \"fileTexturename\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" "BOT cancelled successfully."; } else FTM_Log "" "" ("Resolution \"" + $xRes + "x" + $yRes + "\" is HIGHER than specified threshold, skipped!"); } } progressWindow -ep; FTM_Log "end" "" ""; FTM_END; waitCursor -state off; } }
global proc FTM_MAPSetup(int $FTM_MAPMode, string $FTM_ExtraFunctionColumn) { string $FTM_FileNodes[]=`ls -sl -typ file`; if (`FTM_SelCheck $FTM_FileNodes`) { waitCursor -state on; FTM_Log "start" "" ""; int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size $FTM_FileNodes`;
for ($i=0; $i<size($FTM_FileNodes); $i++){ FTM_Log "" ($FTM_FileNodes[$i]+":") ""; if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $progress = $i; $percentage = $progress * 100 / size($FTM_FileNodes); progressWindow -e -pr $progress -st ("Setting up mentalray memory-mapped textures, please wait...... " + $percentage + "%");
if (`getAttr ($FTM_FileNodes[$i] + ".useFrameExtension")`) { FTM_Log "" "" "Sequence specified, Skipped!"; continue; }
int $resolution = `intFieldGrp -q -v1 ($FTM_ExtraFunctionColumn + "|FTM_MAPRow|FTM_MAPResFieldGrp")`; float $xRes = `getAttr ($FTM_FileNodes[$i] + ".outSizeX")`; float $yRes = `getAttr ($FTM_FileNodes[$i] + ".outSizeY")`;
if ($FTM_MAPMode) { if ($xRes >= $resolution || $yRes >= $resolution) { string $FTM_File = `getAttr ($FTM_FileNodes[$i] + ".fileTextureName")`; $FTM_File = `substituteAll "\\\\" $FTM_File "/"`; string $FTM_TheMAP = `substitute "(\\.map)*$" $FTM_File ""` + ".map"; string $MAPCmd = "system(\"imf_copy -p -r \\\"" + (encodeString(`toNativePath $FTM_File`)) + "\\\" \\\"" + (encodeString(`toNativePath $FTM_TheMAP`)) + "\\\" map\")"; if (`file -q -ex $FTM_TheMAP`){ FTM_Log "" "" ("Mentalray memory-mapped texture file \"" + `toNativePath $FTM_TheMAP` + "\" already exists. FTM will directly use it."); } else { if (catchQuiet(eval($MAPCmd))) FTM_Log "" "" "Mentalray memory-mapped texture file generation failed. Could be permission issue or 'imf_copy' can not be found in system executable path."; } string $pathCmd = "setAttr -typ \"string\" " + $FTM_FileNodes[$i] + ".fileTextureName \"" + $FTM_TheMAP + "\""; if (catchQuiet(eval($pathCmd))) FTM_Log "" "" "WARNING: Attribute \"fileTextureName\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" "Mentalray memory-mapped texture setup accomplished."; } else FTM_Log "" "" ("Resolution \"" + $xRes + "x" + $yRes + "\" is LOWER than specified threshold, skipped!"); } else { if ($xRes <= $resolution && $yRes <= $resolution) { string $FTM_File = `getAttr ($FTM_FileNodes[$i] + ".fileTextureName")`; $FTM_File = `substituteAll "\\\\" $FTM_File "/"`; string $FTM_TheMAP = $FTM_File; $FTM_File = `substitute "(\\.map)*$" $FTM_File ""`; int $wrong = 0; if (!`file -q -ex $FTM_File`){ FTM_Log "" "" ("Normal texture file \"" + `toNativePath $FTM_File` + "\" doesn't exist."); FTM_Log "" "" ("FTM is trying to extract one (in Maya iff format) from \"" + `toNativePath $FTM_TheMAP` + "\""); string $UnMAPCmd = "system(\"imf_copy \\\"" + (encodeString(`toNativePath $FTM_TheMAP`)) + "\\\" \\\"" + (encodeString(`toNativePath $FTM_File`)) + "\\\" iff\")"; if (catchQuiet(eval($UnMAPCmd))) { $wrong = 1; FTM_Log "" "" ("WARNING: Extracting normal texture file from \"" + `toNativePath $FTM_TheMAP` + "\" failed."); FTM_Log "" "" " Could be permission issue, or 'imf_copy' can not be found in system executable path, or original .map file is not a mentalray memory-mapped texture file."; } else FTM_Log "" "" ("Extraction succeed. => \"" + `toNativePath $FTM_File` + "\""); } if (!$wrong) { string $pathCmd = "setAttr -typ \"string\" " + $FTM_FileNodes[$i] + ".fileTextureName \"" + $FTM_File + "\""; if (catchQuiet(eval($pathCmd))) FTM_Log "" "" "WARNING: Attribute \"fileTexturename\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" "Mentalray memory-mapped texture file unset accomplished."; } } else FTM_Log "" "" ("Resolution \"" + $xRes + "x" + $yRes + "\" is HIGHER than specified threshold, skipped!"); } } progressWindow -ep; FTM_Log "end" "" ""; FTM_END; waitCursor -state off; } }
global proc FTM_Substitute(string $oldRootField, string $newRootField) { string $oldRoot = `textFieldButtonGrp -q -text $oldRootField`; $oldRoot = substituteAll("\\\\",$oldRoot,"/"); string $newRoot = `textFieldButtonGrp -q -text $newRootField`; $newRoot = substituteAll("\\\\",$newRoot,"/"); if (size($oldRoot)==0 || size($newRoot)==0) confirmDialog -t "File Texture Manager" -m "Both the Old Root filed and the New Root field must be filled!" -b "OK"; else { string $fileNodes[] = `ls -sl -typ file -typ psdFileTex`; if (`FTM_SelCheck $fileNodes`){ waitCursor -state 1; FTM_Log "start" "" ""; string $badChar[] = {"+",".","^","$","[","]","(",")"}; for ($char in $badChar) $oldRoot = `substituteAllString $oldRoot $char ("\\"+$char)`;
string $node;
int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size $fileNodes`;
for ($i=0;$i<size($fileNodes);$i++) { FTM_Log "" ($fileNodes[$i]+":") ""; if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $progress = $i; $percentage = $progress * 100 / size($fileNodes); progressWindow -e -pr $progress -st ("Redirecting, please wait...... " + $percentage + "%");
string $old = `getAttr ($fileNodes[$i]+".fileTextureName")`; $old = `substituteAll "\\\\" $old "/"`; string $new = `substitute $oldRoot $old $newRoot`; string $cmd = "setAttr -typ \"string\" " + $fileNodes[$i] + ".fileTextureName \"" + $new + "\""; if (catchQuiet(eval($cmd))) FTM_Log "" "" "WARNING: Attribute \"fileTextureName\" is locked/connected and can NOT be modified!"; else FTM_Log "" "" ("Set to \"" + (toNativePath($new)) + "\""); if (!`file -q -ex $new`) FTM_Log "" "" ("WARNING: \"" + (toNativePath($new)) + "\" doesn't exist!"); } progressWindow -ep; FTM_Log "end" "" ""; FTM_END; waitCursor -state 0; } } }
global proc string getDirectoryFromTexCheck(string $checkLabel) { textFieldButtonGrp -e -text ($checkLabel+"/") FTM_TargetDirectoryField; return $checkLabel; } global proc FTM_AnalyseFileTextures (string $FTM_ParentUI) { waitCursor -state on;
string $FTM_Groups[] = `FTM_FileTextureAnalyst`;
if (`columnLayout -q -ex ($FTM_ParentUI + "|FTM_AnalysisCheckerColumn")`) deleteUI ($FTM_ParentUI + "|FTM_AnalysisCheckerColumn");
if (size($FTM_Groups) == 0) text -e -l "找不到贴图文件" ($FTM_ParentUI + "|FTM_EmptyAnalysisText"); else { text -e -l "分析:" ($FTM_ParentUI + "|FTM_EmptyAnalysisText");
setParent $FTM_ParentUI; columnLayout FTM_AnalysisCheckerColumn; int $FTM_Groups_Size = size($FTM_Groups); if ($FTM_Groups[0] == "FTM_EmptySocket_FTM") $FTM_Groups_Size -= 1; if ($FTM_Groups[1] == "FTM_MissingPathSocket_FTM") $FTM_Groups_Size -= 1; global string $lsCmd; string $FTM_TotalResults = "总计 " + size(eval($lsCmd)) + " 文件纹理指向 " + $FTM_Groups_Size + "个路径 : "; text -l $FTM_TotalResults; text -l "" -h 10;
FTM_Log "start" "" ""; for ($FTM_Group in $FTM_Groups) { string $buffer[]; tokenize $FTM_Group "*" $buffer; int $FTM_FilesStoredSize = size ($buffer)-1; string $FTM_CurrentPath = $buffer[0]; string $FTM_FileTexturesAnalysis; if ($FTM_CurrentPath=="FTM_EmptySocket_FTM" && $FTM_FilesStoredSize>0) $FTM_FileTexturesAnalysis = $FTM_FilesStoredSize + " 未指定纹理。所以它们不存在。"; else if ($FTM_CurrentPath=="FTM_MissingPathSocket_FTM" && $FTM_FilesStoredSize>0) $FTM_FileTexturesAnalysis = $FTM_FilesStoredSize + " 没有贴图路径信息 纹理不存在 "; else { if ($FTM_FilesStoredSize>0){ $FTM_CurrentPath = `FTM_GetPath "路径" $FTM_CurrentPath`; $FTM_FileTexturesAnalysis = $FTM_FilesStoredSize + " 个贴图路径指向: \"" + (toNativePath($FTM_CurrentPath)) + "\""; } }
string $FTM_CurrentFile[]; string $FTM_CurrentFiles = ""; string $FTM_Exist[] = {}; int $FTM_ExistSize = 0; string $FTM_NotExist[] = {}; int $FTM_NotExistSize = 0;
for ($i=1; $i<size($buffer); $i++) {
$FTM_CurrentFile[$i] = $buffer[$i]; $FTM_CurrentFiles = $FTM_CurrentFiles + $FTM_CurrentFile[$i] + " ";
string $FTM_CurrentFilePath = `getAttr ($FTM_CurrentFile[$i] + ".fileTextureName")`; if ( `file -q -ex $FTM_CurrentFilePath`) { $FTM_Exist[$FTM_ExistSize] = $FTM_CurrentFile[$i]; $FTM_ExistSize = $FTM_ExistSize + 1;
} else { $FTM_NotExist[$FTM_NotExistSize] = $FTM_CurrentFile[$i]; $FTM_NotExistSize = $FTM_NotExistSize + 1; } }
if (size($FTM_FileTexturesAnalysis)) { string $FTM_MainChecker = `checkBox -l $FTM_FileTexturesAnalysis -al left`; popupMenu -p $FTM_MainChecker; string $cmd = "getDirectoryFromTexCheck(\""+$buffer[0]+"\")"; menuItem -label "复制" -c $cmd; FTM_Log "" "" $FTM_FileTexturesAnalysis;
string $FTM_ExistSubChecker; string $FTM_NotExistSubChecker; if ($FTM_CurrentPath!="FTM_EmptySocket_FTM" && $FTM_CurrentPath!="FTM_MissingPathSocket_FTM") { columnLayout -adj 1 -cat left 30;
string $FTM_ExistFiles = ""; for ($i=0; $i<$FTM_ExistSize; $i++) $FTM_ExistFiles = $FTM_ExistFiles + $FTM_Exist[$i] + " "; $FTM_ExistSubChecker = `checkBox -l ($FTM_ExistSize + "个贴图已连接") -al left -onc ("select -add " + $FTM_ExistFiles) -ofc ("if (" + $FTM_ExistSize + " > 0) select -deselect " + $FTM_ExistFiles)`;
string $FTM_NotExistFiles = ""; for ($i=0; $i<$FTM_NotExistSize; $i++) $FTM_NotExistFiles = $FTM_NotExistFiles + $FTM_NotExist[$i] + " "; $FTM_NotExistSubChecker = `checkBox -l ($FTM_NotExistSize + "个贴图未连接") -al left -onc ("select -add " + $FTM_NotExistFiles) -ofc ("if (" + $FTM_NotExistSize + " > 0) select -deselect " + $FTM_NotExistFiles)`; setParent ($FTM_ParentUI + "|FTM_AnalysisCheckerColumn");
checkBox -e -onc ("select -add " + $FTM_CurrentFiles + ";checkBox -e -v 1 -vis 0 " + $FTM_ExistSubChecker + ";checkBox -e -v 1 -vis 0 " + $FTM_NotExistSubChecker) -ofc ("if (" + $FTM_FilesStoredSize + " > 0) select -deselect " + $FTM_CurrentFiles + ";checkBox -e -v 0 -vis 1 " + $FTM_ExistSubChecker + ";checkBox -e -v 0 -vis 1 " + $FTM_NotExistSubChecker) $FTM_MainChecker; }
else checkBox -e -onc ("select -add " + $FTM_CurrentFiles) -ofc ("if (" + $FTM_FilesStoredSize + " > 0) select -deselect " + $FTM_CurrentFiles) $FTM_MainChecker; } } FTM_Log "end" "" ""; }
waitCursor -state off; }
global proc FTM_BrowseCmd (string $FTM_FileOrPath, string $FTM_TextField, string $FTM_WhichButton, int $FTM_BrowseType) { global string $FTM_WorkSpace; if (size($FTM_WorkSpace) == 0) { $FTM_WorkSpace = `workspace -q -rd` + `workspace -q -fileRuleEntry "sourceImages"`; $FTM_WorkSpace = `FTM_GetPath "path" $FTM_WorkSpace`; } workspace -dir $FTM_WorkSpace;
global int $FTM_NEW_MAYA; if ($FTM_NEW_MAYA) { if ($FTM_BrowseType == 0) $FTM_BrowseType = 1; else if ($FTM_BrowseType == 4) $FTM_BrowseType = 3; string $return[] = `fileDialog2 -ds 2 -cap $FTM_WhichButton -dir $FTM_WorkSpace -fm $FTM_BrowseType -okc $FTM_WhichButton -cc "Cancel"`; string $path = $return[0]; if (!size($path)) $path = `textFieldButtonGrp -q -text $FTM_TextField`; if ($FTM_FileOrPath == "file") $path += "bugQuickFix"; FTM_ChangeTextField $FTM_FileOrPath $FTM_TextField $path ""; } else { string $FTM_Temp = ""; $FTM_Temp += "FTM_ChangeTextField "; $FTM_Temp += ("\"" + $FTM_FileOrPath + "\" "); $FTM_Temp += ("\"" + $FTM_TextField + "\" "); fileBrowser $FTM_Temp $FTM_WhichButton "" $FTM_BrowseType; } }
global proc FTM_ChangeTextField (string $FTM_FileOrPath, string $FTM_TextField, string $FTM_File, string $FTM_FileType) { string $FTM_Path = `FTM_GetPath $FTM_FileOrPath $FTM_File`; textFieldButtonGrp -e -text (toNativePath($FTM_Path)) $FTM_TextField; string $os = `about -os`; if (gmatch($os, "*irix*") || gmatch($os, "*linux*")) window -e -vis false projectViewerWindow;
global string $FTM_WorkSpace; $FTM_WorkSpace = $FTM_Path; }
global proc FTM_ResetUI (string $FTM_OptionColumn,string $FTM_AnalysisColumn,string $FTM_ExtraFunctionColumn,string $FTM_Tabs,string $FTM_CopyButton,string $FTM_MoveButton,string $FTM_SetButton) { waitCursor -state on;
global int $FTM_WIDTH, $FTM_HEIGHT; window -e -wh $FTM_WIDTH $FTM_HEIGHT FTM_MainWindow;
text -e -l "未分析场景文件" ($FTM_AnalysisColumn + "|FTM_EmptyAnalysisText");
if (`columnLayout -q -ex ($FTM_AnalysisColumn + "|FTM_AnalysisCheckerColumn")`) deleteUI ($FTM_AnalysisColumn + "|FTM_AnalysisCheckerColumn"); radioButtonGrp -e -select 1 ($FTM_OptionColumn + "|FTM_OperationMode"); textFieldButtonGrp -e -text "" -en 0 ($FTM_OptionColumn + "|FTM_SourceDirectoryField"); string $FTM_CurrentProject = `workspace -q -rd`; string $FTM_CurrentSourceImagesDir = $FTM_CurrentProject + `workspace -q -fileRuleEntry "sourceImages"`; string $FTM_SourceImages = `FTM_GetPath "path" $FTM_CurrentSourceImagesDir`; textFieldButtonGrp -e -text $FTM_SourceImages ($FTM_OptionColumn + "|FTM_TargetDirectoryField"); checkBoxGrp -e -v1 0 ($FTM_OptionColumn + "|FTM_MakeFolderChecker"); textFieldGrp -e -text "MyTextureFiles" -en 0 ($FTM_OptionColumn + "|FTM_NewFolderNameField"); checkBox -e -v 0 ($FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_AddPrefixChecker"); textField -e -text "prefix_" -en 0 ($FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_PrefixField"); checkBox -e -v 0 ($FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_AddSuffixChecker"); textField -e -text "_suffix" -en 0 ($FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_SuffixField"); checkBoxGrp -e -v1 0 ($FTM_OptionColumn + "|FTM_ReplaceStringChecker"); textFieldGrp -e -text "OldString" -en 0 ($FTM_OptionColumn + "|FTM_OldStringField"); textFieldGrp -e -text "NewString" -en 0 ($FTM_OptionColumn + "|FTM_NewStringField");
textFieldButtonGrp -e -text "" ($FTM_ExtraFunctionColumn + "|oldRootField"); string $tmp = `workspace -q -rd` + `workspace -q -fileRuleEntry "sourceImages"`; $tmp = `FTM_GetPath "path" $tmp`; textFieldButtonGrp -e -text $tmp ($FTM_ExtraFunctionColumn + "|newRootField"); intFieldGrp -e -v1 1024 ($FTM_ExtraFunctionColumn + "|FTM_BOTRow|FTM_BOTResFieldGrp"); intFieldGrp -e -v1 1024 ($FTM_ExtraFunctionColumn + "|FTM_MAPRow|FTM_MAPResFieldGrp"); optionMenu -e -v "Mipmap" ($FTM_ExtraFunctionColumn + "|FTM_FilterTypeRow|FTM_FilterTypeMenu"); optionMenu -e -v "\*" ($FTM_ExtraFunctionColumn + "|FTM_FCRow|FTM_FCSourceMenu"); optionMenu -e -v "iff" ($FTM_ExtraFunctionColumn + "|FTM_FCRow|FTM_FCTargetMenu"); checkBox -e -v 0 ($FTM_ExtraFunctionColumn + "|FTM_SeqCheck"); checkBox -e -v 1 ($FTM_ExtraFunctionColumn + "|FTM_UpdateCheck"); checkBox -e -v 0 -en 1 ($FTM_ExtraFunctionColumn + "|FTM_RemoveCheck");
tabLayout -e -sti 1 $FTM_Tabs;
button -e -en 1 $FTM_CopyButton; button -e -en 1 $FTM_MoveButton; button -e -en 1 $FTM_SetButton;
global string $FTM_WorkSpace; $FTM_WorkSpace = `workspace -q -rd` + `workspace -q -fileRuleEntry "sourceImages"`; $FTM_WorkSpace = `FTM_GetPath "path" $FTM_WorkSpace`;
select -cl; waitCursor -state off; }
global proc FTM_Function (string $FTM_Function, string $FTM_OptionColumn) { global string $lsCmd; string $FTM_SelectedFiles[] = eval($lsCmd + " -sl"); if (`FTM_SelCheck $FTM_SelectedFiles`) { waitCursor -state on; FTM_Log "start" "" ""; int $wrong = 0; int $FTM_OperationMode = `radioButtonGrp -q -select ($FTM_OptionColumn + "|FTM_OperationMode")`;
string $FTM_SourceDirectory;
string $FTM_TargetDirectory = `textFieldButtonGrp -q -text ($FTM_OptionColumn + "|FTM_TargetDirectoryField")`; $FTM_TargetDirectory = `FTM_GetPath "path" $FTM_TargetDirectory`;
if ( `checkBoxGrp -q -v1 ($FTM_OptionColumn + "|FTM_MakeFolderChecker")` ) { string $FTM_NewFolderName = `textFieldGrp -q -text ($FTM_OptionColumn + "|FTM_NewFolderNameField")`; $FTM_TargetDirectory = $FTM_TargetDirectory + $FTM_NewFolderName; if (!`file -q -ex $FTM_TargetDirectory`) { if (`sysFile -md $FTM_TargetDirectory`) FTM_Log "" ("Folder created: \"" + (toNativePath($FTM_TargetDirectory)) + "\".") ""; else { $wrong = 1; FTM_Log "" ("Folder can not be created: " + (toNativePath($FTM_TargetDirectory)) + "\".") ""; } } else { if (!`filetest -w $FTM_TargetDirectory`) { $wrong = 1; FTM_Log "" ("Folder exists but is not writeable: " + (toNativePath($FTM_TargetDirectory)) + "\".") ""; } } $FTM_TargetDirectory = `FTM_GetPath "path" $FTM_TargetDirectory`; }
if (!$wrong) {
string $FTM_FunctionCmd; if ($FTM_Function == "Copy") $FTM_FunctionCmd = "sysFile -cp "; else if ($FTM_Function == "Move") $FTM_FunctionCmd = "sysFile -mov ";
int $progress = 0; int $percentage = 0; progressWindow -t "FTM Working..." -pr $progress -ii 1 -min 0 -max `size $FTM_SelectedFiles`;
for ($FTM_SelectedFile in $FTM_SelectedFiles) { FTM_Log "" ($FTM_SelectedFile+":") ""; if ( `progressWindow -q -ic` ){ FTM_Log "" "User cancelled." ""; break; } $wrong = 0;
$progress += 1; $percentage = $progress * (100/size($FTM_SelectedFiles)); progressWindow -e -pr $progress -st ("Handling " + $FTM_SelectedFile + " ...... " + $percentage + "%");
string $FTM_CurrentFile = `getAttr ($FTM_SelectedFile + ".fileTextureName")`; string $FTM_SourceFile[] = `FTM_GetFile $FTM_CurrentFile`; string $FTM_OriginSourceFile = $FTM_SourceFile[1];
if (size($FTM_OriginSourceFile) == 0) FTM_Log "" "" "WARNING: File texture is not specified.";
else {
if ( `checkBoxGrp -q -v1 ($FTM_OptionColumn + "|FTM_ReplaceStringChecker")` ) { string $FTM_OldString = `textFieldGrp -q -tx ($FTM_OptionColumn + "|FTM_OldStringField")`; string $badChar[] = {"+",".","^","$","[","]","(",")"}; for ($char in $badChar) $FTM_OldString = `substituteAllString $FTM_OldString $char ("\\"+$char)`; string $FTM_MatchExpression = "(" + $FTM_OldString + ")+"; string $FTM_NewString = `textFieldGrp -q -tx ($FTM_OptionColumn + "|FTM_NewStringField")`; for ($i=0; $i<size($FTM_SourceFile[1]); $i++) $FTM_SourceFile[1] = `substitute $FTM_MatchExpression $FTM_SourceFile[1] $FTM_NewString`; }
string $FTM_Prefix; string $FTM_Suffix; string $FTM_SourceFileRegularName[] = `FTM_FCFileRegularName $FTM_SourceFile[1]`;
if ( `checkBox -q -v ($FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_AddPrefixChecker")` ) $FTM_Prefix = `textField -q -tx ($FTM_OptionColumn + "|FTM_AddPrefixRow|FTM_PrefixField")`;
if ( `checkBox -q -v ($FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_AddSuffixChecker")` ) $FTM_Suffix = `textField -q -tx ($FTM_OptionColumn + "|FTM_AddSuffixRow|FTM_SuffixField")`;
if (size($FTM_SourceFileRegularName[1])) $FTM_SourceFileRegularName[1] = "." + $FTM_SourceFileRegularName[1]; if (size($FTM_SourceFileRegularName[2])) $FTM_SourceFileRegularName[2] = "." + $FTM_SourceFileRegularName[2]; $FTM_SourceFile[1] = $FTM_Prefix + $FTM_SourceFileRegularName[0] + $FTM_Suffix + $FTM_SourceFileRegularName[1] + $FTM_SourceFileRegularName[2];
string $FTM_FinalCmd; string $FTM_FunctionResult; int $setWrong = 0; if ($FTM_Function != "Set") { if ($FTM_OperationMode == 1) { $FTM_FinalCmd = $FTM_FunctionCmd + "\"" + `substituteAll "\\\\" ($FTM_TargetDirectory + $FTM_SourceFile[1]) "/"` + "\" \"" + `substituteAll "\\\\" $FTM_SourceFile[0] "/"` + "\""; $FTM_FunctionResult = $FTM_Function + " \"" + `toNativePath $FTM_SourceFile[0]` + "\" to \"" + `toNativePath ($FTM_TargetDirectory + $FTM_SourceFile[1])` + "\". "; } else if ($FTM_OperationMode == 2) { $FTM_SourceDirectory = `textFieldButtonGrp -q -text ($FTM_OptionColumn + "|FTM_SourceDirectoryField")`; $FTM_SourceDirectory = `FTM_GetPath "path" $FTM_SourceDirectory`; $FTM_FinalCmd = $FTM_FunctionCmd + "\"" + `substituteAll "\\\\" ($FTM_TargetDirectory + $FTM_SourceFile[1]) "/"` + "\" \"" + `substituteAll "\\\\" ($FTM_SourceDirectory + $FTM_OriginSourceFile) "/"` + "\""; $FTM_FunctionResult = $FTM_Function + " \"" + `toNativePath ($FTM_SourceDirectory + $FTM_OriginSourceFile)` + "\" to \"" + `toNativePath ($FTM_TargetDirectory + $FTM_SourceFile[1])` + "\". "; } } else if ($FTM_Function == "Set") { string $path = `substituteAll "\\\\" ($FTM_TargetDirectory + $FTM_SourceFile[1]) "/"`; string $cmd = "setAttr -typ \"string\" " + $FTM_SelectedFile + ".fileTextureName \"" + $path + "\""; if (catchQuiet(eval($cmd))) { $FTM_FunctionResult = "Attribute \"fileTextureName\" is locked/connected and can NOT be modified!"; $setWrong = 1; } else $FTM_FunctionResult = "Set to \"" + `toNativePath ($FTM_TargetDirectory + $FTM_SourceFile[1])` + "\". "; }
if ($FTM_Function != "Set") { if (!eval($FTM_FinalCmd)) { $wrong = 1; FTM_Log "" "" ("WARNING: " + $FTM_Function + " can NOT be done, could be permission issue or path existence issue."); } } if (!$wrong) {
if ( `file -q -ex ($FTM_TargetDirectory + $FTM_SourceFile[1])` ) { if ($FTM_Function == "Move") { if ( `file -q -ex $FTM_SourceFile[0]` || `file -q -ex ($FTM_SourceDirectory + $FTM_OriginSourceFile)`) { $FTM_FunctionResult = "Succeed: " + $FTM_FunctionResult + " But the original file is not removed. Check the HELP for possible reasons."; FTM_Log "" "" ("WARNING: " + $FTM_FunctionResult); } else { $FTM_FunctionResult = "Succeed: " + $FTM_FunctionResult; FTM_Log "" "" $FTM_FunctionResult; } } else { $FTM_FunctionResult = "Succeed: " + $FTM_FunctionResult; FTM_Log "" "" $FTM_FunctionResult; } } else { if ($FTM_Function == "Set") { if ($setWrong) $FTM_FunctionResult = "WARNING: " + $FTM_FunctionResult; else $FTM_FunctionResult = "Succeed: " + $FTM_FunctionResult + "But destination does NOT exist."; } else if ($FTM_Function != "Set") $FTM_FunctionResult = "Fail: " + $FTM_FunctionResult + "Check Help tab for possible reasons."; FTM_Log "" "" $FTM_FunctionResult; } } } } }
progressWindow -ep; FTM_Log "end" "" ""; FTM_END; waitCursor -state off; } }
global proc FileTextureManager () {
float $verCut = 2010; global int $FTM_NEW_MAYA, $FTM_WIDTH, $FTM_HEIGHT; $FTM_NEW_MAYA = 0; $FTM_WIDTH = 380; $FTM_HEIGHT = 600;
string $verString = `about -v`; string $verString_tmp[]; tokenize $verString " " $verString_tmp; float $verNum = $verString_tmp[0]; if ($verNum > $verCut) { global int $FTM_NEW_MAYA, $FTM_WIDTH, $FTM_HEIGHT; $FTM_NEW_MAYA = 1; $FTM_WIDTH = 520; $FTM_HEIGHT = 700; } global string $FTM_FCAllFormats[]; $FTM_FCAllFormats = {"iff","sgi","tga","rgb","jpg","jpeg","map","tif","tiff","bmp","bw","icon","cin","pic","yuv","als","gif","lff","pxb","scn","ppm","pri","qtl","vst","rla"};
global string $lsCmd; $lsCmd = "ls -typ file -typ psdFileTex ";
select -cl;
global string $FTM_MayaWorkSpace; $FTM_MayaWorkSpace = `workspace -q -dir`; global string $FTM_WorkSpace = "";
windowPref -enableAll false;
if (`window -exists FTM_MainWindow`) deleteUI FTM_MainWindow;
global int $FTM_WIDTH, $FTM_HEIGHT; window -title "File Texture Manager" -wh $FTM_WIDTH $FTM_HEIGHT -tlc 200 200 -ret FTM_MainWindow; string $FTM_MainForm = `formLayout`; string $FTM_Tabs = `tabLayout -imw 0 -imh 0`;
string $FTM_OptionForm = `formLayout`; string $FTM_OptionScroll = `scrollLayout -cr true`; string $FTM_OptionColumn = `columnLayout -adj 1 -rs 5`;
formLayout -nd 100 FTM_AnalyseForm; string $FTM_AnalyseColumn = `columnLayout -cat both 30 -adj 1 -rs 5`; button -l "分析场景文件纹理" -h 40 -w 250 FTM_AnalyseButton; text -l "" -h 5; text -l "选择要管理的文件(多选)"; string $FTM_AnalysisScroll = `scrollLayout -p FTM_AnalyseForm`; string $FTM_AnalysisColumn = `columnLayout -cat left 15`; text -l "未分析场景文件" FTM_EmptyAnalysisText; button -e -c ("FTM_AnalyseFileTextures " + $FTM_AnalysisColumn) ($FTM_AnalyseColumn + "|FTM_AnalyseButton"); formLayout -e -af $FTM_AnalyseColumn left 0 -af $FTM_AnalyseColumn right 0 -af $FTM_AnalyseColumn top 5 -af $FTM_AnalyseColumn bottom 200 -ac $FTM_AnalysisScroll top 5 $FTM_AnalyseColumn -af $FTM_AnalysisScroll bottom 0 -af $FTM_AnalysisScroll left 0 -af $FTM_AnalysisScroll right 0 ($FTM_OptionColumn + "|FTM_AnalyseForm"); setParent $FTM_OptionColumn; separator -style "in" -h 10;
radioButtonGrp -l "工作模式 " -la2 "自动" "手动" -nrb 2 -select 1 -cl3 right left left -cw3 120 100 100 FTM_OperationMode;
separator -style "in" -h 5;
textFieldButtonGrp -label "源目录" -text "" -buttonLabel "浏览" -adj 2 -en 0 -cw 1 120 -cw 3 60 -cl3 right left center FTM_SourceDirectoryField;
separator -style "in" -h 5;
string $FTM_CurrentProject = `workspace -q -rd`; string $FTM_CurrentSourceImagesDir = $FTM_CurrentProject + `workspace -q -fileRuleEntry "sourceImages"`; string $FTM_SourceImages = `FTM_GetPath "path" $FTM_CurrentSourceImagesDir`; textFieldButtonGrp -label "目标目录: " -text $FTM_SourceImages -buttonLabel "浏览" -adj 2 -cw 1 120 -cw 3 60 -cl3 right left center FTM_TargetDirectoryField;
checkBoxGrp -ncb 1 -l1 "在目标目录下创建新文件夹" -adj 1 -v1 0 -cat 1 left 101 FTM_MakeFolderChecker; textFieldGrp -label "文件夹名称" -text "TextureFiles" -en 0 -cw2 120 180 -cl2 right left FTM_NewFolderNameField; text -al center -l "FINAL目标目录将等于目标目录"; text -al center -l "加上新文件夹(如果用户决定创建新文件夹)"; separator -style "in" -h 5;
rowLayout -nc 2 -cw 1 120 -cat 1 right 0 -cl2 left left FTM_AddPrefixRow; checkBox -l "添加前缀" -v 0 FTM_AddPrefixChecker; textField -tx "prefix_" -en 0 -w 150 FTM_PrefixField; setParent $FTM_OptionColumn; rowLayout -nc 2 -cw 1 120 -cat 1 right 0 -cl2 left left FTM_AddSuffixRow; checkBox -l "添加后缀" -v 0 FTM_AddSuffixChecker; textField -tx "_suffix" -en 0 -w 150 FTM_SuffixField; setParent $FTM_OptionColumn; checkBoxGrp -ncb 1 -l1 "替换字符串" -adj 1 -v1 0 -cat 1 left 101 FTM_ReplaceStringChecker; textFieldGrp -l "旧名称:" -tx "Old String" -en 0 -cw2 120 150 -cl2 right left FTM_OldStringField; textFieldGrp -l "新名称:" -tx "New String" -en 0 -cw2 120 150 -cl2 right left FTM_NewStringField; formLayout -e -af $FTM_OptionScroll top 5 -af $FTM_OptionScroll left 0 -af $FTM_OptionScroll right 0 -af $FTM_OptionScroll bottom 0 $FTM_OptionForm; setParent $FTM_Tabs;
string $FTM_ExtraFunctionScroll = `scrollLayout -cr true`; string $FTM_ExtraFunctionColumn = `columnLayout -cat both 15 -adj 1 -rs 5`; separator -style "none" -h 5; text -fn "boldLabelFont" -al left -l "替换根路径"; textFieldButtonGrp -l "根路径" -text "" -buttonLabel "浏览" -adj 2 -en 1 -cw 1 80 -cw 3 60 -cl3 right left center oldRootField; textFieldButtonGrp -e -bc ("FTM_BrowseCmd \"path\" " + $FTM_ExtraFunctionColumn + "|oldRootField \"Choose old root\" 4") ($FTM_ExtraFunctionColumn + "|oldRootField"); string $tmp = `workspace -q -rd` + `workspace -q -fileRuleEntry "sourceImages"`; $tmp = `FTM_GetPath "path" $tmp`; textFieldButtonGrp -l "新路径" -text $tmp -buttonLabel "浏览" -adj 2 -en 1 -cw 1 80 -cw 3 60 -cl3 right left center newRootField; textFieldButtonGrp -e -bc ("FTM_BrowseCmd \"path\" " + $FTM_ExtraFunctionColumn + "|newRootField \"Choose new root\" 4") ($FTM_ExtraFunctionColumn + "|newRootField"); button -h 25 -l "替换" -c ("FTM_Substitute " + $FTM_ExtraFunctionColumn + "|oldRootField " + $FTM_ExtraFunctionColumn + "|newRootField"); separator -style "in" -h 10; text -fn "boldLabelFont" -al left -l "内存效率 (仅限Maya“文件”节点)"; text -al left -l "\"BOT\" 设置(仅限Maya软件渲染器)"; rowLayout -nc 3 -adj 3 -cw 1 170 -cw 2 2 -cal 3 center -cat 1 both 0 -cat 3 both 0 -rat 1 bottom 0 -rat 2 bottom 0 -rat 3 bottom 0 FTM_BOTRow; intFieldGrp -nf 1 -adj 2 -cw 1 50 -cat 1 left 0 -cat 2 both 5 -l "阈值" -el "" -v1 1024 FTM_BOTResFieldGrp; text -l ""; button -h 25 -l "设置 BOT" -c ("FTM_BOTSetup 1 " + $FTM_ExtraFunctionColumn); setParent ..; button -h 25 -l "取消设置 BOT" -c ("FTM_BOTSetup 0 " + $FTM_ExtraFunctionColumn); text -al left -l "\".map\" 设置(仅限mental ray)"; rowLayout -nc 3 -adj 3 -cw 1 170 -cw 2 2 -cal 3 center -cat 1 both 0 -cat 3 both 0 -rat 1 bottom 0 -rat 2 bottom 0 -rat 3 bottom 0 FTM_MAPRow; intFieldGrp -nf 1 -adj 2 -cw 1 50 -cat 1 left 0 -cat 2 both 5 -l "阈值" -el "" -v1 1024 FTM_MAPResFieldGrp; text -l ""; button -h 25 -l "设置 .map" -c ("FTM_MAPSetup 1 " + $FTM_ExtraFunctionColumn); setParent ..; button -h 25 -l "取消设置 .map" -c ("FTM_MAPSetup 0 " + $FTM_ExtraFunctionColumn); separator -style "in" -h 10; text -fn "boldLabelFont" -al left -l "过滤器设置(仅限Maya的“文件”/“sdFileTex”节点)"; rowLayout -nc 2 -cw 1 120 -cat 2 left 30 -adj 2 -cal 2 center -rat 1 bottom 0 FTM_FilterTypeRow; optionMenu -l "过滤器类型" FTM_FilterTypeMenu; menuItem -label "Off"; menuItem -label "Mipmap"; menuItem -label "Box"; menuItem -label "Quadratic"; menuItem -label "Quartic"; menuItem -label "Gaussian"; optionMenu -e -v "Mipmap" ($FTM_ExtraFunctionColumn + "|FTM_FilterTypeRow|FTM_FilterTypeMenu"); button -h 25 -l "设置过滤器类型 " -c ("FTM_FilterSetup " + $FTM_ExtraFunctionColumn); setParent ..; separator -style "in" -h 10; text -fn "boldLabelFont" -al left -l "纹理文件格式转换"; rowLayout -nc 3 -cw 1 80 -cw 3 80 -cat 1 left 0 -cat 2 left 10 -cat 3 left 10 -adj 2 -cal 2 center FTM_FCRow; optionMenu -l "源:" FTM_FCSourceMenu; menuItem -label "\*"; global string $FTM_FCAllFormats[]; for ($i=0;$i<size($FTM_FCAllFormats);$i++) menuItem -label $FTM_FCAllFormats[$i]; button -h 25 -l "选择匹配项" -c ("select -r `FTM_FCGetMatches \"" + $FTM_ExtraFunctionColumn + "|FTM_FCRow|FTM_FCSourceMenu\"`;"); optionMenu -l "转换" FTM_FCTargetMenu; for ($i=0;$i<size($FTM_FCAllFormats);$i++) menuItem -label $FTM_FCAllFormats[$i]; setParent ..; checkBox -l "处理序列纹理。" -al "left" -v 0 FTM_SeqCheck; checkBox -l "更新路径信息。" -al "left" -v 1 FTM_UpdateCheck; checkBox -l "删除原始纹理。小心使用!" -al "left" -v 0 -en 1 FTM_RemoveCheck; checkBox -e -onc ("checkBox -e -en 1 " + $FTM_ExtraFunctionColumn + "|FTM_RemoveCheck") -ofc ("checkBox -e -en 0 " + $FTM_ExtraFunctionColumn + "|FTM_RemoveCheck") ($FTM_ExtraFunctionColumn + "|FTM_UpdateCheck"); button -l "转换" -h 25 -c ("FTM_FCGatherInfo " + $FTM_ExtraFunctionColumn); setParent $FTM_Tabs;
string $FTM_HelpForm = `formLayout`;
scrollField -ww true -editable false FTM_HelpField;
setParent $FTM_HelpForm; global int $FTM_NEW_MAYA; string $FTM_AboutFrame; if ($FTM_NEW_MAYA) $FTM_AboutFrame = `frameLayout -l "关于 FileTextureManager" -fn boldLabelFont -cll 0 -bv true -li 5`; else $FTM_AboutFrame = `frameLayout -l "关于 FileTextureManager" -la top -fn boldLabelFont -cll 0 -bv true -li 5`; string $FTM_AboutForm = `formLayout`; string $FTM_AboutTextLeft = `text -l "脚本名称 :\n更新时间 :\n作者 :\n汉化 :\n邮箱 :\n\n保留所有权" -al left`; string $FTM_AboutTextRight = `text -l "FileTextureManager.mel\nMay, 2011\n叶(叶峰)\n三岁豆Er\nCrow.Yeh@gmail.com" -al left`; formLayout -e -af $FTM_AboutTextLeft left 10 -af $FTM_AboutTextLeft top 5 -an $FTM_AboutTextLeft right -af $FTM_AboutTextLeft bottom 5 -ac $FTM_AboutTextRight left 10 $FTM_AboutTextLeft -af $FTM_AboutTextRight top 5 -an $FTM_AboutTextRight right -an $FTM_AboutTextRight bottom $FTM_AboutForm; formLayout -e -ac FTM_HelpField bottom 5 $FTM_AboutFrame -af FTM_HelpField top 5 -af FTM_HelpField left 0 -af FTM_HelpField right 0 -an $FTM_AboutFrame top -af $FTM_AboutFrame left 0 -af $FTM_AboutFrame right 0 -af $FTM_AboutFrame bottom 0 $FTM_HelpForm;
setParent $FTM_MainForm; string $FTM_FunctionForm = `formLayout -h 30 -numberOfDivisions 100`; string $FTM_CopyButton = `button -l "复制" -c ("FTM_Function \"Copy\" " + $FTM_OptionColumn)`; string $FTM_MoveButton = `button -l "剪切" -c ("FTM_Function \"Move\" " + $FTM_OptionColumn)`; string $FTM_SetButton = `button -l "指定" -c ("FTM_Function \"Set\" " + $FTM_OptionColumn)`; string $FTM_ResetButton = `button -l "重置" -c ("FTM_ResetUI "+$FTM_OptionColumn+" "+$FTM_AnalysisColumn+" "+$FTM_ExtraFunctionColumn+" "+$FTM_Tabs+" "+$FTM_CopyButton+" "+$FTM_MoveButton+" "+$FTM_SetButton)`; string $FTM_CloseButton = `button -l "退出" -c ("deleteUI FTM_MainWindow; select -cl;global string $FTM_MayaWorkSpace; workspace -dir $FTM_MayaWorkSpace;")`; formLayout -e -ap $FTM_CopyButton right 1 20 -af $FTM_CopyButton top 0 -af $FTM_CopyButton left 0 -af $FTM_CopyButton bottom 0 -ap $FTM_MoveButton left 1 20 -ap $FTM_MoveButton right 1 40 -af $FTM_MoveButton top 0 -af $FTM_MoveButton bottom 0 -ap $FTM_SetButton left 1 40 -ap $FTM_SetButton right 1 60 -af $FTM_SetButton top 0 -af $FTM_SetButton bottom 0 -af $FTM_ResetButton top 0 -af $FTM_ResetButton bottom 0 -ap $FTM_ResetButton left 1 60 -ap $FTM_ResetButton right 1 80 -ap $FTM_CloseButton left 1 80 -af $FTM_CloseButton top 0 -af $FTM_CloseButton right 0 -af $FTM_CloseButton bottom 0 $FTM_FunctionForm; formLayout -e -af $FTM_Tabs top 0 -af $FTM_Tabs left 0 -af $FTM_Tabs right 0 -ac $FTM_Tabs bottom 3 $FTM_FunctionForm -af $FTM_FunctionForm left 0 -af $FTM_FunctionForm right 0 -af $FTM_FunctionForm bottom 0 -an $FTM_FunctionForm top $FTM_MainForm;
FTM_EditUIControl $FTM_OptionColumn $FTM_HelpForm;
string $tabCC = "button -e -en 0 " + $FTM_CopyButton + ";"; $tabCC += "button -e -en 0 " + $FTM_MoveButton + ";"; $tabCC += "button -e -en 0 " + $FTM_SetButton + ";"; $tabCC += "if (`tabLayout -q -sti " + $FTM_Tabs + "` == 1) {"; $tabCC += "button -e -en 1 " + $FTM_CopyButton + ";"; $tabCC += "button -e -en 1 " + $FTM_MoveButton + ";"; $tabCC += "button -e -en 1 " + $FTM_SetButton + ";"; $tabCC += "}";
tabLayout -e -tl $FTM_OptionForm "基本功能" -tl $FTM_ExtraFunctionScroll "附加功能" -tl $FTM_HelpForm "帮助" -psc $tabCC $FTM_Tabs; showWindow FTM_MainWindow;
windowPref -enableAll true; }
FileTextureManager;
|