//MatFilePlace2d // // Date: 2004/01/18 // Author: Dai Sato dstruevision@dstruevision.com http://www.dstruevision.com // Procedure Name: MatFilePlace2d // // Description: This scripts list up all material in your scene. When you select a // material in the list, it also list up file and place2d texture nodes which are // connected to that materail. Then you can change some attribue of those nodes like // filter type, pre-filter radius, wrapUV. // How to use: Just type "MatFilePlace2d" in command line. // after you put this file to your script folder. // This scripts also include functions to make map and bot file, and switch between high-res and low-res texture map. // This function enable you to switch texture file between normal one and low-res one. // To use this function, you have to make low-res one manually. File name have to be as filename_LowRes.extension. // ex. lambert1.testLowRes.Color.tga¨lambert1.testLowRes.Color_LowRes.tga proc string extractFileName(string $path) { string $tokens[]; int $numTokens = `tokenize $path "/" $tokens`; return $tokens[$numTokens-1]; } proc string extractDir(string $path) { string $tokens[]; int $numTokens = `tokenize $path "/" $tokens`; return $tokens[$numTokens-2]; } 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; } proc string checkType(string $check){ string $nodeType = `nodeType $check`; string $class []= `getClassification $nodeType`; if($class[0]=="shader/surface"||$class[0]=="shader/surface/utility"||$class[0]=="shader/displacement") { return "true"; } else { return "false"; } } global proc string[] collectMaterials (){ string $sceneMaterials[] = `ls -mat`; return $sceneMaterials; } global proc string[] collectFiles (){ string $selectedMaterial[] = `ls -sl`; string $matFiles[]; string $allNodes []; int $counter = 0; print "true?"; if($selectedMaterial[0] != "") { $allNodes = `listHistory $selectedMaterial[0]`; for($i=0;$i=0;$i--){ if($i==($numTokens-1)){ if($flag==1) { $noExtension = $tokens[$i]+"_LowRes"; } if($flag==2) { $noExtension = $tokens[$i]; } } else { $noExtension = ($tokens[$i] + "." + $buffer); } $buffer = $noExtension; } return $noExtension; } proc string checkLowRes(string $fileName) { string $nativeWD = `workspace -q -rd`; string $currentWD = toNativePath($nativeWD); string $defaultDir = $currentWD + "sourceimages/"; string $foundFiles[] = `getFileList -folder $defaultDir`; string $noExtension = cutExtension($fileName); string $noDot = cutDot($noExtension,1); string $flag; for($i=0;$i