protected void CheckAnimCurve( FbxObject origAnimObject, FbxObject importAnimObject, FbxAnimLayer origLayer, FbxAnimLayer importLayer, List <PropertyComponentPair> propCompPairs, FbxNodeAttribute origNodeAttr = null, FbxNodeAttribute importNodeAttr = null) { foreach (var pair in propCompPairs) { FbxProperty origProperty = origAnimObject.FindProperty(pair.propertyName, false); if (origNodeAttr != null && (origProperty == null || !origProperty.IsValid())) { origProperty = origNodeAttr.FindProperty(pair.propertyName, false); } FbxProperty importProperty = importAnimObject.FindProperty(pair.propertyName, false); if (importNodeAttr != null && (importProperty == null || !importProperty.IsValid())) { importProperty = importNodeAttr.FindProperty(pair.propertyName, false); } Assert.IsNotNull(origProperty); Assert.IsNotNull(importProperty); Assert.IsTrue(origProperty.IsValid()); Assert.IsTrue(importProperty.IsValid()); foreach (var component in pair.componentList) { FbxAnimCurve origAnimCurve = origProperty.GetCurve(origLayer, component, false); FbxAnimCurve importAnimCurve = importProperty.GetCurve(importLayer, component, false); Assert.IsNotNull(origAnimCurve); Assert.IsNotNull(importAnimCurve); Assert.AreEqual(origAnimCurve.KeyGetCount(), importAnimCurve.KeyGetCount()); for (int i = 0; i < origAnimCurve.KeyGetCount(); i++) { Assert.AreEqual(origAnimCurve.KeyGetTime(i), importAnimCurve.KeyGetTime(i)); Assert.AreEqual(origAnimCurve.KeyGetValue(i), importAnimCurve.KeyGetValue(i)); } } } }
protected void CreateAnimCurves( FbxObject animObject, FbxAnimLayer animLayer, List <PropertyComponentPair> properties, System.Func <int, double> calcTime, // lambda function for calculating time based on index System.Func <int, float> calcValue, // lambda function for calculating value based on index FbxNodeAttribute animNodeAttr = null) { foreach (var pair in properties) { FbxProperty fbxProperty = animObject.FindProperty(pair.propertyName, false); if (animNodeAttr != null && (fbxProperty == null || !fbxProperty.IsValid())) { // backup method for finding the property if we can't find it on the node itself fbxProperty = animNodeAttr.FindProperty(pair.propertyName, false); } Assert.IsNotNull(fbxProperty); Assert.IsTrue(fbxProperty.IsValid()); Assert.That(fbxProperty.GetFlag(FbxPropertyFlags.EFlags.eAnimatable), Is.True); foreach (var component in pair.componentList) { // Create the AnimCurve on the channel FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve(animLayer, component, true); Assert.IsNotNull(fbxAnimCurve); fbxAnimCurve.KeyModifyBegin(); for (int keyIndex = 0; keyIndex < m_keyCount; ++keyIndex) { FbxTime fbxTime = FbxTime.FromSecondDouble(calcTime(keyIndex)); fbxAnimCurve.KeyAdd(fbxTime); fbxAnimCurve.KeySet(keyIndex, fbxTime, calcValue(keyIndex)); } fbxAnimCurve.KeyModifyEnd(); } } }