Skip to content

Commit bd48a1c

Browse files
committed
add comments to code
1 parent 65ac789 commit bd48a1c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,11 @@ public void Dispose()
17301730
}
17311731
}
17321732

1733+
/// <summary>
1734+
/// Base class for QuaternionCurve and EulerCurve.
1735+
/// Provides implementation for computing keys and generating FbxAnimCurves
1736+
/// for euler rotation.
1737+
/// </summary>
17331738
abstract class RotationCurve {
17341739
public double sampleRate;
17351740
public AnimationCurve x;
@@ -1824,6 +1829,10 @@ public void Animate(Transform unityTransform, FbxNode fbxNode, FbxAnimLayer fbxA
18241829
}
18251830
}
18261831

1832+
/// <summary>
1833+
/// Convert from ZXY to XYZ euler, and remove
1834+
/// prerotation from animated rotation.
1835+
/// </summary>
18271836
class EulerCurve : RotationCurve {
18281837
public EulerCurve() { }
18291838

@@ -1979,7 +1988,15 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
19791988

19801989
/* The major difficulty: Unity uses quaternions for rotation
19811990
* (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+
*/
19832000
var rotations = new Dictionary<GameObject, RotationCurve> ();
19842001

19852002
foreach (EditorCurveBinding uniCurveBinding in AnimationUtility.GetCurveBindings (uniAnimClip)) {
@@ -2036,6 +2053,14 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
20362053
}
20372054
}
20382055

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>
20392064
private RotationCurve GetRotationCurve<T>(
20402065
GameObject uniGO, float frameRate,
20412066
ref Dictionary<GameObject, RotationCurve> rotations

0 commit comments

Comments
 (0)