Python Reference Guide
 
Loading...
Searching...
No Matches
Samples\AnimationLayer\MergeAnimationLayers.py
1# Copyright 2010 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5#
6# Script description:
7# Show how to create new animation layers and how to animate a cube on different layers.
8# Also, we speficy some options for the animation layers.
9#
10# Topic: FBAnimationLayer
11#
12
13from pyfbsdk import *
14
15#--
16
17
18lCube = FBModelCube("Cube")
19lCube.Translation.SetAnimated(True)
20lCube.Rotation.SetAnimated(True)
21lCube.Show = True;
22
23
24lSystem = FBSystem()
25lSystem.CurrentTake.CreateNewLayer()
26lCount = lSystem.CurrentTake.GetLayerCount()
27lSystem.CurrentTake.GetLayer(lCount-1).Name= "PythonLayer1"
28
29
30lSystem.CurrentTake.GetLayerByName("PythonLayer1").Weight = 50;
31lSystem.CurrentTake.GetLayerByName("PythonLayer1").LayerMode = FBLayerMode.kFBLayerModeOverride;
32
33
34lSystem.CurrentTake.SetCurrentLayer(lCount-1)
35
36
37Node = lCube.AnimationNode.Nodes[0]
38
39for lNode in Node.Nodes:
40 lNode.FCurve.KeyAdd(FBTime(0,0,0,0), 0)
41lCube.Translation.GetAnimationNode().KeyAdd(FBTime(0,0,0,10), [20, 20, 20])
42lCube.Translation.GetAnimationNode().SetCandidate([10, 10, 10])
43lCube.Translation.GetAnimationNode().KeyCandidate()
44
45
46
47lSystem.CurrentTake.CreateNewLayer()
48lCount = lSystem.CurrentTake.GetLayerCount()
49lSystem.CurrentTake.GetLayer(lCount-1).Name= "PythonLayer2"
50
51
52lSystem.CurrentTake.SetCurrentLayer(lCount-1)
53
54
55for lNode in Node.Nodes:
56 lNode.FCurve.KeyAdd(FBTime(0,0,0,20), 15)
57 del( lNode )
58lCube.Translation.GetAnimationNode().KeyAdd(FBTime(0,0,0,20), [11, 11, 11])
59lCube.Translation.GetAnimationNode().SetCandidate([30, 30, 30])
60lCube.Translation.GetAnimationNode().KeyCandidate()
61
62
63lSystem.CurrentTake.CreateNewLayer()
64lCount = lSystem.CurrentTake.GetLayerCount()
65ParentLayer = lSystem.CurrentTake.GetLayer(lCount-2)
66NewChildLayer = lSystem.CurrentTake.GetLayer(lCount-1)
67NewChildLayer.Name= "child of PythonLayer2"
68
69
70ParentLayer.AddChildLayer(NewChildLayer)
71
72
73print(ParentLayer.GetChildCount())
74
75
77lSystem.CurrentTake.GetLayerByName("PythonLayer1").SelectLayer(True, False)
78lSystem.CurrentTake.GetLayerByName("PythonLayer2").SelectLayer(True, False)
79
80
81lSystem.CurrentTake.MergeLayers(FBAnimationLayerMergeOptions.kFBAnimLayerMerge_SelectedLayer_CompleteScene, True, FBMergeLayerMode.kFBMergeLayerModeAutomatic)
Cube model class.
Definition: pyfbsdk_generated.h:11337
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771
Time data structure.
Definition: pyfbsdk_generated.h:19596