@@ -1730,6 +1730,11 @@ public void Dispose()
1730
1730
}
1731
1731
}
1732
1732
1733
+ /// <summary>
1734
+ /// Base class for QuaternionCurve and EulerCurve.
1735
+ /// Provides implementation for computing keys and generating FbxAnimCurves
1736
+ /// for euler rotation.
1737
+ /// </summary>
1733
1738
abstract class RotationCurve {
1734
1739
public double sampleRate ;
1735
1740
public AnimationCurve x ;
@@ -1824,6 +1829,10 @@ public void Animate(Transform unityTransform, FbxNode fbxNode, FbxAnimLayer fbxA
1824
1829
}
1825
1830
}
1826
1831
1832
+ /// <summary>
1833
+ /// Convert from ZXY to XYZ euler, and remove
1834
+ /// prerotation from animated rotation.
1835
+ /// </summary>
1827
1836
class EulerCurve : RotationCurve {
1828
1837
public EulerCurve ( ) { }
1829
1838
@@ -1979,7 +1988,15 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
1979
1988
1980
1989
/* The major difficulty: Unity uses quaternions for rotation
1981
1990
* (which is how it should be) but FBX uses Euler angles. So we
1982
- * need to gather up the list of transform curves per object. */
1991
+ * need to gather up the list of transform curves per object.
1992
+ *
1993
+ * For euler angles, Unity uses ZXY rotation order while Maya uses XYZ.
1994
+ * Maya doesn't import files with ZXY rotation correctly, so have to convert to XYZ.
1995
+ * Need all 3 curves in order to convert.
1996
+ *
1997
+ * Also, in both cases, prerotation has to be removed from the animated rotation if
1998
+ * there are bones being exported.
1999
+ */
1983
2000
var rotations = new Dictionary < GameObject , RotationCurve > ( ) ;
1984
2001
1985
2002
foreach ( EditorCurveBinding uniCurveBinding in AnimationUtility . GetCurveBindings ( uniAnimClip ) ) {
@@ -2036,6 +2053,14 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
2036
2053
}
2037
2054
}
2038
2055
2056
+ /// <summary>
2057
+ /// Gets or creates the rotation curve for GameObject uniGO.
2058
+ /// </summary>
2059
+ /// <returns>The rotation curve.</returns>
2060
+ /// <param name="uniGO">Unity GameObject.</param>
2061
+ /// <param name="frameRate">Frame rate.</param>
2062
+ /// <param name="rotations">Rotations.</param>
2063
+ /// <typeparam name="T"> RotationCurve is abstract so specify type of RotationCurve to create.</typeparam>
2039
2064
private RotationCurve GetRotationCurve < T > (
2040
2065
GameObject uniGO , float frameRate ,
2041
2066
ref Dictionary < GameObject , RotationCurve > rotations
0 commit comments