# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Topic: FBModel.SetupPropertiesForShapes, FBGeometry, FBProperty.SetAnimated
#


from pyfbsdk import FBModel, FBModelPlane, FBGeometry, FBVertex, FBTime

# Create the plane.
lPlane = FBModelPlane('Deformable Plane')

# The object must be set visible to be present in the system.
lPlane.Visible = True
lPlane.Show = True

# Get the base geometry 
lGeometry = lPlane.Geometry

# Begin modify geometry 
lGeometry.GeometryBegin()

# Add shape 
lShape0Idx = lGeometry.ShapeAdd("Shape 0")

# Init Shape
lGeometry.ShapeInit(lShape0Idx, 2, False)

# Set shape diff point
lGeometry.ShapeSetDiffPoint(lShape0Idx, 0, 0, FBVertex(0.0, 100.0, 10.0, 0.0));
lGeometry.ShapeSetDiffPoint(lShape0Idx, 1, 2, FBVertex(0.0, 100.0, 10.0, 0.0));

# End modify geometry, notify for synchronization
lGeometry.GeometryEnd()

# Setup Properties for shapes explicity
lPlane.SetupPropertiesForShapes()

# Get Shape Property 
lShapeProp = lPlane.PropertyList.Find("Shape 0")
lShapeProp.SetAnimated(True)

# Get AnimationNode for insert key
lAniNode = lShapeProp.GetAnimationNode()

# Add Keys.
lAniNode.KeyAdd(FBTime(0, 0, 0), 0.0)
lAniNode.KeyAdd(FBTime(0, 0, 4), 100.0)
lAniNode.KeyAdd(FBTime(0, 0, 8), 0.0)


# Cleanup.
del( lPlane, lGeometry, lShapeProp, lAniNode )
del( FBModelPlane, FBGeometry, FBVertex, FBTime )