2014年11月17日月曜日

バインドメッシュを複製するやつ

前に作ったImitateBindを他の処理で使いやすくしました

global proc yjp_doImitateBind(string $sourceobj , string $targetobj )
{
string $scs = `findRelatedSkinCluster $sourceobj`;
string $sct = `findRelatedSkinCluster $targetobj`;
if( size($scs) == 0 )return;
    if( size($sct))return;

string $jointlistname[] = `listConnections -type "joint" ($scs +".matrix")`;
int $maxInf = `getAttr ($scs + ".maxInfluences")`;

select $targetobj;
//アトリビュートをアンロック
yjp_meshUnlook $targetobj;
//フリーズ
FreezeTransformations ;

string $scnext[] = `skinCluster -mi $maxInf -omi true -dr 4 -rui 0 -tsb $jointlistname $targetobj`;
//copySkinWeights -ss $scs -ds $scnext[0] -ia "closestJoint" -ia "oneToOne";
select $sourceobj $targetobj;
copySkinWeights  -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint -influenceAssociation oneToOne;
select $targetobj;
return ;
}

以下はyjp_doImitateBindを使ってバインドを保持したままメッシュを複製します
思いのほか簡単。

global proc string yjp_DuplicateMeshSkin()
{
string $objs[] = `ls -sl`;
if( size($objs) == 0)return(0);
//メッシュ複製
string $newmeshA[] = `duplicate -n ($objs[0] + "_dup") -rr $objs[0]`;
yjp_doImitateBind $objs[0] $newmeshA[0];
return ($newmeshA[0]);
}

バインドメッシュ同士のコンバインとセパレートもyjp_doImitateBindをつかってます

一応アトリビュートのアンロックプロシージャ
global proc yjp_meshUnlook(string $selectName)
{
setAttr -lock 0 ($selectName + ".tx");
setAttr -lock 0 ($selectName + ".ty");
setAttr -lock 0 ($selectName + ".tz");
setAttr -lock 0 ($selectName + ".rx");
setAttr -lock 0 ($selectName + ".ry");
setAttr -lock 0 ($selectName + ".rz");
setAttr -lock 0 ($selectName + ".sx");
setAttr -lock 0 ($selectName + ".sy");
setAttr -lock 0 ($selectName + ".sz");
}

0 件のコメント:

コメントを投稿