Last active
December 19, 2015 21:29
-
-
Save tokejepsen/6020272 to your computer and use it in GitHub Desktop.
grandpa mocap transfer
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
import maya.cmds as cmds | |
import maya.mel as mel | |
#load plugin | |
cmds.loadPlugin('fbxmaya.mll',quiet=True) | |
#getting file path and name | |
basicFilter = "FBX (*.fbx)" | |
filePath=cmds.fileDialog2(fileFilter=basicFilter, dialogStyle=1, | |
fileMode=1, | |
caption='Import Animation') | |
cmd='file -import -type "mayaAscii" -ra true -mergeNamespacesOnClash false -namespace ":" -options "v=0;" -pr "M:/00719_grandpa/assets/Characters/Grandpa/publish/ipiSoft_setup.mocap.v001.ma";' | |
mel.eval(cmd) | |
if filePath!=None: | |
#replace reference | |
cmds.file(filePath,loadReference='standing_talking_downRN') | |
#setting timeline | |
lastKey=int(cmds.findKeyframe( 'mocap:LFoot', which="last" )) | |
firstKey=int(cmds.findKeyframe( 'mocap:LFoot', which="first" )) | |
cmds.playbackOptions(min=firstKey) | |
cmds.playbackOptions(max=lastKey) | |
cmds.playbackOptions(ast=firstKey) | |
cmds.playbackOptions(aet=lastKey) | |
cmds.currentTime(int(lastKey)/2) | |
#bake anim | |
objs=["grandpa:c_spine1_ik2_cnt", "grandpa:c_neck1_ik1_cnt", "grandpa:c_face1_cnt", "grandpa:c_neck1_mid_cnt", "grandpa:c_neck1_extra_cnt", "grandpa:c_neck1_fk1_cnt", "grandpa:c_neck1_fk2_cnt", "grandpa:c_neck1_fk3_cnt", "grandpa:c_neck1_ikTwist1_cnt", "grandpa:c_neck1_end_cnt", "grandpa:c_spine1_ik1_cnt", "grandpa:c_spine1_mid_cnt", "grandpa:c_spine1_extra_cnt", "grandpa:c_spine1_master_cnt", "grandpa:c_spine1_fk1_cnt", "grandpa:c_spine1_fk2_cnt", "grandpa:c_spine1_fk3_cnt", "grandpa:c_spine1_fk4_cnt", "grandpa:c_spine1_end_cnt", "grandpa:c_spine1_start_cnt", "grandpa:c_spine1_ikTwist2_cnt", "grandpa:c_spine1_ikTwist1_cnt", "grandpa:c_spine1_hip_cnt", "grandpa:r_leg1_extra_cnt", "grandpa:r_leg1_midIkTwist_cnt", "grandpa:r_leg1_startIkTwist_cnt", "grandpa:r_leg1_polevector_cnt", "grandpa:r_leg1_endIk_cnt", "grandpa:r_leg1_startFk_cnt", "grandpa:r_leg1_midFk_cnt", "grandpa:r_leg1_endFk_cnt", "grandpa:r_foot1_heel_cnt", "grandpa:r_foot1_toetip_cnt", "grandpa:r_foot1_ball_cnt", "grandpa:r_foot1_toeIk_cnt", "grandpa:r_foot1_foot_cnt", "grandpa:r_foot1_toeFk_cnt", "grandpa:r_arm1_extra_cnt", "grandpa:r_arm1_midIkTwist_cnt", "grandpa:r_arm1_startIkTwist_cnt", "grandpa:r_arm1_polevector_cnt", "grandpa:r_arm1_endIk_cnt", "grandpa:r_arm1_startFk_cnt", "grandpa:r_arm1_midFk_cnt", "grandpa:r_arm1_endFk_cnt", "grandpa:r_finger2_1_cnt", "grandpa:r_finger2_2_cnt", "grandpa:r_finger2_3_cnt", "grandpa:r_finger2_base_cnt", "grandpa:r_finger1_1_cnt", "grandpa:r_finger1_2_cnt", "grandpa:r_finger1_base_cnt", "grandpa:r_finger5_1_cnt", "grandpa:r_finger5_2_cnt", "grandpa:r_finger5_3_cnt", "grandpa:r_finger5_base_cnt", "grandpa:r_finger4_1_cnt", "grandpa:r_finger4_2_cnt", "grandpa:r_finger4_3_cnt", "grandpa:r_finger4_base_cnt", "grandpa:r_finger3_1_cnt", "grandpa:r_finger3_2_cnt", "grandpa:r_finger3_3_cnt", "grandpa:r_finger3_base_cnt", "grandpa:r_joint1_cnt", "grandpa:l_arm1_extra_cnt", "grandpa:l_arm1_midIkTwist_cnt", "grandpa:l_arm1_startIkTwist_cnt", "grandpa:l_arm1_polevector_cnt", "grandpa:l_arm1_endIk_cnt", "grandpa:l_arm1_startFk_cnt", "grandpa:l_arm1_midFk_cnt", "grandpa:l_arm1_endFk_cnt", "grandpa:l_finger5_1_cnt", "grandpa:l_finger5_2_cnt", "grandpa:l_finger5_3_cnt", "grandpa:l_finger5_base_cnt", "grandpa:l_finger4_1_cnt", "grandpa:l_finger4_2_cnt", "grandpa:l_finger4_3_cnt", "grandpa:l_finger4_base_cnt", "grandpa:l_finger3_1_cnt", "grandpa:l_finger3_2_cnt", "grandpa:l_finger3_3_cnt", "grandpa:l_finger3_base_cnt", "grandpa:l_finger2_1_cnt", "grandpa:l_finger2_2_cnt", "grandpa:l_finger2_3_cnt", "grandpa:l_finger2_base_cnt", "grandpa:l_finger1_1_cnt", "grandpa:l_finger1_2_cnt", "grandpa:l_finger1_base_cnt", "grandpa:l_joint1_cnt", "grandpa:l_leg1_extra_cnt", "grandpa:l_leg1_midIkTwist_cnt", "grandpa:l_leg1_startIkTwist_cnt", "grandpa:l_leg1_polevector_cnt", "grandpa:l_leg1_endIk_cnt", "grandpa:l_leg1_startFk_cnt", "grandpa:l_leg1_midFk_cnt", "grandpa:l_leg1_endFk_cnt", "grandpa:l_foot1_heel_cnt", "grandpa:l_foot1_toetip_cnt", "grandpa:l_foot1_ball_cnt", "grandpa:l_foot1_toeIk_cnt", "grandpa:l_foot1_foot_cnt", "grandpa:l_foot1_toeFk_cnt", "grandpa:c_master1_cnt"] | |
cmds.bakeResults(objs,simulation=True,t=(firstKey,lastKey),sampleBy=1,disableImplicitControl=True,preserveOutsideKeys=True,sparseAnimCurveBake=False, | |
removeBakedAttributeFromLayer=False,bakeOnOverrideLayer=False,minimizeRotation=True,controlPoints=False,shape=True) | |
#remove mocap | |
cmds.file(filePath,removeReference=True) | |
#delete HIK | |
cmd='hikEnableCharacter( "Character2", 0 );deleteCharacter("Character1");deleteCharacter("Character2");' | |
mel.eval(cmd) | |
#final notification | |
confirm=cmds.confirmDialog( title='FINISHED', message='mocap transfered') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment