Last active
March 2, 2021 09:32
-
-
Save whaison/9e6057eabecc0a3b04361c0fa938861b to your computer and use it in GitHub Desktop.
rig_to_joint_bakemotion_fbx_v11_move_value_zero_start_wrightErrorCatch_fix_ProcNum.mel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rig_to_joint_bakemotion_fbx_v11_move_value_zero_start(); | |
global proc rig_to_joint_bakemotion_fbx_v11_move_value_zero_start() | |
{ | |
rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset(); | |
//rig_to_joint_bakemotion_fbx_11_main(); | |
} | |
//010 開始フレームを0フレームにする。 rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset(); | |
//020 参照してるリファレンス達をループしてファイルにインポートする。1 rig_to_joint_bakemotion_fbx_v1103_proc020_referenceImport() | |
//031 OriginalJointの取得と選択 rig_to_joint_bakemotion_fbx_v1103_proc030_selectOriginalJoint() | |
//040 ジョイントに移動XYZ回転XYZをベイク rig_to_joint_bakemotion_fbx_v1103_proc040_selectedJointBakeTranslateXYZRotateXYZ() | |
//040 | |
//041 拡大縮小のジョイントがあった場合ベイク rig_to_joint_bakemotion_fbx_v1103_proc041_selectedJointBakeScaleXYZ() | |
//050 ベイクした骨がジンバル回転ロックしないようオイラーフィルタ rig_to_joint_bakemotion_fbx_v1103_proc050_RotateUnLockEulerFilter() | |
//060 不要なノードの削除、delete 空のレイヤも削除 rig_to_joint_bakemotion_fbx_v1103_proc060_DeleteDustNode() string $reference[] = `file -q -reference -shortName`; | |
//061 シーンサイズの最適化 rig_to_joint_bakemotion_fbx_v1103_proc061_cleanUpScene(); cleanUpScene (3); | |
//063 リファレンスファイルにインポートする。これをしないとリファレンス参照が邪魔して読み取り専用のノードの名前は変更できません。 rig_to_joint_bakemotion_fbx_v1103_proc063_referenceImport2() | |
//065 ネームスペースの削除 rig_to_joint_bakemotion_fbx_v1103_proc065_DeleteNameSpace2() | |
//068 rename拡張のチェックと新ネーム設定 rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck(string $renameObj ,string $newname ,string $procName) | |
//071 エクスポーター設定 rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting() | |
//074 OriginalJointの取得と選択 rig_to_joint_bakemotion_fbx_v1103_proc074_selectOriginalJoint() | |
//077 先頭文字プレフィックスを削除 rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix() | |
//080 RootノードのZ出力 rig_to_joint_bakemotion_fbx_v1103_proc080_RootTranslateXZoutput() | |
//081 RootXZの移動キー削除 rig_to_joint_bakemotion_fbx_v1103_proc081_RootTranslateXZdeleteKeyframe() | |
//082 FBX保存 rig_to_joint_bakemotion_fbx_v1103_proc082_FbxExport() | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset() | |
{//010 開始フレームを0フレームにする。 | |
string $ObjTranslateXStr= "Root.translateZ"; | |
int $plusMinus=1; | |
print("===========================rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset===ReadRootValueToArrOutStr($ObjTranslateXStr= "+$ObjTranslateXStr+" $plusMinus="+$plusMinus+")================================Start\n"); | |
//int $startFrameInt =`findKeyframe -which first`; | |
int $startFrameInt =`playbackOptions -query -minTime`; | |
//int $nextFrameInt =`findKeyframe -timeSlider -which next`; | |
int $endFrameInt=0; | |
//$endFrameInt = `findKeyframe -which last`; | |
$endFrameInt = `playbackOptions -query -maxTime`; | |
int $OldFrameInt=$startFrameInt-0; | |
int $NowFrameInt=$startFrameInt-0; | |
float $OldFrameZ=0; | |
float $NowFrameZ=0; | |
//selectKey -add -k -t 0 Root_translateZ ; | |
// keyframe -time $NowFrame ; | |
//keyframe -time | |
print("===rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset===ReadRootValueToArrOutStr ループ回数 $endFrameInt="+$endFrameInt+" 引く $startFrameInt= "+$startFrameInt+" \n"); | |
int $nodesLength =$endFrameInt-$startFrameInt; | |
print("===rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset===ReadRootValueToArrOutStr ループ回数 $nodesLength="+$nodesLength+"\n"); | |
int $i; | |
string $RootTranslateZStr="Root.translateZ"; | |
$RootTranslateZStr=$ObjTranslateXStr;//引数つっこむ | |
string $outputStr=""; | |
print("===rig_to_joint_bakemotion_fbx_v1103_proc010_init_offset===ReadRootValueToArrOutStr ループ回数 for ($i = $startFrameIntつまり "+$startFrameInt+"からループはじめて ; $i < $nodesLength "+$nodesLength+"になるまでループするよ; $i++ ) "+"\n"); | |
if($startFrameInt<$nodesLength) | |
{ | |
print("ループが走るとき \n"); | |
}else{ | |
print("ループが回らないとき \n"); | |
int $offsetInt=-1*$startFrameInt; | |
offsetAllAnimation($offsetInt); | |
int $new_startFrameint=$startFrameInt+$offsetInt; | |
int $new_endFrameint=$endFrameInt+$offsetInt; | |
playbackOptions -edit -minTime $new_startFrameint; | |
playbackOptions -edit -maxTime $new_endFrameint; | |
currentTime 0; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc020_referenceImport(); | |
}////010 開始フレームを0フレームにする。 | |
string $reference[];//global stringArr[] | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc020_referenceImport() | |
{//020 参照してるリファレンス達をループしてファイルにインポートする。 | |
global string $reference[]; | |
//まず先に読めるリファレンスは全部ロードしちゃう | |
$reference={"0","0"};//global stringArr[]初期化 | |
print("//file -importReference はじめるよ\n"); | |
$reference = `file -q -reference -shortName`; | |
print("-----$reference[]---------"+"\n"); | |
print($reference); | |
print("\n"); | |
print("-----$reference[]---------"+"\n"); | |
int $countRef = 0; | |
int $refMax =size($reference); | |
for ( $countRef = $refMax-1; $countRef >= 0; $countRef-- ) { | |
print("$reference["+$countRef+"]= "+$reference[$countRef]+"\n"); | |
// file -open $reference[$count5]; | |
if(`file -q -writable`=="1"){ | |
if($countRef<0){ | |
print("ばーかマイナス1だよ\n"); | |
}else{ | |
file -importReference $reference[$countRef]; | |
} | |
}//if | |
//$count5--; | |
};//for | |
print("//file -importReference おわったよ\n"); | |
rig_to_joint_bakemotion_fbx_v1103_proc030_selectOriginalJoint(); | |
}//020 参照してるリファレンス達をループしてファイルにインポートする。 | |
string $Joints[]; //global stringArr[] | |
string $JointsGroup; | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc030_selectOriginalJoint() | |
{ //031 OriginalJointの取得と選択 | |
///////////////////////////////////////////////////////joint select | |
// select -cl; | |
string $joint=""; | |
string $joints[] =`ls -type joint`; | |
//for ($joint in `ls -type joint`) | |
print("-------------------------joint-----------------------------"+"\n"); | |
print($joints); | |
print ("\n-------------------------joint-----------------------------"+"\n"); | |
int $jointsLength=size($joints); | |
if($jointsLength==0) | |
{ | |
print ("\n-------------------------jointないよーーーーー-----------------------------"+"\n"); | |
}else{ | |
for ($joint in $joints) | |
{ | |
for($attr in `listAttr -k $joint`) | |
{ | |
float $keys[] = `keyframe -q -timeChange ($joint + "." + $attr)`; | |
if (`size $keys`>0){ | |
select -add $joint; | |
}; | |
} | |
} | |
} | |
print("-------------------------joint-----------------------------"+"\n"); | |
print($joint); | |
print ("\n-------------------------joint-----------------------------"+"\n"); | |
if($joint=="") | |
{ | |
print ("\n-------------------------jointないよーーーーーそりゃえらーだよ-----------------------------"+"\n"); | |
} | |
////////////////////////////////////////////////////////joint select; | |
//OriginalJointの取得と選択 | |
global string $JointsGroup;//global stringArr | |
$JointsGroup = "*:" + "*:" + "*"; | |
select -replace $JointsGroup; | |
select -hierarchy; | |
select -deselect `ls -type joint`; | |
string $NotJoints[] = `ls -selection`; | |
select -replace $JointsGroup; | |
select -hierarchy; | |
select -deselect $NotJoints; | |
global string $Joints[]; //global stringArr[] | |
$Joints = `ls -selection`; //global input | |
//print("$Joints------------------------------start-----"+"\n"); | |
//print($Joints); | |
//print("$Joints-----------------------------end-------"+"\n"); | |
rig_to_joint_bakemotion_fbx_v1103_proc040_selectedJointBakeTranslateXYZRotateXYZ(); | |
} //031 OriginalJointの取得と選択 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc040_selectedJointBakeTranslateXYZRotateXYZ() | |
{ //040 ジョイントに移動XYZ回転XYZをベイク | |
// 結果: test_ian01_rig:ian_model:Head test_ian01_rig:ian_model:Hip test_ian01_rig:ian_model:L_Skirt_f1 test_ian01_rig:ian_model:L_Skirt_f2 test_ian01_rig:ian_model:L_Skirt_f3 test_ian01_rig:ian_model:L_Skirt_s1 test_ian01_rig:ian_model:L_Skirt_s2 test_ian01_rig:ian_model:L_Skirt_s3 test_ian01_rig:ian_model:L_Skirt_u1 test_ian01_rig:ian_model:L_Skirt_u2 test_ian01_rig:ian_model:L_Skirt_u3 test_ian01_rig:ian_model:L_hear_1_1 test_ian01_rig:ian_model:L_hear_1_2 test_ian01_rig:ian_model:L_hear_2 test_ian01_rig:ian_model:LeftArm test_ian01_rig:ian_model:LeftFoot test_ian01_rig:ian_model:LeftForeArm test_ian01_rig:ian_model:LeftHand test_ian01_rig:ian_model:LeftHand_Weapon test_ian01_rig:ian_model:LeftLeg test_ian01_rig:ian_model:LeftShoulder test_ian01_rig:ian_model:LeftToe test_ian01_rig:ian_model:LeftUpLeg test_ian01_rig:ian_model:Neck test_ian01_rig:ian_model:R_Skirt_f1 test_ian01_rig:ian_model:R_Skirt_f2 test_ian01_rig:ian_model:R_Skirt_f3 test_ian01_rig:ian_model:R_Skirt_s1 test_ian01_rig:ian_model:R_Skirt_s2 test_ian01_rig:ian_model:R_Skirt_s3 test_ian01_rig:ian_model:R_Skirt_u1 test_ian01_rig:ian_model:R_Skirt_u2 test_ian01_rig:ian_model:R_Skirt_u3 test_ian01_rig:ian_model:R_hear_1_1 test_ian01_rig:ian_model:R_hear_1_2 test_ian01_rig:ian_model:R_hear_2 test_ian01_rig:ian_model:RightArm test_ian01_rig:ian_model:RightFoot test_ian01_rig:ian_model:RightForeArm test_ian01_rig:ian_model:RightHand test_ian01_rig:ian_model:RightHand_Weapon test_ian01_rig:ian_model:RightLeg test_ian01_rig:ian_model:RightShoulder test_ian01_rig:ian_model:RightToe test_ian01_rig:ian_model:RightUpLeg test_ian01_rig:ian_model:Root test_ian01_rig:ian_model:Spine1 test_ian01_rig:ian_model:Spine2 test_ian01_rig:ian_model:U_hear_1_1 test_ian01_rig:ian_model:U_hear_1_2 test_ian01_rig:ian_model:U_hear_1_3 test_ian01_rig:ian_model:U_hear_2 test_ian01_rig:ian_model:bust test_ian01_rig:weapon:wep_bigshooter_bone test_ian01_rig:weapon:wep_flail_bone test_ian01_rig:weapon:wep_flail_bone1 test_ian01_rig:weapon:wep_flail_bone2 test_ian01_rig:weapon:wep_flail_bone3 test_ian01_rig:weapon:wep_flail_bone4 test_ian01_rig:weapon:wep_flail_bone5 test_ian01_rig:weapon:wep_grapple_bone test_ian01_rig:weapon:wep_katana_bone test_ian01_rig:weapon:wep_longpaul_bone test_ian01_rig:weapon:wep_rod_bone test_ian01_rig:weapon:wep_saya_bone test_ian01_rig:weapon:wep_shield_bone test_ian01_rig:weapon:wep_shooter_bone test_ian01_rig:weapon:wep_throwing_bone test_ian01_rig:weapon:wep_twinrod_bone test_ian01_rig:weapon:wep_yumi_bone test_ian01_rig:weapon1:wep_bigshooter_bone test_ian01_rig:weapon1:wep_flail_bone test_ian01_rig:weapon1:wep_flail_bone1 test_ian01_rig:weapon1:wep_flail_bone2 test_ian01_rig:weapon1:wep_flail_bone3 test_ian01_rig:weapon1:wep_flail_bone4 test_ian01_rig:weapon1:wep_flail_bone5 test_ian01_rig:weapon1:wep_grapple_bone test_ian01_rig:weapon1:wep_katana_bone test_ian01_rig:weapon1:wep_longpaul_bone test_ian01_rig:weapon1:wep_rod_bone test_ian01_rig:weapon1:wep_saya_bone test_ian01_rig:weapon1:wep_shield_bone test_ian01_rig:weapon1:wep_shooter_bone test_ian01_rig:weapon1:wep_throwing_bone test_ian01_rig:weapon1:wep_twinrod_bone test_ian01_rig:weapon1:wep_yumi_bone // | |
string $min = `playbackOptions -query -min`; | |
string $max = `playbackOptions -query -max`; | |
string $timeTotime=$min+":"+$max; | |
// 結果: 0:30 // | |
bakeResults -simulation true -t ($min+":"+$max) -at "tx" -at "ty" -at "tz" -at "rx" -at "ry" -at "rz"; | |
// 結果: 522 // | |
//スケールにキーが入っている骨のベイク | |
rig_to_joint_bakemotion_fbx_v1103_proc041_selectedJointBakeScaleXYZ(); | |
} //040 ジョイントに移動XYZ回転XYZをベイク | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc041_selectedJointBakeScaleXYZ() | |
{ //041 拡大縮小のジョイントがあった場合ベイク | |
if(`file -q -writable`=="1") | |
{ | |
string $ScaleJoints[]; | |
int $count3 = 0; | |
int $count4 = 0; | |
global string $Joints[]; //global stringArr[] | |
for($tmp3 in $Joints) | |
{ | |
if(`objExists ($Joints[$count3] + "_scaleConstraint1")`) | |
{ | |
$ScaleJoints[$count4] = $Joints[$count3]; | |
$count4++; | |
} | |
$count3++; | |
} | |
if(`size($ScaleJoints)` > 0) | |
{ | |
select -r $ScaleJoints; | |
string $min = `playbackOptions -query -min`; | |
string $max = `playbackOptions -query -max`; | |
bakeResults -simulation true -t ($min+":"+$max) | |
-at "sx" -at "sy" -at "sz"; | |
}; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc050_RotateUnLockEulerFilter(); | |
} //041 拡大縮小のジョイントがあった場合ベイク | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc050_RotateUnLockEulerFilter() | |
{ //050 ベイクした骨がジンバル回転ロックしないようオイラーフィルタ | |
//ベイクした骨にオイラーフィルターをかける | |
if(`file -q -writable`=="1"){ | |
int $count = 0; | |
string $debugstr=""; | |
global string $Joints[]; //global stringArr[] | |
int $JointLength=`size $Joints`; | |
// print("------------$JointLength="+$JointLength+"-------------------\n"); | |
for($count = 0; $count <$JointLength;$count++){ | |
// print("------------$Joints["+$count+"]-------------------\n"); | |
//print("------------$Joints["+$count+"]="+$Joints[$count]+"-------------------\n"); | |
//filterCurve ($Joints[$count] + "_rotateX") ($Joints[$count] + "_rotateY") ($Joints[$count] + "_rotateZ"); | |
filterCurve ($Joints[$count] + ".rotateX") ($Joints[$count] + ".rotateY") ($Joints[$count] + ".rotateZ"); | |
// print("------------$Joints["+$count+"]-------------------\n"); | |
}; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc060_DeleteDustNode(); | |
} //050 ベイクした骨がジンバル回転ロックしないようオイラーフィルタ | |
string $delname[]; | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc060_DeleteDustNode() | |
{ //060 不要なノードの削除、delete 空のレイヤも削除 | |
//不要なノードの削除、 | |
global string $delname[]; | |
global string $reference[]; | |
$reference[0] = `tokenize $reference[0] "_" $delname`; | |
int $numTokens = `tokenize $reference[0] "_" $delname`; | |
print("-----$delname[]---------"+"\n"); | |
print($delname); | |
print("\n"); | |
print("-----$delname[]---------"+"\n"); | |
if(`file -q -writable`=="1"){ | |
select -allDagObjects; | |
global string $JointsGroup;//global stringArr | |
select -d $JointsGroup; | |
delete; | |
deleteEmptyAnimLayers; | |
select -allDagObjects; | |
select -hi; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc061_cleanUpScene(); | |
} //060 不要なノードの削除、delete 空のレイヤも削除 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc061_cleanUpScene() | |
{ //070 シーンサイズの最適化 | |
//シーンサイズの最適化 | |
//C:\Program Files\Autodesk\Maya2016\scripts\others\performPolyOptimizeUV.mel | |
//performPolyOptimizeUV(1); | |
//シーンサイズの最適化 | |
//C:\Program Files\Autodesk\Maya2016\scripts\startup\cleanUpScene.mel | |
if(`file -q -writable`=="1"){ | |
cleanUpScene (3); | |
} | |
//rig_to_joint_bakemotion_fbx_v1103_proc080_RootTranslateXZoutput(); | |
if(`file -q -writable`=="1"){ | |
//リファレンスノードだからプリフィックス追加できません | |
//シーンサイズの最適化しないと リファレンスが消えないです。 | |
rig_to_joint_bakemotion_fbx_v1103_proc063_referenceImport2(); | |
} | |
} //070 シーンサイズの最適化 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc063_referenceImport2() | |
{//020 参照してるリファレンス達をループしてファイルにインポートする。 | |
//エラー: 読み取り専用のノードの名前は変更できません。を回避するため | |
// | |
if(`file -q -writable`=="1"){ | |
//先に全部リファレンスをロードする//////////////////////////////////////////////////////////////////////// | |
//file -loadReference -loadReferenceDepth all; | |
//file -loadReference; | |
//file -open -loadAllReferences; | |
string $sceneName=`file -q -sceneName`; | |
print("$sceneName= "+$sceneName+"\n"); | |
string $referenceArr[] =`file -q -reference $sceneName`; | |
print("-----------referenceArr-----------OK "+"\n"); | |
print($referenceArr); | |
print("\n"+"-----------referenceArr-----------OK "+"\n"); | |
print("親のリファレンスのファイル名 $referenceArr[0]="+$referenceArr[0]+"\n"); | |
int $referenceArrlength=`size($referenceArr)`; | |
print("\n"+"-----------$referenceArrlength-----------OK "+$referenceArrlength+"\n"); | |
for ( $i = 0 ; $i < $referenceArrlength ; $i++ ) { | |
//先にリファレンスのファイルがあるか確認する。 | |
fileTestCheckAndLoad($referenceArr[$i]); | |
string $referenceChileArr[] =`file -q -reference $referenceArr[$i]`; | |
print("-----------referenceChileArr-----------"+"\n"); | |
print($referenceChileArr); | |
print("\n"+"-----------referenceChileArr-----------"+"\n"); | |
int $referenceChildArrlength=`size($referenceChileArr)`; | |
print("\n"+"-----------referenceChildArrlength-----------"+$referenceChildArrlength+"\n"); | |
for ( $j = 0 ; $j < $referenceChildArrlength ; $j++ ) { | |
print("-----------referenceChileArr-for" +$j+"\n"); | |
//先にリファレンスのファイルがあるか確認する。 | |
fileTestCheckAndLoad($referenceChileArr[$j]); | |
} | |
}; | |
int $referenceArrlength=`size($referenceArr)`; | |
print("\n"+"-----------$referenceArrlength-----------OK "+$referenceArrlength+"\n"); | |
for ( $i = 0 ; $i < $referenceArrlength ; $i++ ) { | |
//先にリファレンスのファイルがあるか確認する。 | |
fileTestCheckAndLoad($referenceArr[$i]); | |
string $referenceChileArr[] =`file -q -reference $referenceArr[$i]`; | |
print("-----------referenceChileArr-----------"+"\n"); | |
print($referenceChileArr); | |
print("\n"+"-----------referenceChileArr-----------"+"\n"); | |
int $referenceChildArrlength=`size($referenceChileArr)`; | |
print("\n"+"-----------referenceChildArrlength-----------"+$referenceChildArrlength+"\n"); | |
for ( $j = 0 ; $j < $referenceChildArrlength ; $j++ ) { | |
print("-----------referenceChileArr-for" +$j+"\n"); | |
//先にリファレンスのファイルがあるか確認する。 | |
fileTestCheckAndLoad($referenceChileArr[$j]); | |
} | |
} | |
} | |
string $motionfileName;//ここの外部グローバル変数にアクセスしたい。 | |
//if(`file -q -writable`=="1"){ | |
//不要なノードの削除、ネームスペースの削除 | |
print("//file -importReference はじめるよ\n"); | |
string $reference[] = `file -q -reference -shortName`; | |
print("-----$reference[]---------"+"\n"); | |
print($reference); | |
print("\n"); | |
print("-----$reference[]---------"+"\n"); | |
int $countRef = 0; | |
int $refMax =size($reference); | |
for ( $countRef = $refMax-1; $countRef >= 0; $countRef-- ) { | |
print("$reference["+$countRef+"]= "+$reference[$countRef]+"\n"); | |
// file -open $reference[$count5]; | |
if(`file -q -writable`=="1"){ | |
if($countRef<0){ | |
print("ばーかマイナス1だよ\n"); | |
}else{ | |
file -importReference $reference[$countRef]; | |
} | |
}//if | |
//$count5--; | |
};//for | |
print("//file -importReference おわったよ\n"); | |
///////////////////////////////////////////////////////////////////// | |
///////////////////////////選択select/////////////////////////////////// | |
//select -r $JointsGroup; | |
select -allDagObjects; | |
select -hi; | |
print(`ls -sl`); | |
//////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////// | |
//} | |
rig_to_joint_bakemotion_fbx_v1103_proc065_DeleteNameSpace2(); | |
}//020 参照してるリファレンス達をループしてファイルにインポートする。 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc065_DeleteNameSpace2() | |
{ print("//062 ネームスペースの削除 \n"); | |
//ネームスペースの削除 | |
if(`file -q -writable`=="1"){ | |
string $rename[] = `ls -sl`; | |
int $count2 = 0; | |
for($tmp2 in $rename) | |
{ | |
if(`file -q -writable`=="1"){ | |
string $getname = $rename[$count2]; | |
print("$getname= "+$getname+"\n"); | |
/* | |
int $gatnameboolint=`gmatch $getname "*|*"`; | |
if($gatnameboolint==1) | |
{ | |
print("| ぼうあるよ \n"); | |
string $gatnameArr[]; | |
$numTokens123 = `tokenize $getname "|" $gatnameArr`; | |
int $gatnameArrLength=size($gatnameArr); | |
for ( $g = 0 ; $g < $gatnameArrLength ; $g++ ) { | |
print("$gatnameArr[$g]= "+$gatnameArr[$g]+"\n"); | |
global string $delname[]; | |
string $newname = substituteAllString($gatnameArr[$g],($delname[0] + "_rig:" + $delname[0] + ":"),""); | |
print("$newname= "+$newname+"\n"); | |
//MELで特定の名前のオブジェクトが存在するか検査する//http://www52.atwiki.jp/fumiduki1985/pages/70.html | |
if(`objExists $gatnameArr[$g]`) | |
{ | |
print("$gatnameArr[$g]= "+$gatnameArr[$g]+" あるので実行するよ"+"\n"); | |
if($newname!=$gatnameArr[$g]) | |
{ | |
print("$gatnameArr[$g]= "+$gatnameArr[$g]+" なまえがしゅうせいの必要ないのでやらないよ"+"\n"); | |
//rename -is $gatnameArr[$g] $newname; | |
rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck( $gatnameArr[$g] ,$newname); | |
} | |
} | |
} | |
}else | |
*/ | |
{ | |
//print ("substituteAllString("+"$getname="+$getname+",($delname[0]="+$delname[0] + "_rig: $delname[0]=" + $delname[0] + ":)) \n"); | |
global string $delname[]; | |
string $newname = substituteAllString($getname,($delname[0] + "_rig:" + $delname[0] + ":"),""); | |
print("$newname= "+$newname+"\n"); | |
// | |
print("■■■■■■■■■■■■■名前変えます これ >>$rename[$count2="+$count2+"]= "+$rename[$count2]+"\n"); | |
rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck( $rename[$count2] ,$newname,"rig_to_joint_bakemotion_fbx_v1103_proc062_DeleteNameSpace"); | |
} | |
$count2++; | |
}//if(`file -q -writable`=="1"){ | |
}; | |
} | |
print("062 ネームスペースの削除 終わった \n"); | |
rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting(); | |
} //062 ネームスペースの削除 | |
//global | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck(string $renameObj ,string $newname ,string $procName) | |
{ | |
string $resultNameList[]; | |
int $errorPattern; | |
string $errorPatternString[]; | |
$errorPatternString[0]=""; | |
$errorPatternString[1]="別階層に同名存在(リネーム時の瞬間)"; | |
$errorPatternString[2]="システムが自動的にリネーム"; | |
$errorPatternString[12]="同じ為変更なし"; | |
$errorPatternString[13]="空白の為変更なし"; | |
$errorPatternString[14]="有効名でない為変更なし"; | |
$errorPatternString[15]="デフォルトノードの為変更なし"; | |
$errorPatternString[16]="リファレンスの為変更なし"; | |
$errorPatternString[17]="ロックされたノードの為変更なし"; | |
$errorPatternString[10]="存在しないので除外"; | |
int $ReadOnlyObjError= 0 ; | |
if(!objExists($renameObj)) | |
{ | |
$errorPattern=10; | |
print "存在なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
if($renameObj == $newname) | |
{ | |
$errorPattern=12; | |
print "同じ為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
if(endsWith ($renameObj , ("|"+$newname) )) | |
{ | |
$errorPattern=12; | |
print "同じ為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
if($newname=="%" || $newname=="") | |
{ | |
$errorPattern=13; | |
print "空白のため変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
if(0==isValidObjectName($newname)) | |
{ | |
$errorPattern=14; | |
print "有効名でない為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
if(defaultNodeNameRenamer_unRenameNode($renameObj)) | |
{ | |
$errorPattern =15; | |
print "デフォルトノードの為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
string $referencedList[]=`ls -rn -sl`; | |
if(stringArrayContains($renameObj,$referencedList)) | |
{ | |
$errorPattern=16; | |
print "リファレンスの為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
int $lockTrue[]=`lockNode -q -l $renameObj`; | |
if($lockTrue[0]) | |
{ | |
$errorPattern=17; | |
print "ロックされたノードの為変更なし\n"; | |
//continue; | |
$ReadOnlyObjError= 1 ; | |
} | |
//■■■■■■■■■■■■■■■■■■■■■■■ 実行 ■■■■■■■■■■■■■■■■■■■■■■■■■ | |
if($ReadOnlyObjError== 0) | |
{ | |
//if ( catch ($resultName=`rename $renameObj $newname`) ) | |
if ( catchQuiet ($resultName=`rename $renameObj $newname`) ) | |
{ | |
print("416出ちゃったよーー 読み取り専用のノードの名前は変更できません。$procName="+$procName+"\n"); | |
if($procName == "rig_to_joint_bakemotion_fbx_v1103_proc062_DeleteNameSpace") | |
{ | |
//print("もう一回 実行するよ rig_to_joint_bakemotion_fbx_v1103_proc062_DeleteNameSpace()"); | |
//rig_to_joint_bakemotion_fbx_v1103_proc062_DeleteNameSpace(); | |
print("もう次いくわよ rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting()"); | |
rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting(); | |
} | |
if($procName == "rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix") | |
{ | |
//print("rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix()"); | |
//rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix(); | |
print("rig_to_joint_bakemotion_fbx_v1103_proc070_cleanUpScene()"); | |
rig_to_joint_bakemotion_fbx_v1103_proc070_cleanUpScene(); | |
} | |
print("もう一回やれてる?"); | |
} | |
//$resultName=`rename $renameObj $newname`; | |
//$resultNameList[$i]=$resultName; | |
print ($renameObj+" >>> "+$resultName+"\n"); | |
} | |
//■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | |
/* | |
if($newname == $resultName) | |
{ | |
$errorPattern =0; | |
} | |
else | |
{ | |
if(endsWith ($resultName , ("|"+$newname) )){ | |
$errorPattern =1; | |
} | |
else | |
{ | |
$errorPattern =2; | |
} | |
*/ | |
}//rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck end | |
global proc int defaultNodeNameRenamer_unRenameNode(string $name){ | |
int $unRenameTrue=0; | |
string $unRenameNode[]={ | |
"time1", | |
"sequenceManager1", | |
"renderPartition", | |
"renderGlobalsList1", | |
"defaultLightList1", | |
"defaultShaderList1", | |
"postProcessList1", | |
"defaultRenderUtilityList1", | |
"defaultRenderingList1", | |
"lightList1", | |
"defaultTextureList1", | |
"lambert1", | |
"particleCloud1", | |
"initialShadingGroup", | |
"initialParticleSE", | |
"initialMaterialInfo", | |
"shaderGlow1", | |
"dof1", | |
"defaultRenderGlobals", | |
"defaultRenderQuality", | |
"defaultResolution", | |
"defaultLightSet", | |
"defaultObjectSet", | |
"defaultViewColorManager", | |
"hardwareRenderGlobals", | |
"hardwareRenderingGlobals", | |
"characterPartition", | |
"defaultHardwareRenderGlobals", | |
"ikSystem", | |
"hyperGraphInfo", | |
"hyperGraphLayout", | |
"globalCacheControl", | |
"strokeGlobals", | |
"dynController1", | |
"persp", | |
"perspShape", | |
"top", | |
"topShape", | |
"front", | |
"frontShape", | |
"side", | |
"sideShape", | |
"lightLinker1", | |
"DefaultMaterialsAndShaderGlowFilter7", | |
"selectionListOperator84", | |
"DefaultMaterialsFilter9", | |
"DefaultShaderGlowFilter9", | |
"objectTypeFilter96", | |
"layerManager", | |
"defaultLayer", | |
"renderLayerManager", | |
"defaultRenderLayer" | |
}; | |
$unRenameTrue=stringArrayContains($name,$unRenameNode); | |
return $unRenameTrue; | |
} | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting() | |
{ //063 エクスポーター設定 | |
//エクスポーター設定 | |
if(`file -q -writable`=="1"){ | |
string $allnode[] = `ls -sl`; | |
print("$allnode------------------------------start-----"+"\n"); | |
print($allnode); | |
print("$allnode-----------------------------end-------"+"\n"); | |
select -replace `listTransforms -lights`; | |
select -hierarchy; | |
string $Lights[] = `ls -sl`; | |
print("$Lights------------------------------start-----"+"\n"); | |
print($Lights); | |
print("$Lights-----------------------------end-------"+"\n"); | |
select -replace $allnode; | |
select -deselect $Lights; | |
string $topnode[] = `ls -sl -showType`; | |
print("rig_to_joint_bakemotion_fbx_v1103_proc071_ExportSetting(() $topnode[0]="+$topnode[0]+"\n"); | |
print("$topnode------------------------------start-----"+"\n"); | |
print($topnode); | |
print("$topnode-----------------------------end-------"+"\n"); | |
select -replace $topnode[0]; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc074_selectOriginalJoint(); | |
} //063 エクスポーター設定 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc074_selectOriginalJoint() | |
{ //064 OriginalJointの取得と選択 | |
if(`file -q -writable`=="1"){ | |
//OriginalJointの取得と選択 | |
string $JointsGroup = "*:" + "*:" + "*"; | |
select -replace $JointsGroup; | |
select -hierarchy; | |
select -deselect `ls -type joint`; | |
string $NotJoints[] = `ls -sl`; | |
select -replace $JointsGroup; | |
select -hierarchy; | |
select -deselect $NotJoints; | |
string $Joints[] = `ls -sl`; | |
print("$Joints------------------------------start-----"+"\n"); | |
print($Joints); | |
print("$Joints-----------------------------end-------"+"\n"); | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix(); | |
} //064 OriginalJointの取得と選択 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix() | |
{ //065 先頭文字プレフィックスを削除 | |
///////////////////////////////////////////////////////////////////// | |
///////////////////////////選択select/////////////////////////////////// | |
//select -r $JointsGroup; | |
select -allDagObjects; | |
select -hi; | |
print(`ls -sl`); | |
//////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////// | |
if(`file -q -writable`=="1"){ | |
string $prefix =""; | |
string $currentNodes[] = eval("listRelatives -pa -ad `ls -sl -l`"); | |
print("$currentNodes="+"\n"); | |
print($currentNodes); | |
print("$currentNodes_end"+"\n"); | |
if ( size( $currentNodes ) > 0 ) { | |
for( $i=0; $i < size( $currentNodes ); $i++ ) { | |
if(`file -q -writable`=="1"){ | |
prefixNode( $prefix, $currentNodes[$i] ); | |
} | |
} | |
} | |
$currentNodes = `ls -sl -l`; | |
if ( size( $currentNodes ) > 0 ) { | |
for( $i=0; $i < size( $currentNodes ); $i++ ) { | |
if(`file -q -writable`=="1"){ | |
prefixNode( $prefix, $currentNodes[$i] ); | |
} | |
} | |
}; | |
} | |
// エラー: line 10: プロシージャ "prefixNode" が見つかりません。 // | |
string $prefix =""; | |
string $currentNodes[] = eval("listRelatives -pa -ad `ls -sl -l`"); | |
print("$currentNodes="+"\n"); | |
print($currentNodes); | |
print("$currentNodes_end"+"\n"); | |
if ( size( $currentNodes ) > 0 ) { | |
for( $i=0; $i < size( $currentNodes ); $i++ ) { | |
if(`file -q -writable`=="1"){ | |
prefixNode( $prefix, $currentNodes[$i] ); | |
} | |
} | |
} | |
$currentNodes = `ls -sl -l`; | |
if ( size( $currentNodes ) > 0 ) { | |
for( $i=0; $i < size( $currentNodes ); $i++ ) { | |
if(`file -q -writable`=="1"){ | |
prefixNode( $prefix, $currentNodes[$i] ); | |
} | |
} | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc080_RootTranslateXZoutput(); | |
} //065 先頭文字プレフィックスを削除 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc080_RootTranslateXZoutput() | |
{ //080 RootノードのZ出力 | |
//RootノードのZ出力と消し | |
//root_move_text_v11(); | |
// エラー: line 3: プロシージャ "root_move_text_v12" が見つかりません。 // | |
//RootノードのZ出力と消し | |
//root_move_text_v11(); | |
//if(`file -q -writable`=="1"){ | |
print("===============================root_move_text_v12()==============================Start"); | |
// global string $fbxfilepath;//外部グローバルの変数とってくる。 | |
string $path = (`file -q -sn`); | |
//$path=$fbxfilepath; | |
//$path=$fullpath; | |
print ("$path= "+$path); | |
// 結果: D:/work/3D/motion/test_ian01/scenes/motion/motion_000_attack.mb // | |
string $dirarr[]; | |
$numTokens = `tokenize $path "/" $dirarr`; | |
int $dirLength=size($dirarr); | |
string $filename=$dirarr[$dirLength-1]; | |
print("$filename= "+$filename+"\n"); | |
////////////////motionname | |
string $filenames[]; | |
$numTokens2 = `tokenize $dirarr[$dirLength-1] "." $filenames`; | |
//global string $motionName1;//外部グローバルの変数とってくる。 | |
//string $motionName1;//外部グローバルの変数とってくる。 | |
string $motionName1=$filenames[0]; | |
print("$motionName1= "+$motionName1+"\n"); | |
string $Root_Z_output=""; | |
string $RootReadWay="Root.translateZ"; | |
int $plusMinus=1; | |
if(`gmatch $motionName1 "*left*"`==1) | |
{ | |
print(" ひだり だよ! \n"); | |
$RootReadWay="Root.translateX"; | |
//$plusMinus=1; | |
}else if(`gmatch $motionName1 "*Left*"`==1) | |
{ | |
print(" ひだり だよ! \n"); | |
$RootReadWay="Root.translateX"; | |
//$plusMinus=1; | |
}else if(`gmatch $motionName1 "*right*"`==1) | |
{ | |
print("みぎ だよ! \n"); | |
$RootReadWay="Root.translateX"; | |
//$plusMinus=-1; | |
}else if(`gmatch $motionName1 "*Right*"`==1) | |
{ | |
print("みぎ だよ! \n"); | |
$RootReadWay="Root.translateX"; | |
//$plusMinus=-1; | |
}else if(`gmatch $motionName1 "*front*"`==1) | |
{ | |
print("まえ だよ! \n"); | |
$RootReadWay="Root.translateZ"; | |
//$plusMinus=1; | |
}else if(`gmatch $motionName1 "*Front*"`==1) | |
{ | |
print("まえ だよ! \n"); | |
$RootReadWay="Root.translateZ"; | |
//$plusMinus=1; | |
}else if(`gmatch $motionName1 "*back*"`==1) | |
{ | |
print(" うしろ だよ! \n"); | |
$RootReadWay="Root.translateZ"; | |
//$plusMinus=-1; | |
}else if(`gmatch $motionName1 "*Back*"`==1) | |
{ | |
print(" うしろ だよ! \n"); | |
$RootReadWay="Root.translateZ"; | |
//$plusMinus=-1; | |
}else{ | |
print("指定なしデフォルトの向きだよ。$RootReadWay="+$RootReadWay); | |
} | |
int $DoFuncInt=0; | |
if(`gmatch $motionName1 "*Walk*"`==1) | |
{ | |
print("歩きだよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*walk*"`==1) | |
{ | |
print("歩きだよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Run*"`==1) | |
{ | |
print("はしり だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*run*"`==1) | |
{ | |
print("はしり だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Step*"`==1) | |
{ | |
print("step だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*step*"`==1) | |
{ | |
print("step だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Ukemi*"`==1) | |
{ | |
print("ukemi だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*ukemi*"`==1) | |
{ | |
print("ukemi だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Attack*"`==1) | |
{ | |
print("attack だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*attack*"`==1) | |
{ | |
print("attack だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Atk*"`==1) | |
{ | |
print("attack だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*atk*"`==1) | |
{ | |
print("attack だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Skill*"`==1) | |
{ | |
print("skill だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*skill*"`==1) | |
{ | |
print("skill だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*crit*"`==1) | |
{ | |
print("Critical だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Crit*"`==1) | |
{ | |
print("Critical だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*Critical*"`==1) | |
{ | |
print("Critical だよ! \n"); | |
$DoFuncInt=1; | |
}else if(`gmatch $motionName1 "*critical*"`==1) | |
{ | |
print("Critical だよ! \n"); | |
$DoFuncInt=1; | |
} | |
if(`file -q -writable`=="1"){ | |
if($DoFuncInt==1) | |
{ | |
print("=======================transrateZcsv.txt書き出します===============================\n"); | |
$Root_Z_output=$motionName1+","+ReadRootValueToArrOutStr($RootReadWay,$plusMinus); | |
print("$Root_Z_output= "+$Root_Z_output+"\n"); | |
SaveFrameXyxText($Root_Z_output); | |
}else{ | |
print("=======================transrateZcsv.txt書き出しません===============================\n"); | |
}; | |
} | |
rig_to_joint_bakemotion_fbx_v1103_proc081_RootTranslateXZdeleteKeyframe(); | |
}//080 RootノードのZ出力 | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc081_RootTranslateXZdeleteKeyframe() | |
{ //081 RootXZの移動キー削除 | |
//Rootの移動キーXYZ削除 | |
select -r Root ; | |
selectKey -clear ; | |
selectKey -add -k Root_translateZ Root_translateY Root_translateX ; | |
cutKey -animation keys -clear; | |
rig_to_joint_bakemotion_fbx_v1103_proc082_FbxExport(); | |
}//081 RootXZの移動キー削除 | |
// 結果: 0 // | |
global proc rig_to_joint_bakemotion_fbx_v1103_proc082_FbxExport() | |
{//082 FBX保存 | |
print("--------------MotionExporter_execute--------------\n"); | |
if(`file -q -writable`=="1"){ | |
///////////////////////////////////////////////////////joint select | |
select -cl; | |
for ($joint in `ls -type joint`) | |
{ | |
if(`file -q -writable`=="1"){ | |
for($attr in `listAttr -k $joint`) | |
{ | |
float $keys[] = `keyframe -q -timeChange ($joint + "." + $attr)`; | |
if (`size $keys`>0){ | |
select -add $joint; | |
}; | |
} | |
}//if(`file -q -writable`=="1"){ | |
} | |
////////////////////////////////////////////////////////joint select; | |
} | |
//--------------MotionExporter_execute-------------- | |
//////////////////////////////////////////////////////fbx settings | |
//// エラー: line 354: プロシージャ "FBXExportEmbeddedTextures" が見つかりません。 // | |
FBXExportEmbeddedTextures -v false; | |
// FBXExportHardEdges -v true; | |
// エラー: line 357: プロシージャ "FBXExportApplyConstantKeyReducer" が見つかりません。 // | |
FBXExportApplyConstantKeyReducer -v false; | |
FBXExportShowUI -v false; | |
print "Before fbx export\n"; | |
/////////////////////////////////////////////////////fbx settings; | |
//////////////////////////////////////////////////////////////////////////////exportdir+filename///// | |
workspace -projectPath(`file -q -sn`); | |
// 結果: scenes/motion/motion_000_attack.mb // | |
string $path = (`file -q -sn`); | |
//print ("$path= "+$path); | |
// 結果: D:/work/3D/motion/test_ian01/scenes/motion/motion_000_attack.mb // | |
string $dirarr[]; | |
$numTokens = `tokenize $path "/" $dirarr`; | |
int $dirLength=size($dirarr); | |
string $filename=$dirarr[$dirLength-1]; | |
print("$filename= "+$filename+"\n"); | |
////////////////motionname | |
string $filenames[]; | |
$numTokens2 = `tokenize $dirarr[$dirLength-1] "." $filenames`; | |
string $motionName=$filenames[0]; | |
////////////////savepath | |
string $savePath=""; | |
for ( $i = 0 ; $i <$dirLength ; $i++ ) { | |
if($i < $dirLength-1){ | |
$savePath=$savePath + $dirarr[$i] ; | |
} | |
if($i < $dirLength-2){ | |
$savePath=$savePath + "/" ; | |
} | |
} | |
if(`file -q -writable`=="1"){ | |
print("------- MotionExporter_execute $savePath= " +$savePath+ " -------------\n"); | |
//フォルダ作る | |
string $makedirpass=$savePath+"/fbx/"; | |
sysFile -makeDir $makedirpass; | |
$savePath=$savePath+"/fbx/"+$motionName+".fbx"; | |
print("------- MotionExporter_execute $savePath= " +$savePath+ " -------------\n"); | |
} | |
////////////////////////////////////////////////////////////////////////////exportdir+filename///// | |
FBXExport -f ($savePath) -s; | |
//}; | |
print("------- MotionExporter_execute = " +$savePath+ " -------------\n"); | |
//} | |
}//rig_to_joint_bakemotion_fbx_v1103_proc082_FbxExport() //082 FBX保存 | |
//rig_to_joint_bakemotion_fbx_v11;本体おわり=========================== | |
global proc fileTestCheckAndLoad(string $filepath){ | |
if(`file -q -writable`=="1"){ | |
$fileExCheckHead = `filetest -f $filepath`; | |
if ($fileExCheckHead == 0) | |
{ | |
print("\n"+"------ファイルがみつかりません-----------$filepath="+$filepath+"\n"); | |
int $zeroisfalse=`gmatch $filepath "*{*}"`; | |
print("$zeroisfalse= "+$zeroisfalse); | |
if($zeroisfalse>0) | |
{ | |
print("\n"+"------パターンに一致しました-----------$filepath="+$filepath+"\n"); | |
// Result: 1 | |
string $DoublefilePathArr[]; | |
$numTokens = `tokenize $filepath "." $DoublefilePathArr`; | |
string $newfilepath=$DoublefilePathArr[0]+"_d.mb"; | |
print("\n"+"------パターンに一致しました-----------$newfilepath="+$newfilepath+"\n"); | |
global string $motionfileName;//外部グローバルの変数とってくる。 | |
string $motionfileName = `file -q -sceneName`;// Result: C:/projects/default/scenes/untitled.mb // | |
//file -loadReference -loadSettings $newfilepath;//コピーしたファイルを読んでもだめ。 | |
//file -f -options "v=0;" -ignoreVersion -typ "mayaBinary" -o "D:/work/BlackRose/Chara/test_ian01/scenes/test_ian01_rig.mb"; | |
// addRecentFile("D:/work/BlackRose/Chara/test_ian01/scenes/test_ian01_rig.mb", "mayaBinary"); | |
} | |
}else{ | |
print("\n"+"------ファイルがみつかりました----------$filepath="+$filepath+"\n"); | |
file -loadReference -loadSettings $filepath; | |
} | |
} | |
}; | |
global proc prefixNode(string $prefix, string $node) | |
{ | |
print("---prefixNode---$node="+$node+"\n"); | |
string $isType[] = `ls -type transform $node`; | |
if (size($isType) > 0 ) { | |
string $nodeName = `substitute ".*|" $node ""`; | |
print("---prefixNode---$nodeName="+$nodeName+"\n"); | |
string $buffer[]; | |
$numTokens = `tokenize $nodeName ":" $buffer`; | |
string $endString= $buffer[$numTokens-1]; | |
print("---prefixNode---------------------$endString="+$endString+"\n"); | |
// rename this node | |
//string $newName = `rename $node ( $endString )`; | |
rig_to_joint_bakemotion_fbx_v1103_proc068_renameReadWriteCheck( $node ,$endString,"rig_to_joint_bakemotion_fbx_v1103_proc077_DeletePrefix"); | |
} | |
}; | |
global proc SaveFrameXyxText(string $outputText) | |
{ | |
print("==============================SaveFrameXyxText================================Start\n"); | |
string $workspaceRoot = `workspace -q -rootDirectory`; | |
//string myWorkspace =`workspace -q -dir`; | |
print("-------------#workspaceRoot-------------------"+"\n"); | |
//print($workspaceRoot); | |
print("\n-------------#workspaceRoot-------------------"+"\n"); | |
string $saveDir= $workspaceRoot+"scenes/motion/"; | |
print ("$saveDir= "+$saveDir); | |
string $saveTxtPath=$saveDir+"transrateZcsv.txt"; | |
$fileExCheckHead0 = `filetest -f $saveTxtPath`; | |
$outputTxt=$outputText; | |
//////////////////////////////////////////////////////write | |
$fileExCheckHead = `filetest -f $saveTxtPath`; | |
if ($fileExCheckHead == 0) | |
{ | |
print ("transrateZcsv.txtないので テキストファイル作ります。$saveTxtPath= "+$saveTxtPath+"\n"); | |
//system("echo "+$outputTxt+"> "+$saveTxtPath); | |
//system("type C:\Users\B07363\Documents\maya\2016\ja_JP\scripts\return.txt >> "+$saveTxtPath); | |
//--------------------------------------------------テキストファイル内を削除 | |
//ファイルパスを変数に格納 | |
$exampleFileName = $saveTxtPath; | |
//ファイル識別子を変数に格納 | |
$fileId=`fopen $exampleFileName "w"`; | |
//書き込みたい文字列を指定 | |
fprint $fileId ""; | |
//終了する | |
fclose $fileId; | |
system("echo "+$outputTxt+" >> "+$saveTxtPath); | |
//---------------------------------------------------------- | |
}else{ | |
system("type C:\Users\B07363\Documents\maya\2016\ja_JP\scripts\return.txt >> "+$saveTxtPath); | |
print ("transrateZcsv.txtあるので テキストファイル上書きします。$saveTxtPath= "+$saveTxtPath+"\n"); | |
//type return.txt >> output.txt | |
system("echo "+$outputTxt+" >> "+$saveTxtPath); | |
} | |
/////////////////////////////////////////////////////////////////// | |
print("==============================SaveFrameXyxText================================End\n"); | |
} | |
global proc string ReadRootValueToArrOutStr(string $ObjTranslateXStr , int $plusMinus) | |
{ | |
print("==============================ReadRootValueToArrOutStr($ObjTranslateXStr= "+$ObjTranslateXStr+" $plusMinus="+$plusMinus+")================================Start\n"); | |
int $startFrameInt =`findKeyframe -which first`; | |
//int $nextFrameInt =`findKeyframe -timeSlider -which next`; | |
int $endFrameInt=0; | |
$endFrameInt = `findKeyframe -which last`; | |
int $OldFrameInt=$startFrameInt-0; | |
int $NowFrameInt=$startFrameInt-0; | |
float $OldFrameZ=0; | |
float $NowFrameZ=0; | |
//selectKey -add -k -t 0 Root_translateZ ; | |
// keyframe -time $NowFrame ; | |
//keyframe -time | |
float $NowFrameZArr[]; | |
float $FrameZArr[]; | |
int $FrameZArrInt[]; | |
int $FrameZArrFloat[]; | |
int $TransitionSaInt; | |
int $TransitionSaFloat; | |
print("======ReadRootValueToArrOutStr ループ回数 $endFrameInt="+$endFrameInt+" 引く $startFrameInt= "+$startFrameInt+" \n"); | |
int $nodesLength =$endFrameInt-$startFrameInt; | |
print("======ReadRootValueToArrOutStr ループ回数 $nodesLength="+$nodesLength+"\n"); | |
int $i; | |
string $RootTranslateZStr="Root.translateZ"; | |
$RootTranslateZStr=$ObjTranslateXStr;//引数つっこむ | |
string $outputStr=""; | |
print("======ReadRootValueToArrOutStr ループ回数 for ($i = $startFrameIntつまり "+$startFrameInt+"からループはじめて ; $i < $nodesLength "+$nodesLength+"になるまでループするよ; $i++ ) "+"\n"); | |
for ($i = $startFrameInt ; $i < $nodesLength ; $i++ ) | |
{ | |
print("=========ReadRootValueToArrOutStr $i= "+$i+" \n"); | |
$NowFrameInt=$i-0; | |
//keyframe -time 4 -query -valueChange "Root.translateZ"; | |
// 結果: -31.227989 // | |
$NowFrameZArr= `keyframe -time $NowFrameInt -query -valueChange $RootTranslateZStr` ; | |
float $NowFrameZmove_value_float=$NowFrameZArr[0]; | |
//print("=========ReadRootValueToArrOutStr $NowFrameZArr= START \n"); | |
// print($NowFrameZArr); | |
//print("=========ReadRootValueToArrOutStr $NowFrameZArr= END \n"); | |
print("=========ReadRootValueToArrOutStr $NowFrameZmove_value_float= "+$NowFrameZmove_value_float+" \n"); | |
//$NowFrameZ=$NowFrameZArr[0]; | |
$NowFrameZ=$NowFrameZmove_value_float; | |
//print ("$NowFrameZArr= START \n"); | |
//print ($NowFrameZArr); | |
//print ("$NowFrameZArr= END \n"); | |
// print ("$NowFrameZ= "+$NowFrameZ+"\n"); | |
//$FrameZArr[$i]=$NowFrameZ; | |
$FrameZArr[$i]= $NowFrameZmove_value_float; | |
//$NowFrameInt=int($NowFrameZ); | |
if($i==0){ | |
print("ゼロフレームの比較対象は自分自身の値をいれておく。 つまり 次のロジックの差の算出は常に 0 ゼロ"+"\n"); | |
$OldFrameZ=$NowFrameZ; | |
} | |
//移動量=差の算出 | |
//$TransitionSaInt=$NowFrameInt-$OldFrameInt; | |
$TransitionSaFloat=$NowFrameZ-$OldFrameZ; | |
print("=========ReadRootValueToArrOutStr 差の算出 $TransitionSaFloat("+$TransitionSaFloat+")=$NowFrameZ("+$NowFrameZ+")-$OldFrameZ("+$OldFrameZ+"); \n"); | |
// $FrameZArrInt[$i]=$TransitionSaInt; | |
$FrameZArrFloat[$i]=setFloatRound($TransitionSaFloat*100); | |
//積み立て | |
// $outputStr=$outputStr+$FrameZArrInt[$i]*$plusMinus+","; | |
$outputStr=$outputStr+$FrameZArrFloat[$i]*$plusMinus+","; | |
//あと処理 | |
// $OldFrameInt= $NowFrameInt; | |
$OldFrameZ=$NowFrameZ; | |
} | |
//print ("$FrameZArrInt= START \n"); | |
//print ($FrameZArrInt); | |
//print ("$FrameZArrInt= END \n"); | |
print("$outputStr= "+$outputStr+"\n"); | |
print("==============================ReadRootValueToArrOutStr($ObjTranslateXStr= "+$ObjTranslateXStr+" $plusMinus="+$plusMinus+")=$outputStr= "+$outputStr+"================================End\n"); | |
return $outputStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment