@@ -504,15 +504,23 @@ meshInfo.Vertices [v].z*UnitScaleFactor
504
504
505
505
/// <summary>
506
506
/// Takes a Quaternion and returns a Euler with XYZ rotation order.
507
+ /// Also converts from left (Unity) to righthanded (Maya) coordinates.
508
+ ///
509
+ /// Note: Cannot simply use the FbxQuaternion.DecomposeSphericalXYZ()
510
+ /// function as this returns the angle in spherical coordinates
511
+ /// instead of Euler angles, which Maya does not import properly.
507
512
/// </summary>
508
513
/// <returns>Euler with XYZ rotation order.</returns>
509
- public static Vector3 QuaternionToXYZEuler ( Quaternion q )
514
+ public static FbxDouble3 QuaternionToXYZEuler ( Quaternion q )
510
515
{
511
516
FbxQuaternion quat = new FbxQuaternion ( q . x , q . y , q . z , q . w ) ;
512
517
FbxAMatrix m = new FbxAMatrix ( ) ;
513
518
m . SetQ ( quat ) ;
514
519
var vector4 = m . GetR ( ) ;
515
- var result = new Vector3 ( ( float ) vector4 . X , ( float ) vector4 . Y , ( float ) vector4 . Z ) ;
520
+
521
+ // Negate the y and z values of the rotation to convert
522
+ // from Unity to Maya coordinates (left to righthanded).
523
+ var result = new FbxDouble3 ( vector4 . X , - vector4 . Y , - vector4 . Z ) ;
516
524
517
525
return result ;
518
526
}
@@ -527,13 +535,13 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
527
535
fbxNode . SetRotationOrder ( FbxNode . EPivotSet . eSourcePivot , FbxEuler . EOrder . eOrderXYZ ) ;
528
536
529
537
UnityEngine . Vector3 unityTranslate ;
530
- UnityEngine . Vector3 unityRotate ;
538
+ FbxDouble3 unityRotate ;
531
539
UnityEngine . Vector3 unityScale ;
532
540
533
541
switch ( exportType ) {
534
542
case TransformExportType . Zeroed :
535
543
unityTranslate = Vector3 . zero ;
536
- unityRotate = Vector3 . zero ;
544
+ unityRotate = new FbxDouble3 ( 0 ) ;
537
545
unityScale = Vector3 . one ;
538
546
break ;
539
547
case TransformExportType . Global :
@@ -549,15 +557,15 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
549
557
}
550
558
551
559
// transfer transform data from Unity to Fbx
552
- // Negating the x value of the translation, and the y and z values of the rotation
553
- // to convert from Unity to Maya coordinates (left to righthanded).
560
+ // Negating the x value of the translation to convert from Unity
561
+ // to Maya coordinates (left to righthanded).
554
562
// Scaling the translation by 100 to convert from m to cm.
555
563
var fbxTranslate = new FbxDouble3 (
556
564
- unityTranslate . x * UnitScaleFactor ,
557
565
unityTranslate . y * UnitScaleFactor ,
558
566
unityTranslate . z * UnitScaleFactor
559
567
) ;
560
- var fbxRotate = new FbxDouble3 ( unityRotate . x , - unityRotate . y , - unityRotate . z ) ;
568
+ var fbxRotate = unityRotate ;
561
569
var fbxScale = new FbxDouble3 ( unityScale . x , unityScale . y , unityScale . z ) ;
562
570
563
571
// set the local position of fbxNode
0 commit comments