Solved! Go to Solution.
Solved by akira.kudo. Go to Solution.
A sample code "ExportScene01.py" below in the sdk would be helpful for you. As you can see it, there are also helpful comments what we have to do for creating animation.
Please see in detail a URL below.
<code_begin>
# Create two animation stacks.
def AnimateSkeleton(pSdkManager, pScene, pSkeletonRoot):
lKeyIndex = 0
lTime = FbxTime()
lRoot = pSkeletonRoot
lLimbNode1 = pSkeletonRoot.GetChild(0)
# First animation stack.
lAnimStackName = "Bend on 2 sides"
lAnimStack = FbxAnimStack.Create(pScene, lAnimStackName)
# The animation nodes can only exist on AnimLayers therefore it is mandatory to
# add at least one AnimLayer to the AnimStack. And for the purpose of this example,
# one layer is all we need.
lAnimLayer = FbxAnimLayer.Create(pScene, "Base Layer")
lAnimStack.AddMember(lAnimLayer)
# Create the AnimCurve on the Rotation.Z channel
lCurve = lRoot.LclRotation.GetCurve(lAnimLayer, "Z", True)
if lCurve:
lCurve.KeyModifyBegin()
lTime.SetSecondDouble(0.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(1.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 45.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(2.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, -45.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(3.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lCurve.KeyModifyEnd()
# Same thing for the next object
lCurve = lLimbNode1.LclRotation.GetCurve(lAnimLayer, "Z", True)
if lCurve:
lCurve.KeyModifyBegin()
lTime.SetSecondDouble(0.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(1.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, -90.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(2.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 90.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(3.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lCurve.KeyModifyEnd()
# Second animation stack.
lAnimStackName = "Bend and turn around"
lAnimStack = FbxAnimStack.Create(pScene, lAnimStackName)
# The animation nodes can only exist on AnimLayers therefore it is mandatory to
# add at least one AnimLayer to the AnimStack. And for the purpose of this example,
# one layer is all we need.
lAnimLayer = FbxAnimLayer.Create(pScene, "Base Layer")
lAnimStack.AddMember(lAnimLayer)
# Create the AnimCurve on the Rotation.Y channel
lCurve = lRoot.LclRotation.GetCurve(lAnimLayer, "Y", True)
if lCurve:
lCurve.KeyModifyBegin()
lTime.SetSecondDouble(0.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(2.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 720.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lCurve.KeyModifyEnd()
lCurve = lLimbNode1.LclRotation.GetCurve(lAnimLayer, "Z", True)
if lCurve:
lCurve.KeyModifyBegin()
lTime.SetSecondDouble(0.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(1.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 90.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lTime.SetSecondDouble(2.0)
lKeyIndex = lCurve.KeyAdd(lTime)[0]
lCurve.KeySetValue(lKeyIndex, 0.0)
lCurve.KeySetInterpolation(lKeyIndex, FbxAnimCurveDef.eInterpolationCubic)
lCurve.KeyModifyEnd()
<code_end>
For reading csv, there are a lot of artcles in websites. So a URL for instance would be helpful.
http://www.pythonforbeginners.com/systems-programming/using-the-csv-module-in-python/
I hope this helps.
Can't find what you're looking for? Ask the community or share your knowledge.