//JustMakeMap // // Date: 2004/01/30 // Author: Dai Sato dstruevision@dstruevision.com http://www.dstruevision.com // Procedure Name: JustMakeMap // // Description: This scripts enable you to make memory-mapped files of all file nodes and load these map files. // How to use: Just type JustMakeMap in comand line, then enter path and press make button. proc string extractFileName(string $path) { string $tokens[]; int $numTokens = `tokenize $path "/" $tokens`; return $tokens[$numTokens-1]; } proc string extractExtension(string $extractedFilename) { string $tokens[]; int $numTokens = `tokenize $extractedFilename "." $tokens`; return $tokens[$numTokens -1]; } proc string cutExtension(string $fileName) { string $tokens[]; string $noExtension =""; string $buffer = ""; int $numTokens = `tokenize $fileName "." $tokens`; for ($i=$numTokens-2;$i>=0;$i--) { $noExtension = ($tokens[$i] + "." + $buffer); $buffer = $noExtension; } return $noExtension; } proc string returnDir(string $path) { string $tempFilePath = ""; string $buffer = ""; string $tokens[]; int $numTokens = `tokenize $path "/" $tokens`; for ($i=$numTokens-2;$i>=0;$i--) { $tempFilePath = ($tokens[$i] + "/" + $buffer); $buffer = $tempFilePath; } return $tempFilePath; } global proc mySelectDir(string $folder,string $something) { string $selectedDir = (toNativePath($folder)); textField -e -tx $selectedDir newFilePathMap; } global proc myGetDir() { fileBrowserDialog -m 4 -fc "mySelectDir" -ft "omage" -an "Select Dir"; } global proc myJustMakeMap () { $textureNodes = `ls -typ file`; $progressMax = size($textureNodes); if($progressMax != 0) { progressBar -edit -beginProgress -isInterruptable true -status "Calculation ..." -maxValue $progressMax makeMapProgressBar; for ($node in $textureNodes) { string $fullFileName = `getAttr($node+".fileTextureName")`; string $fileName = extractFileName($fullFileName); string $extension = extractExtension($fileName); string $fileDir = returnDir($fullFileName); string $newFileDir = `textField -q -tx newFilePathMap`; string $cutFilename = cutExtension($fileName); string $newExtension = "map"; string $newFileName = $newFileDir+"/"+$cutFilename+$newExtension; if(`file -q -ex $fullFileName`){ chdir $fileDir; $systemCommand2 = "imf_copy -p "+$fileName+" "+$newFileName+" map"; system ($systemCommand2); setAttr ( $node + ".fileTextureName") -type "string" $newFileName; } progressBar -edit -step 1 makeMapProgressBar; } progressBar -edit -endProgress makeMapProgressBar; } } global proc JustMakeMap () { global int $progressMax = 10; string $nativeWD = `workspace -q -rd`; string $currentWD = toNativePath($nativeWD); string $defaultDir = $currentWD + "sourceimages"; workspace -dir $defaultDir; if ((`window -ex MakeMapWindow`) == true) deleteUI MakeMapWindow; window -t "JustMakeMap" -s true -mnb true -mxb true -mb true -w 100 -h 200 MakeMapWindow; columnLayout baseColumn; frameLayout -label "MakeMap" -w 240 baseFrame; columnLayout; text -l "enter output path(or leave as it is)"; rowColumnLayout -numberOfRows 1; textField -w 200 -ed false -tx $defaultDir newFilePathMap; button -label "Dir" -c "myGetDir()"; setParent baseColumn; columnLayout -rs 3; progressBar -width 150 -height 10 makeMapProgressBar; rowColumnLayout -numberOfRows 1; button -l "MakeMap" -w 60 -h 30 -c "myJustMakeMap()"; button -l "Undo" -w 50 -h 30 -c "undo"; window -e -width 250 -height 130 MakeMapWindow; showWindow; }