@@ -1804,7 +1804,7 @@ internal static HashSet<float> GetKeyTimes(AnimationCurve[] animCurves)
1804
1804
/// a Cubic curve using the default tangents.
1805
1805
/// </summary>
1806
1806
internal void ExportAnimationKeys ( AnimationCurve uniAnimCurve , FbxAnimCurve fbxAnimCurve ,
1807
- UnityToMayaConvertSceneHelper convertSceneHelper )
1807
+ UnityToMayaConvertSceneHelper convertSceneHelper , string uniPropertyName )
1808
1808
{
1809
1809
// TODO: complete the mapping between key tangents modes Unity and FBX
1810
1810
Dictionary < AnimationUtility . TangentMode , List < FbxAnimCurveDef . ETangentMode > > MapUnityKeyTangentModeToFBX =
@@ -1831,14 +1831,47 @@ internal void ExportAnimationKeys (AnimationCurve uniAnimCurve, FbxAnimCurve fbx
1831
1831
1832
1832
int fbxKeyIndex = fbxAnimCurve . KeyAdd ( fbxTime ) ;
1833
1833
1834
- fbxAnimCurve . KeySet ( fbxKeyIndex ,
1835
- fbxTime ,
1836
- convertSceneHelper . Convert ( uniKeyFrame . value )
1837
- ) ;
1838
1834
1839
1835
// configure tangents
1840
1836
var lTangent = AnimationUtility . GetKeyLeftTangentMode ( uniAnimCurve , keyIndex ) ;
1841
1837
var rTangent = AnimationUtility . GetKeyRightTangentMode ( uniAnimCurve , keyIndex ) ;
1838
+ FbxAnimCurveDef . ETangentMode tanMode = FbxAnimCurveDef . ETangentMode . eTangentAuto ;
1839
+ FbxAnimCurveDef . EInterpolationType interpMode = FbxAnimCurveDef . EInterpolationType . eInterpolationCubic ;
1840
+ switch ( rTangent )
1841
+ {
1842
+ case AnimationUtility . TangentMode . Auto :
1843
+ case AnimationUtility . TangentMode . ClampedAuto :
1844
+ break ;
1845
+ case AnimationUtility . TangentMode . Free :
1846
+ tanMode = FbxAnimCurveDef . ETangentMode . eTangentUser ;
1847
+ break ;
1848
+ case AnimationUtility . TangentMode . Linear :
1849
+ interpMode = FbxAnimCurveDef . EInterpolationType . eInterpolationLinear ;
1850
+ break ;
1851
+ case AnimationUtility . TangentMode . Constant :
1852
+ interpMode = FbxAnimCurveDef . EInterpolationType . eInterpolationConstant ;
1853
+ break ;
1854
+ default :
1855
+ break ;
1856
+ }
1857
+
1858
+ float tangentMultiplier = 100 ;
1859
+ if ( uniPropertyName == "m_LocalPosition.x" )
1860
+ {
1861
+ tangentMultiplier *= - 1 ; // have to negate x when switching between Unity->Maya axes
1862
+ }
1863
+
1864
+ fbxAnimCurve . KeySet ( fbxKeyIndex ,
1865
+ fbxTime ,
1866
+ convertSceneHelper . Convert ( uniKeyFrame . value ) ,
1867
+ interpMode , //FbxAnimCurveDef.EInterpolationType.eInterpolationCubic,
1868
+ tanMode , //FbxAnimCurveDef.ETangentMode.eTangentBreak,
1869
+ tangentMultiplier * uniKeyFrame . outTangent ,
1870
+ keyIndex < uniAnimCurve . length - 1 ? tangentMultiplier * uniAnimCurve [ keyIndex + 1 ] . inTangent : 0 ,
1871
+ FbxAnimCurveDef . EWeightedMode . eWeightedAll ,
1872
+ uniKeyFrame . outWeight ,
1873
+ keyIndex < uniAnimCurve . length - 1 ? uniAnimCurve [ keyIndex + 1 ] . inWeight : 0
1874
+ ) ;
1842
1875
1843
1876
if ( ! ( MapUnityKeyTangentModeToFBX . ContainsKey ( lTangent ) && MapUnityKeyTangentModeToFBX . ContainsKey ( rTangent ) ) )
1844
1877
{
@@ -1995,11 +2028,11 @@ private void ExportAnimationCurve (FbxNode fbxNode,
1995
2028
1996
2029
// TODO: we'll resample the curve so we don't have to
1997
2030
// configure tangents
1998
- if ( ModelExporter . ExportSettings . BakeAnimationProperty ) {
2031
+ /* if (ModelExporter.ExportSettings.BakeAnimationProperty) {
1999
2032
ExportAnimationSamples (uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
2000
- } else {
2001
- ExportAnimationKeys ( uniAnimCurve , fbxAnimCurve , convertSceneHelper ) ;
2002
- }
2033
+ } else {*/
2034
+ ExportAnimationKeys ( uniAnimCurve , fbxAnimCurve , convertSceneHelper , uniPropertyName ) ;
2035
+ // }
2003
2036
}
2004
2037
}
2005
2038
0 commit comments