动画


from pyfbsdk import *

# go to 0 frame
t = FBTime()
t.SetFrame(0)
FBPlayerControl().Goto(t)
for obj in selectedModels:
    # key frame
    obj.Translation.Key()
    obj.Rotation.Key()
    
    
t.SetFrame(-1)
FBPlayerControl().Goto(t)
for obj in selectedModels:
    # key frame
    obj.Translation = FBVector3d( 0, 0, 0)
    obj.Rotation = FBVector3d( -90, 0, 0)
    obj.Translation.Key()
    obj.Rotation.Key()
    

# Function to create rotation animation for a model
def CreateAnimation(pNode):
    if pNode.FCurve:
        lFCurve = pNode.FCurve
        lFCurve.KeyAdd(FBTime.Zero, 0)
        lFCurve.KeyAdd(FBTime(0,0,6,0), 90)
    if pNode.Nodes:
        for lNode in pNode.Nodes:
            CreateAnimation( lNode )
            
lModel.Rotation.SetAnimated(True)
lModel.Rotation.GetAnimationNode().Nodes[0].FCurve.KeyDeleteByTimeRange(FBTime(0,0,0,0), FBTime(0,0,0,20))
lModel.Rotation.GetAnimationNode().Nodes[1].FCurve.KeyDeleteByTimeRange(FBTime(0,0,0,0), FBTime(0,0,0,20))
lModel.Rotation.GetAnimationNode().Nodes[2].FCurve.KeyDeleteByTimeRange(FBTime(0,0,0,0), FBTime(0,0,0,20))


评论
  目录