Samples/Geometry/ShapeCreation.py

Samples/Geometry/ShapeCreation.py
1 # Copyright 2009 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 # Topic: FBModel.SetupPropertiesForShapes, FBGeometry, FBProperty.SetAnimated
7 #
8 
9 
10 from pyfbsdk import FBModel, FBModelPlane, FBGeometry, FBVertex, FBTime
11 
12 # Create the plane.
13 lPlane = FBModelPlane('Deformable Plane')
14 
15 # The object must be set visible to be present in the system.
16 lPlane.Visible = True
17 lPlane.Show = True
18 
19 # Get the base geometry
20 lGeometry = lPlane.Geometry
21 
22 # Begin modify geometry
23 lGeometry.GeometryBegin()
24 
25 # Add shape
26 lShape0Idx = lGeometry.ShapeAdd("Shape 0")
27 
28 # Init Shape
29 lGeometry.ShapeInit(lShape0Idx, 2, False)
30 
31 # Set shape diff point
32 lGeometry.ShapeSetDiffPoint(lShape0Idx, 0, 0, FBVertex(0.0, 100.0, 10.0, 0.0));
33 lGeometry.ShapeSetDiffPoint(lShape0Idx, 1, 2, FBVertex(0.0, 100.0, 10.0, 0.0));
34 
35 # End modify geometry, notify for synchronization
36 lGeometry.GeometryEnd()
37 
38 # Setup Properties for shapes explicity
39 lPlane.SetupPropertiesForShapes()
40 
41 # Get Shape Property
42 lShapeProp = lPlane.PropertyList.Find("Shape 0")
43 lShapeProp.SetAnimated(True)
44 
45 # Get AnimationNode for insert key
46 lAniNode = lShapeProp.GetAnimationNode()
47 
48 # Add Keys.
49 lAniNode.KeyAdd(FBTime(0, 0, 0), 0.0)
50 lAniNode.KeyAdd(FBTime(0, 0, 4), 100.0)
51 lAniNode.KeyAdd(FBTime(0, 0, 8), 0.0)
52 
53 
54 # Cleanup.
55 del( lPlane, lGeometry, lShapeProp, lAniNode )
56 del( FBModelPlane, FBGeometry, FBVertex, FBTime )