Pythonで書き直した
# -*- coding: utf-8 -*-
from maya import cmds
import maya.mel as mel
import re
import pymel.core as pm
def selected_groupName():
selectedGlp=""
selectedArr=cmds.ls(sl=1)
print("selectedArr= "+str(selectedArr))
if(str(selectedArr)=="[]"):
print("You Should Select root Group Node!!!")
else:
selectedGlp=selectedArr[0]
#evalStr='$characterName = `hikCreateCharacter('+selectedGlp+')`'
#myPythonVar=mel.eval('$tempMelVar=$gMainWindow')
#characterName=mel.eval(evalStr)
#print(u"characterName= " + str(characterName))
return selectedGlp
def LongNameToShortName(LongName):
#childfullpath= |group_meshHIK_Tpose_jointUE4name5|SK_Mannequin|root|hip|spine_01
LongNameArr=LongName.split("|")
LongNameArrLong=len(LongNameArr)
shortName=LongNameArr[LongNameArrLong-1]
return shortName
def Group_in_joint(GroupName,jointName):
print("jointName= "+jointName)
HitJointFullPath=""
groupChild=cmds.ls(GroupName,dag=1,long=1)
for childfullpath in groupChild:
searchStr=r'.*'+'\|'+jointName+r'$'
print("searchStr= "+searchStr +" childfullpath= "+childfullpath)
MatchObj=re.match(searchStr, childfullpath)
MatchBool=bool(MatchObj)
if(MatchBool==True):
HitJointFullPath=childfullpath
print("HitJointFullPath !!!!!!!!= "+HitJointFullPath)
break
#shortjointNameArr=cmds.ls(childfullpath,shortNames=1)
#shortjointName=shortjointNameArr[0]
shortjointName=LongNameToShortName(childfullpath)
print("searchStr= "+jointName +" shortjointName= "+shortjointName)
if(str(shortjointName)==str(jointName)):
HitJointFullPath=childfullpath
print("HitJointFullPath !!!!!!!!= "+shortjointName)
break
print("HitJointFullPath= "+HitJointFullPath)
return HitJointFullPath
def setAttKeyFrame(GroupName,jointName,attName,attVal):
#MEL setCharacterObject("root",$characterDefName,0,0);
jointFullName=Group_in_joint(GroupName,jointName)
#evalStr='setCharacterObject("'+jointFullName+'","'+characterDefName+'",'+str(RigInt)+','+str(RigInt2)+');'
#print("evalStr= "+ evalStr)
attStr=jointFullName+'.'+attName
cmds.setAttr( attStr, attVal )
cmds.setKeyframe(jointFullName)
#mel.eval(evalStr)
def UE4JointSetToHumanIK():
GroupName= selected_groupName()
#print("characterDefName= "+characterDefName)
setAttKeyFrame(GroupName,"lowerJaw","rotateX",10)
setAttKeyFrame(GroupName,"lEyelidUpperInner","translateY",5.2)
setAttKeyFrame(GroupName,"lEyelidUpper","translateY",5)
setAttKeyFrame(GroupName,"lEyelidUpperOuter","translateY",5.2)
setAttKeyFrame(GroupName,"rEyelidUpperInner","translateY",5.2)
setAttKeyFrame(GroupName,"rEyelidUpper","translateY",5)
setAttKeyFrame(GroupName,"rEyelidUpperOuter","translateY",5.2)
UE4JointSetToHumanIK()
マイナス5frameに移動してそれぞれのジョイントにセットアトリビュートしたあとキーを打つ
currentTime -5 ;
proc setkeyFrame_F(string $innerPath,string $attributeName,float $attributeValue)
{
string $selectedArrFUllPath_F[] = `ls -sl`;
print("$selectedArrFUllPath_F is ==");
print($selectedArrFUllPath_F);
string $groupName_F;
$groupName_F=$selectedArrFUllPath_F[0];
print("groupName_F= "+$groupName_F+"\n");
string $attpath_F;
$attpath_F = "|"+$groupName_F + $innerPath;
print("attpath_F= "+$attpath_F+"\n");
string $attStr_F;
$attStr_F =$attpath_F+"."+$attributeName;
print("attStr= "+$attStr_F+"\n");
setAttr $attStr_F $attributeValue;
setKeyframe -attribute $attributeName $attpath_F;
}
setkeyFrame_F("|SK_Mannequin|root|hip|spine_01|spine_02|spine_03|neck_01|neck_02|head|lowerJaw","rotateX",10);
setkeyFrame_F("|SK_Mannequin|root|hip|spine_01|spine_02|spine_03|neck_01|neck_02|head|upperFaceRig|lEyelidUpperInner","translateY",5.2);
setkeyFrame_F("|SK_Mannequin|root|hip|spine_01|spine_02|spine_03|neck_01|neck_02|head|upperFaceRig|lEyelidUpper","translateY",5);
setkeyFrame_F("|SK_Mannequin|root|hip|spine_01|spine_02|spine_03|neck_01|neck_02|head|upperFaceRig|rEyelidUpperInner","translateY",5.2);
setkeyFrame_F("|SK_Mannequin|root|hip|spine_01|spine_02|spine_03|neck_01|neck_02|head|upperFaceRig|rEyelidUpper","translateY",5);
コメント