@@ -1947,18 +1947,8 @@ private void TransferMotion(Transform source, Transform dest, float sampleRate,
1947
1947
// child * parent
1948
1948
var newLocalMatrix = sourceLocalMatrix * destLocalMatrix ;
1949
1949
1950
- // FBX is transposed relative to Unity: transpose as we convert.
1951
- FbxMatrix matrix = new FbxMatrix ( ) ;
1952
- matrix . SetColumn ( 0 , new FbxVector4 ( newLocalMatrix . GetRow ( 0 ) . x , newLocalMatrix . GetRow ( 0 ) . y , newLocalMatrix . GetRow ( 0 ) . z , newLocalMatrix . GetRow ( 0 ) . w ) ) ;
1953
- matrix . SetColumn ( 1 , new FbxVector4 ( newLocalMatrix . GetRow ( 1 ) . x , newLocalMatrix . GetRow ( 1 ) . y , newLocalMatrix . GetRow ( 1 ) . z , newLocalMatrix . GetRow ( 1 ) . w ) ) ;
1954
- matrix . SetColumn ( 2 , new FbxVector4 ( newLocalMatrix . GetRow ( 2 ) . x , newLocalMatrix . GetRow ( 2 ) . y , newLocalMatrix . GetRow ( 2 ) . z , newLocalMatrix . GetRow ( 2 ) . w ) ) ;
1955
- matrix . SetColumn ( 3 , new FbxVector4 ( newLocalMatrix . GetRow ( 3 ) . x , newLocalMatrix . GetRow ( 3 ) . y , newLocalMatrix . GetRow ( 3 ) . z , newLocalMatrix . GetRow ( 3 ) . w ) ) ;
1956
-
1957
- // FBX wants translation, rotation (in euler angles) and scale.
1958
- // We assume there's no real shear, just rounding error.
1959
- FbxVector4 translation , rotation , shear , scale ;
1960
- double sign ;
1961
- matrix . GetElements ( out translation , out rotation , out shear , out scale , out sign ) ;
1950
+ FbxVector4 translation , rotation , scale ;
1951
+ GetTRSFromMatrix ( newLocalMatrix , out translation , out rotation , out scale ) ;
1962
1952
1963
1953
// get rotation directly from matrix, as otherwise causes issues
1964
1954
// with negative rotations.
@@ -2624,18 +2614,8 @@ private bool ExportBoneTransform(
2624
2614
pose = parentBindPose * bindPose . inverse ;
2625
2615
}
2626
2616
2627
- // FBX is transposed relative to Unity: transpose as we convert.
2628
- FbxMatrix matrix = new FbxMatrix ( ) ;
2629
- matrix . SetColumn ( 0 , new FbxVector4 ( pose . GetRow ( 0 ) . x , pose . GetRow ( 0 ) . y , pose . GetRow ( 0 ) . z , pose . GetRow ( 0 ) . w ) ) ;
2630
- matrix . SetColumn ( 1 , new FbxVector4 ( pose . GetRow ( 1 ) . x , pose . GetRow ( 1 ) . y , pose . GetRow ( 1 ) . z , pose . GetRow ( 1 ) . w ) ) ;
2631
- matrix . SetColumn ( 2 , new FbxVector4 ( pose . GetRow ( 2 ) . x , pose . GetRow ( 2 ) . y , pose . GetRow ( 2 ) . z , pose . GetRow ( 2 ) . w ) ) ;
2632
- matrix . SetColumn ( 3 , new FbxVector4 ( pose . GetRow ( 3 ) . x , pose . GetRow ( 3 ) . y , pose . GetRow ( 3 ) . z , pose . GetRow ( 3 ) . w ) ) ;
2633
-
2634
- // FBX wants translation, rotation (in euler angles) and scale.
2635
- // We assume there's no real shear, just rounding error.
2636
- FbxVector4 translation , rotation , shear , scale ;
2637
- double sign ;
2638
- matrix . GetElements ( out translation , out rotation , out shear , out scale , out sign ) ;
2617
+ FbxVector4 translation , rotation , scale ;
2618
+ GetTRSFromMatrix ( pose , out translation , out rotation , out scale ) ;
2639
2619
2640
2620
// Export bones with zero rotation, using a pivot instead to set the rotation
2641
2621
// so that the bones are easier to animate and the rotation shows up as the "joint orientation" in Maya.
@@ -2651,6 +2631,21 @@ private bool ExportBoneTransform(
2651
2631
return true ;
2652
2632
}
2653
2633
2634
+ private void GetTRSFromMatrix ( Matrix4x4 unityMatrix , out FbxVector4 translation , out FbxVector4 rotation , out FbxVector4 scale ) {
2635
+ // FBX is transposed relative to Unity: transpose as we convert.
2636
+ FbxMatrix matrix = new FbxMatrix ( ) ;
2637
+ matrix . SetColumn ( 0 , new FbxVector4 ( unityMatrix . GetRow ( 0 ) . x , unityMatrix . GetRow ( 0 ) . y , unityMatrix . GetRow ( 0 ) . z , unityMatrix . GetRow ( 0 ) . w ) ) ;
2638
+ matrix . SetColumn ( 1 , new FbxVector4 ( unityMatrix . GetRow ( 1 ) . x , unityMatrix . GetRow ( 1 ) . y , unityMatrix . GetRow ( 1 ) . z , unityMatrix . GetRow ( 1 ) . w ) ) ;
2639
+ matrix . SetColumn ( 2 , new FbxVector4 ( unityMatrix . GetRow ( 2 ) . x , unityMatrix . GetRow ( 2 ) . y , unityMatrix . GetRow ( 2 ) . z , unityMatrix . GetRow ( 2 ) . w ) ) ;
2640
+ matrix . SetColumn ( 3 , new FbxVector4 ( unityMatrix . GetRow ( 3 ) . x , unityMatrix . GetRow ( 3 ) . y , unityMatrix . GetRow ( 3 ) . z , unityMatrix . GetRow ( 3 ) . w ) ) ;
2641
+
2642
+ // FBX wants translation, rotation (in euler angles) and scale.
2643
+ // We assume there's no real shear, just rounding error.
2644
+ FbxVector4 shear ;
2645
+ double sign ;
2646
+ matrix . GetElements ( out translation , out rotation , out shear , out scale , out sign ) ;
2647
+ }
2648
+
2654
2649
/// <summary>
2655
2650
/// Counts how many objects are between this object and the root (exclusive).
2656
2651
/// </summary>
0 commit comments