@@ -1148,22 +1148,22 @@ internal static FbxDouble3 ToFbxDouble3(FbxVector4 v)
1148
1148
return new FbxDouble3 ( v . X , v . Y , v . Z ) ;
1149
1149
}
1150
1150
1151
- internal static FbxVector4 ToFbxVector4 ( FbxDouble3 v )
1152
- {
1153
- return new FbxVector4 ( v . X , v . Y , v . Z ) ;
1154
- }
1155
-
1156
1151
/// <summary>
1157
- /// Euler to quaternion without axis conversion .
1152
+ /// Euler (roll/pitch/yaw (ZXY rotation order) to quaternion .
1158
1153
/// </summary>
1159
1154
/// <returns>a quaternion.</returns>
1160
- /// <param name="euler">Euler.</param>
1155
+ /// <param name="euler">ZXY Euler.</param>
1161
1156
internal static FbxQuaternion EulerToQuaternionZXY ( Vector3 euler )
1162
1157
{
1163
1158
var unityQuat = Quaternion . Euler ( euler ) ;
1164
1159
return new FbxQuaternion ( unityQuat . x , unityQuat . y , unityQuat . z , unityQuat . w ) ;
1165
1160
}
1166
1161
1162
+ /// <summary>
1163
+ /// Euler X/Y/Z rotation order to quaternion.
1164
+ /// </summary>
1165
+ /// <param name="euler">XYZ Euler.</param>
1166
+ /// <returns>a quaternion</returns>
1167
1167
internal static FbxQuaternion EulerToQuaternionXYZ ( FbxVector4 euler )
1168
1168
{
1169
1169
FbxAMatrix m = new FbxAMatrix ( ) ;
@@ -1174,11 +1174,6 @@ internal static FbxQuaternion EulerToQuaternionXYZ(FbxVector4 euler)
1174
1174
// get a fbxNode's global default position.
1175
1175
internal bool ExportTransform ( UnityEngine . Transform unityTransform , FbxNode fbxNode , Vector3 newCenter , TransformExportType exportType )
1176
1176
{
1177
- // Fbx rotation order is XYZ, but Unity rotation order is ZXY.
1178
- // Also, DeepConvert does not convert the rotation order (assumes XYZ), unless RotationActive is true.
1179
- fbxNode . SetRotationOrder ( FbxNode . EPivotSet . eSourcePivot , FbxEuler . EOrder . eOrderZXY ) ;
1180
- fbxNode . SetRotationActive ( true ) ;
1181
-
1182
1177
UnityEngine . Vector3 unityTranslate ;
1183
1178
FbxDouble3 fbxRotate ;
1184
1179
UnityEngine . Vector3 unityScale ;
@@ -1638,7 +1633,7 @@ private bool ExportParentConstraint(IConstraint uniConstraint, FbxScene fbxScene
1638
1633
var fbxTranslationOffset = ConvertToFbxVector4 ( uniTranslationOffset , UnitScaleFactor ) ;
1639
1634
fbxParentConstraint . SetTranslationOffset ( uniSource . node , fbxTranslationOffset ) ;
1640
1635
1641
- var fbxRotationOffset = ToFbxVector4 ( ToFbxDouble3 ( uniRotationOffset ) ) ;
1636
+ var fbxRotationOffset = ConvertToFbxVector4 ( uniRotationOffset ) ;
1642
1637
fbxParentConstraint . SetRotationOffset ( uniSource . node , fbxRotationOffset ) ;
1643
1638
}
1644
1639
ExportCommonConstraintProperties ( uniParentConstraint , fbxParentConstraint , fbxNode ) ;
@@ -2500,6 +2495,11 @@ private FbxNode CreateFbxNode(GameObject unityGo, FbxScene fbxScene)
2500
2495
// Use RSrs as the scaling inheritance instead.
2501
2496
fbxNode . SetTransformationInheritType ( FbxTransform . EInheritType . eInheritRSrs ) ;
2502
2497
2498
+ // Fbx rotation order is XYZ, but Unity rotation order is ZXY.
2499
+ // Also, DeepConvert does not convert the rotation order (assumes XYZ), unless RotationActive is true.
2500
+ fbxNode . SetRotationOrder ( FbxNode . EPivotSet . eSourcePivot , FbxEuler . EOrder . eOrderZXY ) ;
2501
+ fbxNode . SetRotationActive ( true ) ;
2502
+
2503
2503
MapUnityObjectToFbxNode [ unityGo ] = fbxNode ;
2504
2504
2505
2505
return fbxNode ;
@@ -2708,14 +2708,6 @@ AnimationOnlyExportData exportData
2708
2708
// cancel silently
2709
2709
return false ;
2710
2710
}
2711
-
2712
- // Rotation order and rotation active must be set before setting the transform, otherwise
2713
- // values may change if setting the rotation order afterwards.
2714
- if ( ! fbxNode . GetRotationActive ( ) )
2715
- {
2716
- fbxNode . SetRotationOrder ( FbxNode . EPivotSet . eSourcePivot , FbxEuler . EOrder . eOrderZXY ) ;
2717
- fbxNode . SetRotationActive ( true ) ;
2718
- }
2719
2711
ExportBoneTransform ( fbxNode , fbxScene , bone . transform , boneInfo ) ;
2720
2712
}
2721
2713
}
@@ -3334,13 +3326,8 @@ internal int ExportAll (
3334
3326
fbxSettings . SetSystemUnit ( FbxSystemUnit . cm ) ;
3335
3327
3336
3328
// The Unity axis system has Y up, Z forward, X to the right (left handed system with odd parity).
3337
- // The Maya axis system has Y up, Z forward, X to the left (right handed system with odd parity).
3338
- // We need to export right-handed for Maya because ConvertScene can't switch handedness:
3339
- // https://forums.autodesk.com/t5/fbx-forum/get-confused-with-fbxaxissystem-convertscene/td-p/4265472
3340
- var unityAxisSystem = new FbxAxisSystem (
3341
- FbxAxisSystem . EUpVector . eYAxis ,
3342
- FbxAxisSystem . EFrontVector . eParityOdd ,
3343
- FbxAxisSystem . ECoordSystem . eLeftHanded ) ;
3329
+ // DirectX has the same axis system, so use this constant.
3330
+ var unityAxisSystem = FbxAxisSystem . DirectX ;
3344
3331
fbxSettings . SetAxisSystem ( unityAxisSystem ) ;
3345
3332
3346
3333
// export set of object
@@ -3425,6 +3412,10 @@ internal int ExportAll (
3425
3412
// Set the scene's default camera.
3426
3413
SetDefaultCamera ( fbxScene ) ;
3427
3414
3415
+ // The Maya axis system has Y up, Z forward, X to the left (right handed system with odd parity).
3416
+ // We need to export right-handed for Maya because ConvertScene (used by Maya and Max importers) can't switch handedness:
3417
+ // https://forums.autodesk.com/t5/fbx-forum/get-confused-with-fbxaxissystem-convertscene/td-p/4265472
3418
+ // This needs to be done last so that everything is converted properly.
3428
3419
FbxAxisSystem . MayaYUp . DeepConvertScene ( fbxScene ) ;
3429
3420
3430
3421
// Export the scene to the file.
0 commit comments