//SwitchLowRes // // Date: 2004/05/15 // Author: Dai Sato dstruevision@dstruevision.com http://www.dstruevision.com // Procedure Name: SwitchLowRes // // Description: This scripts 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`; if($numTokens<2) { return $path; } else { 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 cutDot(string $fileName, string $flag) { string $tokens[]; string $noExtension =""; string $buffer = ""; int $numTokens = `tokenize $fileName "." $tokens`; for ($i=($numTokens-1);$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