Skip to content

Commit faf2314

Browse files
committed
code review fixes
return FbxDouble3 instead of Vector3
1 parent f4d8a98 commit faf2314

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,23 @@ meshInfo.Vertices [v].z*UnitScaleFactor
504504

505505
/// <summary>
506506
/// 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.
507512
/// </summary>
508513
/// <returns>Euler with XYZ rotation order.</returns>
509-
public static Vector3 QuaternionToXYZEuler(Quaternion q)
514+
public static FbxDouble3 QuaternionToXYZEuler(Quaternion q)
510515
{
511516
FbxQuaternion quat = new FbxQuaternion (q.x, q.y, q.z, q.w);
512517
FbxAMatrix m = new FbxAMatrix ();
513518
m.SetQ (quat);
514519
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);
516524

517525
return result;
518526
}
@@ -527,13 +535,13 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
527535
fbxNode.SetRotationOrder (FbxNode.EPivotSet.eSourcePivot, FbxEuler.EOrder.eOrderXYZ);
528536

529537
UnityEngine.Vector3 unityTranslate;
530-
UnityEngine.Vector3 unityRotate;
538+
FbxDouble3 unityRotate;
531539
UnityEngine.Vector3 unityScale;
532540

533541
switch (exportType) {
534542
case TransformExportType.Zeroed:
535543
unityTranslate = Vector3.zero;
536-
unityRotate = Vector3.zero;
544+
unityRotate = new FbxDouble3 (0);
537545
unityScale = Vector3.one;
538546
break;
539547
case TransformExportType.Global:
@@ -549,15 +557,15 @@ protected void ExportTransform (UnityEngine.Transform unityTransform, FbxNode fb
549557
}
550558

551559
// 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).
554562
// Scaling the translation by 100 to convert from m to cm.
555563
var fbxTranslate = new FbxDouble3 (
556564
-unityTranslate.x*UnitScaleFactor,
557565
unityTranslate.y*UnitScaleFactor,
558566
unityTranslate.z*UnitScaleFactor
559567
);
560-
var fbxRotate = new FbxDouble3 (unityRotate.x, -unityRotate.y, -unityRotate.z);
568+
var fbxRotate = unityRotate;
561569
var fbxScale = new FbxDouble3 (unityScale.x, unityScale.y, unityScale.z);
562570

563571
// set the local position of fbxNode

0 commit comments

Comments
 (0)