スキンウェイトに詳しくなりたい copySkinWeights コマンド

スキンウェイトに詳しくなりたい
スキンウェイトの世界は自動化がまだ追いついてないっぽい。
スキンウェイトのコピーの中身は

copySkinWeights -sourceSkin skinCluster1 -destinationSkin skinCluster2 -noMirror;
http://me.autodesk.jp/wam/maya/docs/Maya2010/Commands/copySkinWeights.html

cmds.copySkinWeights( sourceSkin=’skinCluster1′, destinationSkin=’skinCluster2′, noMirror=True
http://me.autodesk.jp/wam/maya/docs/Maya2010/CommandsPython/copySkinWeights.html

解決できないエラー(モデルがわるかった。スキンバインド全体が壊れてた。)
cmds.copySkinWeights( sourceSkin=’group_mesh|Mesh|Genesis8FemaleSkin’, destinationSkin=’group_meshHIK|Mesh|Genesis8FemaleSkin’, noMirror=True )

エラー: line 1: RuntimeError: file line 1: skinCluster ノードは -sourceSkin/-ss フラグとともに指定する必要があります。 #

解決できないエラー(一般的)(モデルがわるかった。スキンバインド全体が壊れてた。)
copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
// 警告: line 0: スキン オブジェクトではないので ‘Genesis8FemaleSkinShape’ をスキップします。 //
// エラー: line 0: 1 つのソース スキンと 1 つの目的のスキン、もしくはソースと目的のスキン上のコンポーネントを選択する必要があります。 //

ーーーーーーーーーーーーーーーーー
Maya2020でも解決できていない様子、(モデルがわるかった。スキンバインド全体が壊れてた。)

copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
// 警告: line 0: スキン オブジェクトではないので ‘Genesis8FemaleSkinShape’ をスキップします。 //
// エラー: line 0: 1 つのソース スキンと 1 つの目的のスキン、もしくはソースと目的のスキン上のコンポーネントを選択する必要があります。 //

cmds.copySkinWeights( sourceSkin=’group_mesh|Mesh|Genesis8FemaleSkin’, destinationSkin=’group_meshHIK|Mesh|Genesis8FemaleSkin’, noMirror=True )
エラー: RuntimeError: file line 1: skinCluster ノードは -sourceSkin/-ss フラグとともに指定する必要があります。 #

copySkinWeightsはそのコマンドの処理の中で、skinClusterコマンドを使っているみたいで
その引数部分にsourceSkinがうまくわたせてないみたいに見える。

モデルがわるかった。スキンバインド全体が壊れてた。


これも関係ありそう。
skinClusterは、一度に1つのジオメトリのみをバインドします。したがって、複数のジオメトリをバインドするには、複数のskinClusterコマンドを発行する必要があります。

https://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/Commands/skinCluster.html

一旦1つの裸ジオメトリのスキンウェイトにしておいてそれを複数の服にコピーしていく流れをやったらいいのかもな。
ーーーーーーーーーーーーーーーーーーーーー

ダメだった。
cmds.copySkinWeights( sourceSkin=’group_mesh|Mesh|Genesis8FemaleSkin’, destinationSkin=’group_meshHIK|Mesh|Genesis8FemaleSkin’, noMirror=True )
エラー: line 1: RuntimeError: file line 1: skinCluster ノードは -sourceSkin/-ss フラグとともに指定する必要があります。 #

copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
// 警告: line 0: スキン オブジェクトではないので ‘Genesis8FemaleSkinShape’ をスキップします。 //
// エラー: line 0: 1 つのソース スキンと 1 つの目的のスキン、もしくはソースと目的のスキン上のコンポーネントを選択する必要があります。 //

メッシュを追加するたびにスキンウェイトをやりなおす?その必要はないスキンウェイトのコピーはメッシュ単位。

メッシュを追加するたびにスキンウェイトをやりなおす?その必要はないスキンウェイトのコピーはメッシュ単位。

スキンウェイトの情報は.mb/.maシーンデータに入っているからシーンごと読み込むことが重要だ。

1,OldシーンにNewシーンを読み込んでOldキャラとNewキャラをそれぞれグループ化して並べる
2,見にくいけど、グループの座標は同じにしてから、
3,OldキャラとNewキャラを順に選択して、Skin > Edit Smooth Skin > Copy Skin Weights を実行したらうまくいった。

ついでに追加したメッシュが体に添うようなスキニーパンツやフィットしたスーツなら
体から服にスキンをコピーしてあげればびったり添う

曲げても平気

こんなに曲げても大丈夫

明日python書く予定は未定。

jointにSkinClusterがないと起こるエラー

jointにSkinClasterがないとなるエラー

The plug-in has found the following skin definition problems :
Unable to find the bind pose for : / SK_Mannequin / root / pelvis / spine_01 / spine_02 / spine_03 / clavicle_l / upperarm_l / lowerarm_l / hand_l / ring_01_l. No bind poses in the hierarchy containing the object will be exported.
Unable to find the bind pose for : / SK_Mannequin / root / pelvis / spine_01 / spine_02 / spine_03 / clavicle_r / upperarm_r / lowerarm_r / hand_r / middle_01_r / middle_02_r. No bind poses in the hierarchy containing the object will be exported.

これを解決するためにテストした

jointにSkinClusterがないとなるようで

たとえば下のように手のジョイントがSphereの外に突き出ている場合に

手のjointのSkinClusterがない状態になる。この状態でスキンバインドし保存し開きなおしてFBX出力するとエラーが出る。

このようにメッシュが外をカバーできていればエラーが出ない。

メッシュをスケールしjointを覆うだけでなおせる。。 下は読む必要がない。

もっと深堀してみると、、、、

このエラーがでるのは
BindPoseにはSkinClusterが必要だということになる。
SkinClusterなかったら、スキンバインド時にBindPoseは作られるがFBX出力時に怒られる
たぶんこのFBX exporter pluginが
SkinCluster経由で探したBindPoseがみつからないか?
・BindPoseのSkinClusterがないとこの「プラグインは、次のスキン定義の問題を発見しました。」と言っているのでBindPoseのSkin情報がないというのは問題になるみたいだ。


ノードエディタだと正常な場合こうJointノードにバインドポーズがあってBindPose1に接続されてる。

スキンクラスターがないノード
バインドポーズからピンがでていない


・jointのバインドポーズを直接BindPose1へノードエディタでつなげてみる
 →やってみたが、どのワールド行列につないだらよいかわからない。

もう少しシンプルなものでテストしてみたほうがいい。


下の例では
・gotoBindPose;をしても問題が出ない
・チャネルボックスエディタでもノードエディタでもBindPoseを持たないjointが存在。
・SkinClusterがなくても保存して開きなおしてFBX出力してもエラーが出ない。

一辺倒な言葉ではなにも語れないことがわかった。
jointがメッシュからはみ出ているなら 、だって骨が皮からはみ出ているなら問題あるでしょ。
・メッシュをかぶせる
・ジョイントをめり込ませるか
このめんどうな作業をやり直したほうがよさそうだ。

Maya Selected Node All Childs node disconnectAttr Loop

選択したノード以下のすべての接続を解除するループ

import maya.cmds as cmds
selectionNode=cmds.ls(sl=True)
# 指定したノード以下全てを検索
selectionNodes=cmds.ls(selectionNode,dag=1)
for node in selectionNodes:
	try:
		attribute1 =node+"_translateX.output"
		attribute2 =node+".translateX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass
	

	try:
		attribute1 =node+"_translateY.output"
		attribute2 =node+".translateY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_translateZ.output"
		attribute2 =node+".translateZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateX.output"
		attribute2 =node+".rotateX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateY.output"
		attribute2 =node+".rotateY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateZ.output"
		attribute2 =node+".rotateZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleX.output"
		attribute2 =node+".scaleX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleY.output"
		attribute2 =node+".scaleY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleZ.output"
		attribute2 =node+".scaleZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass