Community
from pyfbsdk import *
import pprint
app = FBApplication()
system = FBSystem()
scene = FBSystem().Scene
player = FBPlayerControl()
animationRotationCurves = [] # used to store each model FCurve (on Take 001)
substractionRotationCurves = [] # used to store each model FCurve to be substracted (on Take 002)
pp = pprint.PrettyPrinter()
def getCurve(lmodel):
curveToRet =
for child in lmodel.Children:
curveToRet.extend(getCurve(child))
return curveToRet
def main():
if (len(scene.Takes)!= 3):
FBMessageBox( "Incorrect amount of takes", "Please create 3 takes in this order: additive anim, substraction anim, result take", "OK", None, None )
return False
else:
takeAnimation = scene.Takes
takeSubstraction = scene.Takes
takeResult = scene.Takes
character = app.CurrentCharacter #FBCharacter()
if character:
rootModel = character.GetModel(FBBodyNodeId.kFBHipsNodeId)
print "rootModel is:", rootModel.Name
system.CurrentTake = takeAnimation
scene.Evaluate()
animationRotationCurves = getCurve(rootModel)
system.CurrentTake = takeSubstraction
scene.Evaluate()
substractionRotationCurves = getCurve(rootModel)
system.CurrentTake = takeResult
scene.Evaluate()
# uncomment this bellow to print stuff for the keys
# system.CurrentTake = takeAnimation
# scene.Evaluate()
resultCurves = []
# iterates through each bone fcurve
for i in range(len(animationRotationCurves)):
print i
# obviusly, this is too much to ask: resultCurves.append(animationRotationCurves - substractionRotationCurves)
# :)
# so we iterate through each axis
for axis in range(0,3):
print animationRotationCurves.Name
print animationRotationCurves.Nodes.Name
print system.CurrentTake.Name
# and through each frame
for lkey in animationRotationCurves.Nodes.FCurve.Keys:
print "model: ", i, " axis number: ", axis, " lkey: ", lkey
else: # if character fails there's no character on the scene/selected
FBMessageBox( "No character selected", "Please select a character", "OK", None, None )
main()
Can't find what you're looking for? Ask the community or share your knowledge.