と言う事で作っていたらデタッチセパレートがいらなくなってしまった。
分割したメッシュの両方にウエイトがコピーされますよ
マージするMELも作ったので後日
/*
ちぎりたいフェースを選択して実行
スキンクラスタがあればウエイトも維持
使用しているプロシージャ
yjp_DuplicateMeshSkin
yjp_doImitateBind
yjp_meshUnlook
*/
global proc yjp_SeparateMeshWeight()
{
 string $origFaceSel[] = `filterExpand -ex 1 -sm 34`;
 print ($origFaceSel[0] + "\n") ;
 if(!`gmatch $origFaceSel[0] "*.f*"`)
 {
  print ("フェースを選択してください" + "\n") ;
  return;
 }
 string $temp[];
 string $FaceNum[] ;
 string $Amesh;
 int $n;
 
 for ($n=0 ; $n < size($origFaceSel) ; $n++)
 {
  tokenize $origFaceSel[$n] "." $temp;
  $FaceNum[$n] = $temp[1];
  //print ($FaceNum[$n] + "\n") ;
 }
 
 string $origObjShape[] = `listRelatives -p $origFaceSel`;
 string $origObj[] = `listRelatives -p $origObjShape`;
 string $parents[] = `listRelatives -p $origObj[0]`;
 ////////スキンクラスター取得
 
 string $scf = `findRelatedSkinCluster $origObj[0]`;
 
 if( size($scf))
 {
  ////////バインドされているジョイントを取得
  string $jointlistnameA[] = `listConnections -type "joint" ($scf +".matrix")`;
  //最大インフルエンス取得
  int $maxInf = `getAttr ($scf + ".maxInfluences")`;
  
  //ソースメッシュウエイトを保存
  select -r $origObj[0];
  //ウエイト保存のため複製
  $Amesh = `yjp_DuplicateMeshSkin`;
 }
 
 //Aメッシュ複製
 string $newmeshA[] = `duplicate -n ($origObj[0] + "_A") -rr $origObj[0]`;
 //Bメッシュ複製
 string $newmeshB[] = `duplicate -n ($origObj[0] + "_B") -rr $origObj[0]`;
 //Aメッシュ選択フェース以外削除
 string $FaceA[];
 for ($n=0 ; $n < size($FaceNum) ; $n++)
 {
  $FaceA[$n] = $newmeshA[0] + "." + $FaceNum[$n];
 }
 select -r $FaceA;
 InvertSelection;
 delete;
 
 //Bメッシュ選択フェース削除
 string $FaceB[];
 for ($n=0 ; $n < size($FaceNum) ; $n++)
 {
  $FaceB[$n] = $newmeshB[0] + "." + $FaceNum[$n];
 }
 select -r $FaceB;
 delete;
 
 if( size($scf))
 {
  //ソースメッシュと同じバインドを複製メッシュに摘要
  yjp_doImitateBind $origObj[0] $newmeshA[0];
  
  select -r $newmeshA[0];
  //ウエイトコピー
  $scs = `findRelatedSkinCluster $Amesh`;
  $sct = `findRelatedSkinCluster $newmeshA[0]`;
  copySkinWeights -ss $scs -ds $sct -noMirror;
  
  select -r $newmeshA[0];
  //不要なインフルエンスの除去
  removeUnusedInfluences;
  
  //ソースメッシュと同じバインドを複製メッシュに摘要
  yjp_doImitateBind $origObj[0] $newmeshB[0];
  
  select -r $newmeshB[0];
  //ウエイトコピー
  $scs = `findRelatedSkinCluster $Amesh`;
  $sct = `findRelatedSkinCluster $newmeshB[0]`;
  copySkinWeights -ss $scs -ds $sct -noMirror;
  print ("ウエイトコピー" +"\n");
  
  select -r $newmeshB[0];
  //不要なインフルエンスの除去
  removeUnusedInfluences;
  
  delete $Amesh;
  
 }
 delete $origObj[0];
 rename $newmeshB[0] $origObj[0];
 select -r $newmeshA[0];
}
 
0 件のコメント:
コメントを投稿