View Full Version : Fluid Cache Re-Applying
azshall 08-29-2006, 08:09 PM Hi.
I'm working on some stuff with Fluids. I have 2 boxes next to me, one for working and one for caching. This way I'm not on downtime waiting for a cache. Here is my predicament though!
I need the cache to be in the master scene file, now once I start the cache on ONE computer, I continue working on this master scene file and make changes/saves/etc. This means that the Master Scene File I am working on will not reflect the cache being made.
My question is this. Does anyone know of a script or methodology to re-connect a fluidCache to a desired fluid node? I did a 'createNode diskCache' but I can't seem to figure out HOW THE HELL to get it to be a fluidCache node. (They all read as diskCache, jiggle/fluid/etc), but for some reason fluids KNOW its a fluid and pulls that AETemplate.
Why can I NOT get this to work? Has anyone else experienced this or figured out how to re-map a cache from one scene to another (given the fluids are respectively the same?)
Thanks ..
Seth
|
|
essencedesign
08-29-2006, 08:20 PM
Can't you just go in to your cache_FluidShape Attr tab and assign the new cache ? ...maybe I'm not quite getting what you want to do :shrug:
azshall
08-29-2006, 08:48 PM
You can't re-assign a cache if there is no cache node to assign to. Remember, workflow is this.
2 Computers.
First Computer
Continue working. Make changes to other elements, save often, whatever.
Second Computer
Load up the scene I'm currently working with on First Computer. Start caching the desired fluid in the scene. Once this cache is done, apply it to the scene I'm working with on First Computer.
Does this make sense? First Computer fluid should not have a cache node, as you cannot create a cache if it does. This means, there IS NO cache node on the First Computer scene. If I try to manually create one, it makes a jiggleCache ... I've been digging through some of the fluidCache mel scripts that come bundled with maya and trying to re-create this, but its very complex.
Does this make sense? I'm trying to cache on a separate machine so I do not slow myself down with working on my main machine. This way I can let the Second Computer cache while I work. Then use that cache file on my First Computer scene.
Anyone?
Seth
azshall
08-29-2006, 11:21 PM
So nobody knows how to re-target a fluid cache file from 1 scene to another? If no cache file exists in the other scene?
You're kidding me if this isn't possible. Anyone?!
Over the last month. I can say that I've discovered that Maya's native caching system on all levels, is very poor. I feel for anyone who ever has to deal with managing them on a daily basis. A lot of headaches.
apoc519
08-30-2006, 01:49 AM
*nevermind, i see what you're saying. Its the wrong cache type
if you run this in your script editor it will attach an empty disk cache to your fluid that you can then point to your existing cache file
createNode diskCache;
connectAttr -f diskCache1.diskCache fluidShape1.diskCache;
replace fluidShape1 with the name of your fluid. Is that what you're looking for?
azshall
08-30-2006, 02:12 AM
if you run this in your script editor it will attach an empty disk cache to your fluid that you can then point to your existing cache file
createNode diskCache;
connectAttr -f diskCache1.diskCache fluidShape1.diskCache;
replace fluidShape1 with the name of your fluid. Is that what you're looking for?
yeah, tried that.. Doesn't work ..
Here's what I can tell that is going on, but can't get it to physically read.
AE for diskCache node regarding fluids is not the same as other ones
There is a custom expression setup to refresh (each frame) the cache to the next increment in the sequence.
The custom expression and the diskCache node both have custom created attributes to cycle the frame (the attributes are named the same, they're integers and they're called segmentStartFrame).
The expression is not only setup to refresh each frame, its custom attribute is also connected to the diskCache custom attribute via connection editor.
The segmentStartFrame attribute on the expression is also keyed from the start/finish of the cache. Then baked every keyframe with stepped keys.
The cache is then connected (as apoc has explained) to the Fluid. This is where things go wierd. It takes everything above to replicate exactly what is going on when you say "Create Fluid Cache". Yet it simply does not read the cache.
I am at a loss at this point as to what I should do. Really sucks. Here's a script I've written to re-target the the cache from an old scene. Mind you, these are exactly the same as the cache file works when I load the scene. I then delete the cache OFF of the fluid and try to re-attach. There is no difference here.
The main command I am using to actually GENERATE the diskCache node to work with fluids was found by digging in the Maya bundled MEL scripts. That command is called createAndAttachFluidDiskCache. This creates the node and then connects it, as apoc has suggested automatically. You have to do the rest.
The difference I notice when rebuilding this from scratch, is that I cannot get the new diskCache node I'm making to read if there is density/heat/temperature/etc ... The checkboxes in the diskCache node are unchecked. If you look at a fluid that is properly cached (via Maya), you'll see whatever attribs you cached are in there.
Mind you, THIS IS FOR SEQUENTIALLY CACHED FRAMES. This is not a single cache file. I need to render on a Farm and if I don't cache a file for each frame, I cannot render with maya software on the farm.
Ugh. Is anyone more confused now? :thumbsup: .. Below is the script I wrote to re-do all of this, however, it still does not work even though I can't tell a difference other than I'm already cached, just trying to re-apply it.
//
// Written by Seth Hall
// Summer 2006
//
// Usage:
// Source the script. If you have a fluid in the scene, select the proper one
// in the dropdown menu. Load a proper MCFP cache file via the browse button.
// Set your start and end frame. Then click Apply Fluid Cache.
//
// Remember, that if the fluid already has a cache setup in Maya, you must delete
// it first and then do this.
//
global proc cm_browseCopyPath (string $filePath, string $textField, string $getButton, int $type) {
global string $category[];
string $ws = "file -q -sn";
string $workSpace = toNativePath($ws);
workspace -dir $workSpace;
string $bcpTemp = "";
if ($textField != "cm_file") {
$bcpTemp += "cm_copyFilePath ";
$bcpTemp += ("\"" + $filePath + "\" ");
$bcpTemp += ("\"" + $textField + "\" ");
} else {
$bcpTemp += "cm_copySceneFilePath ";
$bcpTemp += ("\"" + $filePath + "\" ");
$bcpTemp += ("\"" + $textField + "\" ");
}
fileBrowser $bcpTemp $getButton "" $type;
}
global proc cm_copySceneFilePath (string $filePath, string $textField, string $file, string $type) {
string $path = `cm_getPath $filePath $file`;
string $buffer[];
string $newPath = "";
string $origPath = "";
tokenize $path "\\" $buffer;
int $i;
for ($i = 0; $i < size($buffer); $i++) {
if ($buffer[$i] != $buffer[size($buffer) - 1]) {
$newPath += ($buffer[$i] + "/");
$origPath += ($buffer[$i] + "/");
} else {
$newPath += $buffer[$i];
}
}
$newPath = `toNativePath($newPath)`;
$origPath = `toNativePath($origPath)`;
textField -e -tx $newPath $textField;
if (`about -os` == "irix" || `about -os` == "linux")
window -e -vis false projectViewerWindow;
workspace -dir $origPath;
cm_checker;
}
global proc cm_copyFilePath (string $filePath, string $textField, string $file, string $type) {
string $buffer[];
string $path = `cm_getPath $filePath $file`;
string $parsedPath = "";
tokenize $path "\\" $buffer;
int $size = size($buffer);
int $i;
for ($i = 0; $i < $size; $i++) {
if ($i != ($size - 1)) {
$parsedPath += ($buffer[$i] + "\\");
} else {
$parsedPath += $buffer[$i];
}
}
textField -e -tx $parsedPath $textField;
if (`about -os` == "irix" || `about -os` == "linux")
window -e -vis false projectViewerWindow;
workspace -dir $path;
cm_checker;
}
global proc string cm_getPath (string $filePath, string $oldPath) {
$oldPath = `fromNativePath $oldPath`;
if ($filePath == "file")
$oldPath = `dirname $oldPath`;
$oldPath = `substitute "$" $oldPath ""`;
string $rightPath = `toNativePath ($oldPath + "/")`;
return $rightPath;
}
global proc cm_keyMaster(string $obj, string $attr, float $start, float $end) {
float $total = ($end - $start) + 1;
if (!`objExists $obj`) {
warning ("CM -> " + $obj + " does not exist. Supply a real object");
} else {
if (!`attributeExists $attr $obj`) {
warning ("CM -> " + $obj + "." + $attr + " does not exist. Supply a real attribute.");
} else {
float $runner = $start;
int $i;
for ($i = 0; $i < $total; $i++) {
setKeyframe -ott "step" -at $attr -t $runner -v $runner $obj;
$runner++;
}
}
}
}
global proc string sh_cacheMasterApply(string $fluid, string $cacheFile, string $fileCachedFrom, float $start, float $end) {
if (!`objExists $fluid`) {
warning ("CM -> " + $fluid + " does not exist.");
} else {
if (!`filetest -f $cacheFile`) {
warning ("CM -> The Cache File you supplied could not be located.");
} else {
string $temp[] = `listRelatives -s $fluid`;
string $fluidShape = $temp[0];
string $cacheNode = `createAndAttachFluidDiskCache $fluid $cacheFile`;
string $expName = (`substituteAllString $fileCachedFrom "." "_"` + "_currentSegment#");
string $exp = ("updateCacheSegmentAtCurrentTime " + $cacheNode + " " + $fileCachedFrom);
AEassignDiskCB ($cacheNode + ".cacheName") $cacheFile "disk cache";
addAttr -ln "segmentStartFrame" -sn "ssf" -at long -dv 0 $cacheNode;
string $exp = `expression -s $exp -o "" -n $expName -ae 1 -uc all`;
addAttr -ln "segmentStartFrame" -sn "ssf" -at long -dv 0 $exp;
cm_keyMaster $exp "segmentStartFrame" $start $end;
connectAttr -f ($exp + ".segmentStartFrame") ($cacheNode + ".segmentStartFrame");
return $cacheNode;
}
return "Supply the correct cache node and try again.";
}
return "Fluid container does not exist.";
}
global proc cm_checker() {
string $cache = `textField -q -tx cm_cache`;
string $fluid = `optionMenu -q -v cm_fluidOption`;
string $fileName;
float $start = `floatField -q -v cm_start`;
float $end = `floatField -q -v cm_end`;
string $command;
string $buffer[];
int $count = 0;
int $found = 1;
tokenize $cache "." $buffer;
if ($cache == "") {
$count++;
$found--;
} else if (size($buffer) < 2) {
textField -e -tx "" cm_cache;
warning ("CM -> This is not a proper Fluid Cache File.");
$count++;
$found--;
} else if ($buffer[size($buffer) - 1] != "mcfp") {
textField -e -tx "" cm_cache;
warning ("CM -> This is not a proper Fluid Cache File. Extension should be \"mcfp\"");
$count++;
$found--;
}
if ($found > 0) {
string $fBuff[];
string $mBuff[];
string $foo;
string $ext;
tokenize $cache "\\" $fBuff;
int $i;
for ($i = 0; $i < size($fBuff); $i++) {
if (`gmatch $fBuff[$i] "*.ma*"`) {
$foo = $fBuff[$i];
$ext = ".ma";
} else if (`gmatch $fBuff[$i] "*.mb*"`) {
$foo = $fBuff[$i];
$ext = ".mb";
}
}
tokenize $foo "." $mBuff;
textField -e -tx ($mBuff[0] + $ext) cm_fileName;
clear $fBuff;
clear $mBuff;
}
if ($start > $end) {
$count++;
} else if ($end < $start) {
$count++;
}
if ($count < 1) {
$fileName = `textField -q -tx cm_fileName`;
$cache = `substituteAllString $cache "\\" "/"`;
$command = ("sh_cacheMasterApply \"" + $fluid + "\" \"" + $cache + "\" \"" + $fileName + "\" " + $start + " " + $end);
print ("\nDEBUG: > " + $command + "\n");
button -e -en 1 -l "Apply Fluid Cache" -c ("sh_cacheMasterApply \"" + $fluid + "\" \"" + $cache + "\" \"" + $fileName + "\" " + $start + " " + $end) cm_applyCacheButton;
} else {
button -e -en 0 -l "Fix Your Settings!" -c "" cm_applyCacheButton;
}
clear $buffer;
}
global proc sh_cacheMaster() {
if (`window -exists cacheMasterGUI`) {
deleteUI cacheMasterGUI;
}
window
-title "Cache Master (MAYA CACHING SUCKS EDITION)"
-titleBar true
-maximizeButton false
-minimizeButton true
-sizeable false
-resizeToFitChildren true
-menuBar false
-menuBarVisible false
-w 375
-h 100
cacheMasterGUI;
columnLayout -adj true;
rowColumnLayout -nc 2
-cs 1 2 -cw 1 54
-cs 2 5 -cw 2 307;
text -l "File Name" cm_fileNameLabel;
textField
-ed 0
-tx ""
-cc "cm_checker()"
-ec "cm_checker()"
cm_fileName;
setParent ..;
separator -h 2 -st "none";
separator -h 3 -st "in";
separator -h 2 -st "none";
rowColumnLayout -nc 3
-cs 1 2 -cw 1 54
-cs 2 5 -cw 2 242
-cs 3 2 -cw 3 65;
text -l "Cache File" cm_cacheLabel;
textField
-tx ""
-cc "cm_checker()"
-ec "cm_checker()"
cm_cache;
button -l "Browse" -c ("cm_browseCopyPath \"path\" \"cm_cache\" \"Choose Output\" 0") cm_fileBrowse;
setParent ..;
separator -h 2 -st "none";
separator -h 3 -st "out";
separator -h 2 -st "none";
rowColumnLayout -nc 2
-cs 1 2 -cw 1 54
-cs 2 5 -cw 2 307;
string $fShapes[] = `ls -et "fluidShape"`;
string $fObjs[];
text -l "Fluid Obj" cm_fluidObjLabel;
optionMenu -l "" -cc "cm_checker()" cm_fluidOption;
if (size($fShapes) > 0) {
int $i;
for ($i = 0; $i < size($fShapes); $i++) {
$fObjs = `listRelatives -p $fShapes[$i]`;
menuItem -l $fObjs[0];
clear $fObjs;
}
}
clear $fShapes;
clear $fObjs;
setParent ..;
separator -h 2 -st "none";
separator -h 3 -st "out";
separator -h 2 -st "none";
rowColumnLayout -nc 4
-cs 1 40 -cw 1 54
-cs 2 5 -cw 2 60
-cs 3 40 -cw 3 54
-cs 4 5 -cw 4 60;
text -l "Start Frame" cm_startLabel;
floatField
-cc "cm_checker()"
-ec "cm_checker()"
-s 10
-pre 2
-v `playbackOptions -q -min`
cm_start;
text -l "End Frame" cm_endLabel;
floatField
-cc "cm_checker()"
-ec "cm_checker()"
-s 10
-pre 2
-v `playbackOptions -q -max`
cm_end ;
setParent ..;
separator -h 2 -st "none";
separator -h 3 -st "in";
separator -h 2 -st "none";
text -fn "boldLabelFont" -l "* THIS MUST BE A MULTI FRAME CACHE *";
separator -h 2 -st "none";
separator -h 3 -st "out";
separator -h 2 -st "none";
button -l "Apply Fluid Cache" -c ("") cm_applyCacheButton;
setParent ..;
setParent ..;
showWindow cacheMasterGUI;
cm_checker;
}
sh_cacheMaster;
Seth
azshall
08-30-2006, 03:06 AM
Got it to work. Jesus what a tedious and odd way of having to make something work.
My script actually does work. There is 1 discrepancy. When I create the cache node, I'm actually creating it called the FLUID NAME .. not the FLUID SHAPE NAME ... Here lies the problem. The expression to auto-update the segmented cache requires the exact same name. With that said ... I swapped that name, re-did it and worked fine. I've corrected the script above to work for those who would like to re-target their own cache.
Enjoy.
Seth
apoc519
08-30-2006, 03:24 AM
unless you're doing this hundreds of times a day is it not just easier to create a new cache and then redirect it to the correct cache files?
Or plan ahead and create a cache before you transfer to the second machine? It would only need to be 1 frame. Just to create the correct fluid cache node
Is there something about the file-per-frame cacheing that makes that not work? Every render farm I've worked on read the single large cache file just fine
Mikael_CC
08-31-2006, 10:57 AM
Another work around is save the scene you did the cache in as a temp name with only the fluids in the scene. Then import the fluid into your main scene.
CGTalk Moderation
08-31-2006, 10:57 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.