//James Parks //Sample scenes.txt file for jpMayaCache /* shot01 shot02 shot03 shot04 shot05 test */ //This is used to seperate caches into scenes folders //jpPointOven will further seperate caches by the reference //prefix and then name the file prefix_geo.####.kpc //So you wind up with: //|---PointOven // |---shot01 // |---shot02 // |---character01_bodyGEO.mdd // |---character02_shirtGEO.mdd global float $jpMayaCacheVerNum = 1.0; ////////////////////////// //All the crap to get the vert cache out ////////////////////////// global proc jpMakeMayaCache() { string $startDate = `system("date /T")`; string $startTime = `system("time /T")`; int $poMin = `playbackOptions -q -min`; int $poMax = `playbackOptions -q -max`; string $scene = `optionMenuGrp -q -v jpMCoutSceneMenu`; string $path = `optionVar -q "jpMCpath"`; if(!`filetest -d $path`) { sysFile -md $path; }//end if string $noPath; if($path == "") { $noPath = `confirmDialog -t "Set A Path" -ma "center" -m "You Must Set A Path" -b "OK"`; }//end if if($noPath == "OK") jpMCsetPathDialog(); string $allObjects[] = `ls -sl`; string $prefix = jpAmIaReference($allObjects[0]); if($prefix == "0") { $prefix = "NotReferenced"; }//end if string $tokPrefix[]; tokenize $prefix ":" $tokPrefix; $prefix = $tokPrefix[0]; sysFile -md ($path + $scene + "\/" + $prefix); string $fullPath = ($path + $scene + "\/" + $prefix + "\/"); for($thisObj in $allObjects) { string $thisPath = ($fullPath + $thisObj + "\/"); string $thisShape[] = `listRelatives -s $thisObj`; print ("Min: " + $poMin + "\n"); print ("Max: " + $poMax + "\n"); print ("Path: " + $path + "\n"); print ("Scene: " + $scene + "\n"); print ("This Path: " + $thisPath + "\n"); print ("Object: " + $thisShape[0] + "\n\n"); //print ($poMin + " " + $poMax + " " + $fullPath + "\/" + $thisObj); jpWriteCacheCmd($poMin, $poMax, $thisPath, $thisObj, $thisShape[0]); }//end for currentTime $poMin; string $endDate = `system("date /T")`; string $endTime = `system("time /T")`; print ("Started at " + $startTime + " " + $startDate + "\nEnded at " + $endTime + " " + $endDate); }//end proc jpMakeMayaCache ///////////////////// //This is the function you must change to use a different vertex caching system //Well, one of the functions anyway ///////////////////// global proc jpWriteCacheCmd(string $start, string $end, string $path, string $file, string $object) { cacheFile -directory $path -startTime $start -endTime $end -fileName $file -fm "OneFilePerFrame" -staticCache 1 -points $object -dtf; }//end proc jpWriteCacheCmd global proc jpReadCacheCmd(string $start, string $end, string $path, string $file, string $object) { importCacheFile ($path + $file + ".xml") "xml"; }//end proc jpReadCacheCmd //////////////////// //Select Heirarchy Geometry //////////////////// global proc jpSelectHeirGEO() { string $geos[]; string $new_pwObjs[]; string $old_pwObjs[]; do { $old_pwObjs[0] = $new_pwObjs[0]; $new_pwObjs = `pickWalk -d "up"`; }while($old_pwObjs[0] != $new_pwObjs[0]); select -hi $new_pwObjs[0]; string $heirarchy[] = `ls -tr -sl`; $geos = jpFilterList($heirarchy, "*GEO"); select $geos; }//end proc jpSelectHeirGEO ///////////////////// //Read lines from file to make option menu ///////////////////// global proc string[] jpReadLines(string $file) { string $lines[]; if(!`filetest -r $file`) { warning "File Not Found"; }//end if int $fileID = `fopen $file r`; string $nextLine = `fgetline $fileID`; int $i = 0; while ( size( $nextLine ) > 0 ) { string $tokContents[]; int $tokNumber = `tokenize $nextLine "\n" $tokContents`; if($tokNumber > 0) { $lines[$i] = $tokContents[0]; $i++; }//end if $nextLine = `fgetline $fileID`; }//end while fclose $fileID; return $lines; }//end proc global proc jpInitMayaCache() { string $path = `optionVar -q "jpMCpath"`; string $noPath; if($path == "") { $noPath = `confirmDialog -t "Set A Path" -ma "center" -m "You Must Set A Path" -b "OK"`; }//end if if($noPath == "OK") jpMCsetPathDialog(); }//end proc jpInitMayaCache ////////////////////////// //All the crap to get the vert cache back in //This is the other function you have to change to use another vertex caching system ////////////////////////// global proc jpAddMayaCacheDeformer() { int $poMin = `playbackOptions -q -min`; int $poMax = `playbackOptions -q -max`; string $character; string $allObjects[] = `ls -sl`; //Path Stuff string $scene = `optionMenuGrp -q -v jpMCoutSceneMenu`; string $path = `optionVar -q "jpMCpath"`; string $noPath; if($path == "") { $noPath = `confirmDialog -t "Set A Path" -ma "center" -m "You Must Set/nA Path" -b "OK"`; }//end if if($noPath == "OK") jpMCsetPathDialog(); $thisPath = ($path + "\/" + $scene); for($thisObj in $allObjects) { select -clear; select $thisObj; string $prefix = jpAmIaReference($thisObj); if($prefix != "0") { int $prefixLen = `size($prefix)`; $prefix = `substring $prefix 1 ($prefixLen-1)`; }//end if else { $prefix = "NotReferenced"; }//end else //print ("\nFile: " + $path + $thisObject); string $fullPath = ($path + $scene + "\/" + $prefix + "\/"); string $thisPath = ($fullPath + $thisObj + "\/"); string $thisShape[] = `listRelatives -s $thisObj`; print ("Min: " + $poMin + "\n"); print ("Max: " + $poMax + "\n"); print ("Path: " + $path + "\n"); print ("Scene: " + $scene + "\n"); print ("This Path: " + $thisPath + "\n"); print ("Object: " + $thisShape[0] + "\n\n"); jpReadCacheCmd($poMin, $poMax, $thisPath, $thisObj, $thisShape[0]); }//end for }//end proc jpAddVertDeformer ///////////////// //jpMayaCache GUI ///////////////// global proc jpMayaCache() { global float $jpMayaCacheVerNum; string $path = `optionVar -q "jpMCpath"`; string $noPath; if($path == "0") { $noPath = `confirmDialog -t "Set A Path" -ma "center" -m "You Must Set A Path" -b "OK"`; }//end if if($noPath == "OK") jpMCsetPathDialog(); string $scenes[] = jpReadLines($path + "scenes.txt"); string $winName = "jpMayaCacheGUI"; if (`window -exists $winName`) deleteUI $winName; window -t ("MayaCache v" + $jpMayaCacheVerNum + " -- James Parks") -w 115 -h 115 -rtf 1 -mnb 1 -mxb 0 -menuBar 1 $winName; menu -l "File" jpMCfileMenu; menuItem -l "Set Path..." -p jpMCfileMenu -c "jpMCsetPathDialog()" jpMCsetPathMenuItem; menuItem -l "Print Path" -p jpMCfileMenu -c ("print \"" + $path + "\"") jpMCprintPathMenuItem; menuItem -l "Refresh" -p jpMCfileMenu -c "jpMayaCache()" jpMCrefreshMenuItem; // string $jpMCcacheForm = `formLayout -numberOfDivisions 100 jpPMcacheForm`; // string $jpMCcacheTabs = `tabLayout -scr 1 -innerMarginWidth 5 -innerMarginHeight 5 jpMCcacheTabs`; // setParent $jpMCcacheTabs; string $outTab = `columnLayout outColumn`; rowColumnLayout -nc 1 -cw 1 115; button -w 115 -l "Select All *GEO" -c ("string $allGEO[] = `ls -r 1 \"*GEO\"`; select $allGEO;"); //("catchQuiet(`select \"*GEO\"`); catchQuiet(`select -add \"*:*GEO\"`); catchQuiet(`select -add \"*:*:*GEO\"`)"); button -w 115 -l "Select Heir *GEO" -c "jpSelectHeirGEO"; optionMenuGrp -cw 1 50 -cw 2 65 -cal 1 "left" -cal 2 "left" -l "Scene:" jpMCoutSceneMenu; for($scene in $scenes) { menuItem -l $scene ($scene + "MenuItem"); }//end for setParent ..; //checkBox -w 115 -l "Single File" -al "left" -v 0 jpMCsingleFileOutGrp; //checkBox -w 115 -l "All GEO at Once" -al "left" -v 0 jpMCallAtOnceGrp; button -w 115 -l "Cache Selected" -c "jpMakeMayaCache"; button -w 115 -l "Deform Selected" -c "jpAddMayaCacheDeformer"; showWindow $winName; }//end proc jpMayaCache global proc jpMCsetPathDialog() { global string $jpMCpath; fileBrowserDialog -m 4 -fc "jpMCsetPath" -an "Set Vertex Cache Path"; }//end proc jpMCsetPathDialog global proc jpMCsetPath(string $fileName, string $fileType) { global string $jpMCpath; $jpMCpath = ($fileName + "\/"); optionVar -sv "jpMCpath" $jpMCpath; jpMayaCache; }//end proc jpMCsetPath