Created
June 13, 2015 09:18
-
-
Save leestuartx/afcce2707cb685d57e51 to your computer and use it in GitHub Desktop.
Remove Keyframes from root and reposition and orient to 0,0,0
This file contains hidden or 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
#a script for removing all the keyframes on the root node | |
from pyfbsdk import * | |
import os.path, os, inspect, sys | |
#List to populate character template | |
lScene = FBSystem().Scene | |
lcharactersList = FBSystem().Scene.Characters | |
lchar = lcharactersList[0] | |
#select the first character | |
lchar.Selected = True | |
#find a joint | |
jointsList = FBComponentList() | |
FBFindObjectsByName('Character1_Reference', jointsList, False, True) | |
#print(jointsList[0].Name) | |
#jointsList[0].Selected = True | |
def ClearAnim( pNode ): | |
if pNode.FCurve: | |
pNode.FCurve.EditClear() | |
else: | |
for lNode in pNode.Nodes: | |
ClearAnim( lNode ) | |
# Cleanup | |
del( lNode ) | |
for newTake in lSystem.Scene.Takes: | |
#Open next take | |
lSystem.CurrentTake = newTake | |
#clear the root joint | |
ClearAnim( jointsList[0].AnimationNode ) | |
#bake to the rig | |
lOptions = FBPlotOptions() | |
lOptions.ConstantKeyReducerKeepOneKey = True | |
lOptions.PlotAllTakes = False | |
lOptions.PlotOnFrame = True | |
lOptions.PlotPeriod = FBTime( 0, 0, 0, 1 ) | |
lOptions.PlotTranslationOnRootOnly = True | |
lOptions.PreciseTimeDiscontinuities = True | |
lOptions.RotationFilterToApply = FBRotationFilter.kFBRotationFilterGimbleKiller | |
lOptions.UseConstantKeyReducer = False | |
lchar.PlotAnimation (FBCharacterPlotWhere.kFBCharacterPlotOnControlRig,lOptions ) | |
#reposition the root joint to 0,0,0 | |
jointsList[0].Translation = FBVector3d(0.0, 0.0, 0.0) | |
#jointsList[0].Scaling = FBVector3d(1.0, 1.0, 1.0) | |
jointsList[0].Rotation = FBVector3d(0.0, 0.0, 0.0) | |
## Plot the character animation to skeleton | |
lOptions = FBPlotOptions() | |
lOptions.ConstantKeyReducerKeepOneKey = True | |
lOptions.PlotAllTakes = False | |
lOptions.PlotOnFrame = True | |
lOptions.PlotPeriod = FBTime( 0, 0, 0, 1 ) | |
lOptions.PlotTranslationOnRootOnly = True | |
lOptions.PreciseTimeDiscontinuities = True | |
lOptions.RotationFilterToApply = FBRotationFilter.kFBRotationFilterGimbleKiller | |
lOptions.UseConstantKeyReducer = False | |
lchar.PlotAnimation (FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton,lOptions ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment