点缓存输出输入 (确保物体形态节点名称相同)
//////////////////////////////
global proc cacheWindows()
{
if(`window -ex cacheWin`==1)deleteUI cacheWin;
window -t "缓存批量转化" -s 0 -bgc 0.2 0.2 0.2 cacheWin;
formLayout cacheWinfl ;
text -label "结束帧:" "rNameText02" ;
text -label "起始帧:" "rNameText01" ;
text -label "缓存路径:" "rNameText03" ;
//text -label "缓存起始:" "rNameText04" ;
textField -w 50 "rNameTextField02" ;
textField -w 50 "rNameTextField01" ;
//textField -w 50 "rNameTextField04" ;
textField -w 250 "rNameTextField03" ;
separator -width 305 "rNameSeparator01" ;
separator -width 305 "rNameSeparator02" ;
separator -width 305 "rNameSeparator03" ;
button -label "导出缓存" -width 305 -c "exportCache" "rNameButton02" ;
button -label "导入缓存" -width 305 -c "importCache" "rNameButton01" ;
button -label "关闭窗口" -width 305 -c "deleteUI cacheWin;" "rNameButton03" ;
text -label "注意:1.对布料出缓存时,注意修改布料形态节点名称." "cachetext1";
text -label "2.选中要输出的mesh模型,并且只针对非变换属性的动画有效." "cachetext2";
text -label "3.设置起始帧、结束帧和缓存存放路径." "cachetext3";
text -label "4.确定导出缓存模型的形态节点名称与导入缓存节点名称一致." "cachetext4";
text -label " 伍沁憬 QQ459306732 " "cachetext5";
formLayout -e
-af "rNameText02" "left" 113
-af "rNameText02" "top" 12
// -af "rNameText04" "left" 210
// -af "rNameText04" "top" 12
-af "rNameText01" "left" 6
-af "rNameText01" "top" 12
-af "rNameTextField02" "left" 153
-af "rNameTextField02" "top" 10
-af "rNameTextField01" "left" 58
-af "rNameTextField01" "top" 10
-af "rNameText03" "left" 6
-af "rNameText03" "top" 37
-af "rNameTextField03" "left" 58
-af "rNameTextField03" "top" 35
// -af "rNameTextField04" "left" 230
// -af "rNameTextField04" "top" 10
-af "rNameSeparator01" "left" 3
-af "rNameSeparator01" "top" 58
-af "rNameSeparator02" "left" 3
-af "rNameSeparator02" "top" 148
-af "rNameSeparator03" "left" 3
-af "rNameSeparator03" "top" 220
-af "rNameButton03" "left" 6
-af "rNameButton03" "top" 122
-af "rNameButton02" "left" 6
-af "rNameButton02" "top" 65
-af "rNameButton01" "left" 6
-af "rNameButton01" "top" 93
-af "cachetext1" "top" 150
-af "cachetext1" "left" 6
-af "cachetext2" "top" 165
-af "cachetext2" "left" 6
-af "cachetext3" "top" 180
-af "cachetext3" "left" 6
-af "cachetext4" "top" 195
-af "cachetext4" "left" 6
-af "cachetext5" "top" 225
-af "cachetext5" "left" 210
cacheWinfl ;
showWindow cacheWin;
}
////////////////////////////////窗口创建
//////////////////导出缓存
global proc exportCache()
{
string $sel[]=`ls -sl`;
int $count=`size $sel`;
if($count>=1)
{
int $start =`textField -q -text "rNameTextField01"`;
int $end =`textField -q -text "rNameTextField02"`;
string $cachePath =`textField -q -text "rNameTextField03"`;
string $allshapename[]=eval_r("listRelatives -s `ls -sl`");
string $shapename;
for ($shapename in $allshapename)
{
int $count=`getAttr ($shapename+".intermediateObject")`;
if ($count==0)
{
cacheFile -fileName $shapename -directory $cachePath -pts $shapename -st $start -et $end ;
}
}
}
else
{error "请选择需要导出缓存的几何体模型!!!!"; }
}
////////////////导入缓存
global proc importCache()
{
string $sel[]=`ls -sl`;
int $count=`size $sel`;
if($count>=1)
{
int $start =`textField -q -text "rNameTextField01"`;
int $end =`textField -q -text "rNameTextField02"`;
string $cachePath =`textField -q -text "rNameTextField03"`;
string $allshapename[]=eval_r("listRelatives -s `ls -sl`");
string $shapename;
for ($shapename in $allshapename)
{
string $cacheFiles[] = `cacheFile -f $shapename -st 0 -et 0 -points $shapename`;
string $switch = createHistorySwitch($shapename,false);
string $cacheNode = `cacheFile -attachFile -f $cacheFiles[0] -cnm $shapename -ia ($switch+".inp[0]") `;
setAttr ($switch+".playFromCache") true;
setAttr -type "string" ($cacheNode+".cachePath") $cachePath;
setAttr -type "string" ($cacheNode+".cacheName") $shapename;
setAttr ($cacheNode+".startFrame") 1;
setAttr ($cacheNode+".sourceStart") $start;
setAttr ($cacheNode+".sourceEnd") $end;
setAttr ($cacheNode+".originalStart") $start;
setAttr ($cacheNode+".originalEnd") $end;
}
}
else
{error "请选择需要导入缓存的几何体模型!!!!" ;}
}
(来源:tiancgVFX)
本文为作者分享,翼虎网鼓励从业者分享原创内容,翼虎网不会对原创文章作任何内容编辑修改!如作者有特别标注,请按作者说明转载,如无说明,则转载此文章须经得作者同意,并请附上出处(翼虎网)及本页链接。
原文链接:http://blog.sina.com.cn/tiancgweb