@@ -1745,23 +1745,9 @@ internal static HashSet<float> GetKeyTimes(AnimationCurve[] animCurves)
1745
1745
/// NOTE : This is a work in progress (WIP). We only export the key time and value on
1746
1746
/// a Cubic curve using the default tangents.
1747
1747
/// </summary>
1748
- internal void ExportAnimationKeys ( AnimationCurve uniAnimCurve , FbxAnimCurve fbxAnimCurve ,
1748
+ internal static void ExportAnimationKeys ( AnimationCurve uniAnimCurve , FbxAnimCurve fbxAnimCurve ,
1749
1749
UnityToMayaConvertSceneHelper convertSceneHelper , string uniPropertyName )
1750
1750
{
1751
- // TODO: complete the mapping between key tangents modes Unity and FBX
1752
- Dictionary < AnimationUtility . TangentMode , List < FbxAnimCurveDef . ETangentMode > > MapUnityKeyTangentModeToFBX =
1753
- new Dictionary < AnimationUtility . TangentMode , List < FbxAnimCurveDef . ETangentMode > >
1754
- {
1755
- //TangeantAuto|GenericTimeIndependent|GenericClampProgressive
1756
- { AnimationUtility . TangentMode . Free , new List < FbxAnimCurveDef . ETangentMode > { FbxAnimCurveDef . ETangentMode . eTangentAuto , FbxAnimCurveDef . ETangentMode . eTangentGenericClampProgressive } } ,
1757
-
1758
- //TangeantAuto|GenericTimeIndependent
1759
- { AnimationUtility . TangentMode . Auto , new List < FbxAnimCurveDef . ETangentMode > { FbxAnimCurveDef . ETangentMode . eTangentAuto , FbxAnimCurveDef . ETangentMode . eTangentGenericTimeIndependent } } ,
1760
-
1761
- //TangeantAuto|GenericTimeIndependent|GenericClampProgressive
1762
- { AnimationUtility . TangentMode . ClampedAuto , new List < FbxAnimCurveDef . ETangentMode > { FbxAnimCurveDef . ETangentMode . eTangentAuto , FbxAnimCurveDef . ETangentMode . eTangentGenericClampProgressive } } ,
1763
- } ;
1764
-
1765
1751
// Copy Unity AnimCurve to FBX AnimCurve.
1766
1752
// NOTE: only cubic keys are supported by the FbxImporter
1767
1753
using ( new FbxAnimCurveModifyHelper ( new List < FbxAnimCurve > { fbxAnimCurve } ) )
@@ -1781,13 +1767,6 @@ internal void ExportAnimationKeys (AnimationCurve uniAnimCurve, FbxAnimCurve fbx
1781
1767
FbxAnimCurveDef . EInterpolationType interpMode = FbxAnimCurveDef . EInterpolationType . eInterpolationCubic ;
1782
1768
switch ( rTangent )
1783
1769
{
1784
- /*case AnimationUtility.TangentMode.Auto:
1785
- case AnimationUtility.TangentMode.ClampedAuto:
1786
- tanMode = FbxAnimCurveDef.ETangentMode.eTangentAuto;
1787
- break;
1788
- case AnimationUtility.TangentMode.Free:
1789
- tanMode = FbxAnimCurveDef.ETangentMode.eTangentUser;
1790
- break;*/
1791
1770
case AnimationUtility . TangentMode . Linear :
1792
1771
interpMode = FbxAnimCurveDef . EInterpolationType . eInterpolationLinear ;
1793
1772
break ;
@@ -1799,21 +1778,17 @@ internal void ExportAnimationKeys (AnimationCurve uniAnimCurve, FbxAnimCurve fbx
1799
1778
break ;
1800
1779
}
1801
1780
1802
- float tangentMultiplier = 100 ;
1781
+ float tangentMultiplier = UnitScaleFactor ;
1803
1782
if ( uniPropertyName . StartsWith ( "localEulerAnglesRaw" ) )
1804
1783
{
1805
1784
tangentMultiplier = 1 ;
1806
1785
}
1807
- if ( uniPropertyName == "m_LocalPosition.x" || uniPropertyName == "localEulerAnglesRaw.y" || uniPropertyName == "localEulerAnglesRaw.z" )
1808
- {
1809
- tangentMultiplier *= - 1 ; // have to negate x when switching between Unity->Maya axes
1810
- }
1811
1786
1812
1787
fbxAnimCurve . KeySet ( fbxKeyIndex ,
1813
1788
fbxTime ,
1814
1789
convertSceneHelper . Convert ( uniKeyFrame . value ) ,
1815
- interpMode , //FbxAnimCurveDef.EInterpolationType.eInterpolationCubic,
1816
- tanMode , //FbxAnimCurveDef.ETangentMode.eTangentBreak,
1790
+ interpMode ,
1791
+ tanMode ,
1817
1792
tangentMultiplier * uniKeyFrame . outTangent ,
1818
1793
keyIndex < uniAnimCurve . length - 1 ? tangentMultiplier * uniAnimCurve [ keyIndex + 1 ] . inTangent : 0 ,
1819
1794
FbxAnimCurveDef . EWeightedMode . eWeightedAll ,
@@ -1822,16 +1797,6 @@ internal void ExportAnimationKeys (AnimationCurve uniAnimCurve, FbxAnimCurve fbx
1822
1797
) ;
1823
1798
1824
1799
Debug . LogWarning ( uniPropertyName + ": tangents: " + uniKeyFrame . inTangent + ", " + uniKeyFrame . outTangent + ", weights: " + uniKeyFrame . inWeight + ", " + uniKeyFrame . outWeight ) ;
1825
-
1826
- if ( ! ( MapUnityKeyTangentModeToFBX . ContainsKey ( lTangent ) && MapUnityKeyTangentModeToFBX . ContainsKey ( rTangent ) ) )
1827
- {
1828
- Debug . LogWarning ( string . Format ( "key[{0}] missing tangent mapping ({1},{2})" , keyIndex , lTangent . ToString ( ) , rTangent . ToString ( ) ) ) ;
1829
- continue ;
1830
- }
1831
-
1832
- // TODO : handle broken tangents
1833
-
1834
- // TODO : set key tangents
1835
1800
}
1836
1801
}
1837
1802
}
@@ -1975,13 +1940,11 @@ private void ExportAnimationCurve (FbxNode fbxNode,
1975
1940
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1976
1941
// (Meters to Centimetres)
1977
1942
var convertSceneHelper = new UnityToMayaConvertSceneHelper ( uniPropertyName ) ;
1978
-
1979
- // TODO: we'll resample the curve so we don't have to
1980
- // configure tangents
1943
+
1981
1944
/*if (ModelExporter.ExportSettings.BakeAnimationProperty) {
1982
1945
ExportAnimationSamples (uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
1983
1946
} else {*/
1984
- ExportAnimationKeys ( uniAnimCurve , fbxAnimCurve , convertSceneHelper , uniPropertyName ) ;
1947
+ ExportAnimationKeys ( uniAnimCurve , fbxAnimCurve , convertSceneHelper , uniPropertyName ) ;
1985
1948
// }
1986
1949
}
1987
1950
}
@@ -2158,12 +2121,14 @@ private void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoot,
2158
2121
continue ;
2159
2122
}
2160
2123
2161
- /*index = EulerCurve.GetEulerIndex (propertyName);
2162
- if (index >= 0) {
2124
+ // If this is an euler curve with a prerotation, then need to sample animations to remove the prerotation.
2125
+ // Otherwise can export normally with tangents.
2126
+ index = EulerCurve . GetEulerIndex ( propertyName ) ;
2127
+ if ( index >= 0 && fbxNode . GetPreRotation ( FbxNode . EPivotSet . eSourcePivot ) . Distance ( new FbxVector4 ( ) ) > 0 ) {
2163
2128
RotationCurve rotCurve = GetRotationCurve < EulerCurve > ( uniGO , uniAnimClip . frameRate , ref rotations ) ;
2164
2129
rotCurve . SetCurve ( index , uniAnimCurve ) ;
2165
2130
continue ;
2166
- }*/
2131
+ }
2167
2132
2168
2133
// simple property (e.g. intensity), export right away
2169
2134
ExportAnimationCurve ( fbxNode , uniAnimCurve , uniAnimClip . frameRate ,
0 commit comments